MCPcopy Create free account
hub / github.com/OpenPipe/OpenPipe / serializeChatOutput

Function serializeChatOutput

app/src/modelProviders/fine-tuned/serializers.ts:14–27  ·  view source on GitHub ↗
(output: ChatCompletionMessage)

Source from the content-addressed store, hash-verified

12const FUNCTION_ARGS_TAG = "<arguments>";
13
14export 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
29export const deserializeChatOutput = (
30 completion: string,

Callers 3

countLlamaOutputTokensFunction · 0.90
trainModalFineTuneFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected