Skip to content

Commit

Permalink
fix(message-converter): enhance assistant message handling to include…
Browse files Browse the repository at this point in the history
… content and tool calls
  • Loading branch information
joschkabraun authored Jan 17, 2025
1 parent 234d600 commit 42f2809
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/utils/message-converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,20 @@ export class OpenAIMessageConverter implements MessageConverter {
content: JSON.stringify(m.function_call),
};
} else if (m.role === 'assistant' && !!m.tool_calls) {
return {
role: Role.assistant,
content: JSON.stringify(m.tool_calls),
};
if (!!m.content) {
return {
role: Role.assistant,
content: JSON.stringify({
content: m.content,
tool_calls: m.tool_calls,
}),
};
} else {
return {
role: Role.assistant,
content: JSON.stringify(m.tool_calls),
};
}
} else {
return {
role: Role[m.role as keyof typeof Role],
Expand Down

0 comments on commit 42f2809

Please sign in to comment.