(params, content)
| 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 | }; |
| 81749 | }); |
| 81750 | return { ...completion, choices }; |
| 81751 | } |
| 81752 | function parseResponseFormat(params, content) { |
| 81753 | if (params.response_format?.type !== "json_schema") { |
| 81754 | return null; |
| 81755 | } |
| 81756 | if (params.response_format?.type === "json_schema") { |
| 81757 | if ("$parseRaw" in params.response_format) { |
| 81758 | const response_format = params.response_format; |
| 81759 | return response_format.$parseRaw(content); |
| 81760 | } |
| 81761 | return JSON.parse(content); |
no test coverage detected
searching dependent graphs…