Mistral: FC warnings

This commit is contained in:
Enrico Ros
2024-07-25 01:28:52 -07:00
parent d3aaa8ae75
commit 1eee2b8710
2 changed files with 12 additions and 2 deletions
@@ -59,7 +59,7 @@ export function aixToOpenAIChatCompletions(openAIDialect: OpenAIDialects, model:
model: model.id,
messages: chatMessages,
tools: chatGenerate.tools && _toOpenAITools(chatGenerate.tools),
tool_choice: chatGenerate.toolsPolicy && _toOpenAIToolChoice(chatGenerate.toolsPolicy),
tool_choice: chatGenerate.toolsPolicy && _toOpenAIToolChoice(openAIDialect, chatGenerate.toolsPolicy),
parallel_tool_calls: undefined,
max_tokens: model.maxTokens !== undefined ? model.maxTokens : undefined,
temperature: model.temperature !== undefined ? model.temperature : undefined,
@@ -335,7 +335,14 @@ function _toOpenAITools(itds: AixTools_ToolDefinition[]): NonNullable<TRequest['
});
}
function _toOpenAIToolChoice(itp: AixTools_ToolsPolicy): NonNullable<TRequest['tool_choice']> {
function _toOpenAIToolChoice(openAIDialect: OpenAIDialects, itp: AixTools_ToolsPolicy): NonNullable<TRequest['tool_choice']> {
// [Mistral] - supports 'auto', 'none', 'any'
if (openAIDialect === 'mistral' && itp.type !== 'auto') {
// Note: we tried adding the 'any' model, but don't feel comfortable with altering our good parsers
// to allow for Mistral's deviation from the de-facto norm set by the OpenAI protocol.
throw new Error('We only support automatic tool selection for Mistral models');
}
// NOTE: OpenAI has an additional policy 'none', which we don't have as it behaves like passing no tools at all.
// Passing no tools is mandated instead of 'none'.
switch (itp.type) {
@@ -170,6 +170,9 @@ export namespace OpenAIWire_Tools {
type: z.literal('function'),
function: z.object({ name: z.string() }),
}),
// [Mistral] Mistral only, requires an 'any' value
// Commented because we'll disable Mistral function calling instead
// z.literal('any'),
]);
}