diff --git a/src/modules/aifn/autosuggestions/autoSuggestions.ts b/src/modules/aifn/autosuggestions/autoSuggestions.ts index be2336618..74c7953a6 100644 --- a/src/modules/aifn/autosuggestions/autoSuggestions.ts +++ b/src/modules/aifn/autosuggestions/autoSuggestions.ts @@ -83,7 +83,7 @@ export function autoSuggestions(conversationId: string, assistantMessageId: stri // Follow-up: Auto-Diagrams if (suggestDiagrams) { - void llmChatGenerateOrThrow(funcLLMId, [ + llmChatGenerateOrThrow(funcLLMId, [ { role: 'system', content: systemMessage.text }, { role: 'user', content: userMessage.text }, { role: 'assistant', content: assistantMessageText }, @@ -110,7 +110,8 @@ export function autoSuggestions(conversationId: string, assistantMessageId: stri } } }).catch(err => { - console.error('autoSuggestions::diagram:', err); + // Likely the model did not support function calling + // console.log('autoSuggestions: diagram error:', err); }); } diff --git a/src/modules/llms/llm.client.ts b/src/modules/llms/llm.client.ts index 3a6bf5804..580e4b8cb 100644 --- a/src/modules/llms/llm.client.ts +++ b/src/modules/llms/llm.client.ts @@ -5,7 +5,7 @@ import { hasGoogleAnalytics } from '~/common/components/GoogleAnalytics'; import type { ModelDescriptionSchema } from './server/llm.server.types'; import type { OpenAIWire } from './server/openai/openai.wiretypes'; import type { StreamingClientUpdate } from './vendors/unifiedStreamingClient'; -import { DLLM, DLLMId, DModelSource, DModelSourceId, LLM_IF_OAI_Chat, useModelsStore } from './store-llms'; +import { DLLM, DLLMId, DModelSource, DModelSourceId, LLM_IF_OAI_Chat, LLM_IF_OAI_Fn, useModelsStore } from './store-llms'; import { FALLBACK_LLM_TEMPERATURE } from './vendors/openai/openai.vendor'; import { findAccessForSourceOrThrow, findVendorForLlmOrThrow } from './vendors/vendors.registry'; @@ -129,6 +129,10 @@ export async function llmChatGenerateOrThrow(llmId); + // if the model does not support function calling and we're trying to force a function, throw + if (forceFunctionName && !llm.interfaces.includes(LLM_IF_OAI_Fn)) + throw new Error(`Model ${llmId} does not support function calling`); + // FIXME: relax the forced cast const options = llm.options as TLLMOptions; diff --git a/src/modules/llms/server/openai/models.data.ts b/src/modules/llms/server/openai/models.data.ts index 57400f69d..0cf234174 100644 --- a/src/modules/llms/server/openai/models.data.ts +++ b/src/modules/llms/server/openai/models.data.ts @@ -386,7 +386,7 @@ const _knownMistralChatModels: ManualMappings = [ label: 'Codestral (2405)', description: 'Designed and optimized for code generation tasks.', contextWindow: 32768, - interfaces: [LLM_IF_OAI_Chat, LLM_IF_OAI_Fn], + interfaces: [LLM_IF_OAI_Chat], pricing: { chatIn: 1, chatOut: 3 }, }, { @@ -397,7 +397,7 @@ const _knownMistralChatModels: ManualMappings = [ // copied description: 'Designed and optimized for code generation tasks.', contextWindow: 32768, - interfaces: [LLM_IF_OAI_Chat, LLM_IF_OAI_Fn], + interfaces: [LLM_IF_OAI_Chat], pricing: { chatIn: 1, chatOut: 3 }, }, @@ -430,7 +430,7 @@ const _knownMistralChatModels: ManualMappings = [ label: 'Open Mixtral 8x22B (2404)', description: 'Mixtral 8x22B model', contextWindow: 65536, - interfaces: [LLM_IF_OAI_Chat], + interfaces: [LLM_IF_OAI_Chat, LLM_IF_OAI_Fn], pricing: { chatIn: 2, chatOut: 6 }, }, { @@ -441,7 +441,7 @@ const _knownMistralChatModels: ManualMappings = [ // copied description: 'Mixtral 8x22B model', contextWindow: 65536, - interfaces: [LLM_IF_OAI_Chat], + interfaces: [LLM_IF_OAI_Chat, LLM_IF_OAI_Fn], pricing: { chatIn: 2, chatOut: 6 }, }, // Medium (Deprecated)