(completion, params)
| 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 | } |
| 81733 | function 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 | }; |
no test coverage detected
searching dependent graphs…