( outputConfig: unknown, )
| 750 | } |
| 751 | |
| 752 | function convertOutputConfig( |
| 753 | outputConfig: unknown, |
| 754 | ): OpenAIChatCompletionRequest['response_format'] { |
| 755 | if ( |
| 756 | !outputConfig || |
| 757 | typeof outputConfig !== 'object' || |
| 758 | !('format' in outputConfig) || |
| 759 | !outputConfig.format || |
| 760 | typeof outputConfig.format !== 'object' |
| 761 | ) { |
| 762 | return undefined |
| 763 | } |
| 764 | |
| 765 | const format = outputConfig.format as Record<string, unknown> |
| 766 | if (format.type === 'json_schema') { |
| 767 | return { |
| 768 | type: 'json_schema', |
| 769 | json_schema: { |
| 770 | name: |
| 771 | typeof format.name === 'string' |
| 772 | ? format.name |
| 773 | : typeof format.schema === 'object' && |
| 774 | format.schema && |
| 775 | 'title' in format.schema && |
| 776 | typeof format.schema.title === 'string' |
| 777 | ? format.schema.title |
| 778 | : 'Schema', |
| 779 | schema: format.schema, |
| 780 | strict: format.strict === true, |
| 781 | }, |
| 782 | } |
| 783 | } |
| 784 | |
| 785 | if (format.type === 'json_object') { |
| 786 | return { type: 'json_object' } |
| 787 | } |
| 788 | |
| 789 | return undefined |
| 790 | } |
| 791 | |
| 792 | function getOpenAICompatReasoningEffort( |
| 793 | outputConfig: unknown, |
no outgoing calls
no test coverage detected