MCPcopy Create free account
hub / github.com/Noumena-Network/code / convertToolChoice

Function convertToolChoice

src/services/api/openAICompatInferenceClient.ts:715–750  ·  view source on GitHub ↗
(
  toolChoice: unknown,
)

Source from the content-addressed store, hash-verified

713}
714
715function 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
752function convertOutputConfig(
753 outputConfig: unknown,

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected