MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / parseChatCompletion

Function parseChatCompletion

out/cli.cjs:81727–81745  ·  view source on GitHub ↗
(completion, params)

Source from the content-addressed store, hash-verified

81725 choices: completion.choices.map((choice) => ({
81726 ...choice,
81727 message: { ...choice.message, parsed: null, tool_calls: choice.message.tool_calls ?? [] }
81728 }))
81729 };
81730 }
81731 return parseChatCompletion(completion, params);
81732}
81733function parseChatCompletion(completion, params) {
81734 const choices = completion.choices.map((choice) => {
81735 if (choice.finish_reason === "length") {
81736 throw new LengthFinishReasonError();
81737 }
81738 if (choice.finish_reason === "content_filter") {
81739 throw new ContentFilterFinishReasonError();
81740 }
81741 return {
81742 ...choice,
81743 message: {
81744 ...choice.message,
81745 tool_calls: choice.message.tool_calls?.map((toolCall) => parseToolCall(params, toolCall)) ?? [],
81746 parsed: choice.message.content && !choice.message.refusal ? parseResponseFormat(params, choice.message.content) : null
81747 }
81748 };

Callers 3

maybeParseChatCompletionFunction · 0.85
_createChatCompletionMethod · 0.85
parseMethod · 0.85

Calls 2

parseToolCallFunction · 0.85
parseResponseFormatFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…