( toolChoice: unknown, )
| 713 | } |
| 714 | |
| 715 | function convertToolChoice( |
| 716 | toolChoice: unknown, |
| 717 | ): OpenAIChatCompletionRequest['tool_choice'] { |
| 718 | if (!toolChoice) { |
| 719 | return undefined |
| 720 | } |
| 721 | |
| 722 | if (typeof toolChoice === 'string') { |
| 723 | return toolChoice |
| 724 | } |
| 725 | |
| 726 | if ( |
| 727 | typeof toolChoice === 'object' && |
| 728 | toolChoice !== null && |
| 729 | 'type' in toolChoice |
| 730 | ) { |
| 731 | if (toolChoice.type === 'auto') { |
| 732 | return 'auto' |
| 733 | } |
| 734 | if (toolChoice.type === 'any') { |
| 735 | return 'required' |
| 736 | } |
| 737 | if ( |
| 738 | toolChoice.type === 'tool' && |
| 739 | 'name' in toolChoice && |
| 740 | typeof toolChoice.name === 'string' |
| 741 | ) { |
| 742 | return { |
| 743 | type: 'function', |
| 744 | function: { name: toolChoice.name }, |
| 745 | } |
| 746 | } |
| 747 | } |
| 748 | |
| 749 | return undefined |
| 750 | } |
| 751 | |
| 752 | function convertOutputConfig( |
| 753 | outputConfig: unknown, |
no outgoing calls
no test coverage detected