(output: ChatCompletionMessage)
| 12 | const FUNCTION_ARGS_TAG = "<arguments>"; |
| 13 | |
| 14 | export const serializeChatOutput = (output: ChatCompletionMessage) => { |
| 15 | let formatted = ""; |
| 16 | if (output?.tool_calls) { |
| 17 | for (const toolCall of output.tool_calls) { |
| 18 | formatted += FUNCTION_CALL_TAG + toolCall.function.name; |
| 19 | if (toolCall.function.arguments) { |
| 20 | formatted += FUNCTION_ARGS_TAG + toolCall.function.arguments; |
| 21 | } |
| 22 | } |
| 23 | } else { |
| 24 | formatted = output?.content ?? ""; |
| 25 | } |
| 26 | return formatted; |
| 27 | }; |
| 28 | |
| 29 | export const deserializeChatOutput = ( |
| 30 | completion: string, |
no outgoing calls
no test coverage detected