Skip to content

Commit

Permalink
fix: transfrom wrong format in json response from Anthropic (#897)
Browse files Browse the repository at this point in the history
  • Loading branch information
marknguyen1302 authored Jul 19, 2024
1 parent 10bfad2 commit dc57195
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cortex-js/src/extensions/anthropic.engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class AnthropicEngineExtension extends OAIEngineExtension {
return _.pick(data, ['messages', 'model', 'stream', 'max_tokens']);
};

transformResponse = (data: any): string => {
transformResponse = (data: any) => {
// handling stream response
if (typeof data === 'string' && data.trim().length === 0) {
return '';
Expand Down Expand Up @@ -82,15 +82,15 @@ export default class AnthropicEngineExtension extends OAIEngineExtension {
}
// non-stream response
if (data.content && data.content.length > 0 && data.content[0].text) {
return JSON.stringify({
return {
choices: [
{
delta: {
content: data.content[0].text,
},
},
],
});
};
}

console.error('Invalid response format:', data);
Expand Down

0 comments on commit dc57195

Please sign in to comment.