Skip to content

Commit

Permalink
fix: response is a json string
Browse files Browse the repository at this point in the history
  • Loading branch information
birme committed Dec 9, 2024
1 parent 3dd9ef7 commit 276c245
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/api_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ const apiService: FastifyPluginCallback<ApiServiceOptions> = (
]
});

return reply.send(chatCompletion.choices[0].message.content.assistantMessage);
if (chatCompletion.choices[0].message.content) {
const content = JSON.parse(chatCompletion.choices[0].message.content);
return reply.send(content.assistantMessage);
}
return reply.send('empty response');
}

next();
Expand Down

0 comments on commit 276c245

Please sign in to comment.