|
| 1 | +import { ChatGoogleGenerativeAI } from "@langchain/google-genai"; |
1 | 2 | import { createReactAgent } from "@langchain/langgraph/prebuilt"; |
2 | 3 | import { ChatOpenAI } from "@langchain/openai"; |
3 | 4 | import alert from "dialogs/alert"; |
@@ -50,14 +51,29 @@ export default function openAIAssistantPage() { |
50 | 51 | }); |
51 | 52 |
|
52 | 53 | const agentCheckpointer = new CordovaSqliteSaver(); |
53 | | - const model = new ChatOpenAI({ |
54 | | - model: settings.value.aiModel, |
55 | | - apiKey: settings.value.aiApiKey, |
56 | | - streaming: true, |
57 | | - configuration: { |
58 | | - baseURL: settings.value.aiBaseUrl, |
59 | | - }, |
60 | | - }); |
| 54 | + if ((settings.value.aiProvider = "openai")) { |
| 55 | + if (!settings.value.aiBaseUrl) { |
| 56 | + alert( |
| 57 | + "Error", |
| 58 | + "Please set your API base url in Settings before using the assistant.", |
| 59 | + ); |
| 60 | + return; |
| 61 | + } |
| 62 | + const model = new ChatOpenAI({ |
| 63 | + model: settings.value.aiModel, |
| 64 | + apiKey: settings.value.aiApiKey, |
| 65 | + streaming: true, |
| 66 | + configuration: { |
| 67 | + baseURL: settings.value.aiBaseUrl, |
| 68 | + }, |
| 69 | + }); |
| 70 | + } else if ((settings.value.aiProvider = "gemini")) { |
| 71 | + const model = new ChatGoogleGenerativeAI({ |
| 72 | + model: settings.value.aiModel, |
| 73 | + apiKey: settings.value.aiApiKey, |
| 74 | + streaming: true, |
| 75 | + }); |
| 76 | + } |
61 | 77 |
|
62 | 78 | const toolsArray = Object.values(allTools); |
63 | 79 |
|
|
0 commit comments