-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution] AI Assistant: LLM Connector model chooser bug. Ne…
…w chat does not use connector's model (#199303) (#204014) ## Summary The PR fixes [this bug](#199303) The issue happens with some of the locally setup LLMs (like [Ollama](https://github.com/ollama/ollama)) which requires the correct `model` to be passed as part of the [chat completions API](https://github.com/ollama/ollama/blob/main/docs/api.md#generate-a-chat-completion). We had a bug in our code when on new conversation creation we would not pass all the connectors configuration and only `connectorId` and `actionTypeId` would be passed. Here is the old code implementation: ``` const newConversation = await createConversation({ title: NEW_CHAT, ...(currentConversation?.apiConfig != null && currentConversation?.apiConfig?.actionTypeId != null ? { apiConfig: { connectorId: currentConversation.apiConfig.connectorId, actionTypeId: currentConversation.apiConfig.actionTypeId, ...(newSystemPrompt?.id != null ? { defaultSystemPromptId: newSystemPrompt.id } : {}), }, } : {}), }); ``` and thus the new conversation would not have the complete connector configuration which would cause to use default model (`gpt-4o`) as a model we pass to the LLM. Also, I updated the default body that we use on the Test connector page, to make sure that we send a model parameter to the LLM in case of `Open AI > Other (OpenAI Compatible Service)` kind of connectors. ### Testing notes Steps to reproduce: 1. Install [Ollama](https://github.com/ollama/ollama?tab=readme-ov-file#ollama) locally 2. Setup an OpenAI connector using Other (OpenAI Compatible Service) provider 3. Open AI Assistant and select created Ollama connector to chat 4. Create a "New Chat" 5. The Ollama connector should be selected 6. Send a message to LLM (for example "hello world") Expected: there should be no errors saying `ActionsClientChatOpenAI: an error occurred while running the action - Unexpected API Error: - 404 model "gpt-4o" not found, try pulling it first`
- Loading branch information
Showing
5 changed files
with
53 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters