-
-
Notifications
You must be signed in to change notification settings - Fork 23.2k
Add ChatOllama Cloud component #5497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add a dedicated ChatOllama Cloud chat model component to integrate with Ollama Cloud API (https://ollama.com) with complete tool calling functionality. Features: - Dropdown selection for available Ollama Cloud models: * gpt-oss:120b, gpt-oss:20b * deepseek-v3.1:671b * qwen3-coder:480b, qwen3-vl:235b * minimax-m2, glm-4.6 - Configurable base URL (defaults to https://ollama.com) - Full tool calling support with bidirectional argument conversion Files added: - packages/components/nodes/chatmodels/ChatOllamaCloud/ChatOllamaCloud.ts - packages/components/nodes/chatmodels/ChatOllamaCloud/Ollama.svg - packages/components/credentials/OllamaCloudApi.credential.ts
Summary of ChangesHello @hung101, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a dedicated ChatOllamaCloud component, which is a great addition. The implementation cleverly wraps the existing ChatOpenAI component to create a compatibility layer for the Ollama Cloud API. My review focuses on improving the robustness and maintainability of this new component. I've identified a critical issue with how the temperature parameter is handled which could lead to runtime errors, and I've provided a fix. I also have a couple of suggestions to improve code efficiency and remove some redundant code, which will make the component easier to maintain in the future.
| const obj: any = { | ||
| temperature: parseFloat(temperature), | ||
| model: modelName | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The temperature parameter is parsed unconditionally. If this optional field is cleared in the UI, nodeData.inputs?.temperature could be undefined or an empty string. parseFloat on these values results in NaN, which will be sent to the API and likely cause requests to fail. To ensure robustness, you should parse temperature conditionally, similar to how other optional numeric parameters like maxTokens are handled.
| const obj: any = { | |
| temperature: parseFloat(temperature), | |
| model: modelName | |
| } | |
| const obj: any = { | |
| model: modelName | |
| } | |
| if (temperature) { | |
| obj.temperature = parseFloat(temperature) | |
| } |
| // Manual conversion for LangChain tools with Zod schema | ||
| if (tool.name && tool.schema) { | ||
| try { | ||
| const { zodToJsonSchema } = require('zod-to-json-schema') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The require('zod-to-json-schema') call is inside a map function. While require is cached by Node.js, calling it repeatedly within a loop is inefficient and can be harder to read. It's better practice to move this require statement outside the boundTools.map(...) loop to ensure it's resolved only once.
| const model = new ChatOpenAI(obj) | ||
|
|
||
| // Force streaming to false for Ollama compatibility | ||
| model.streaming = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is redundant. The ChatOpenAI constructor defaults streaming to false if it's not provided in the options. Since the obj passed to the constructor doesn't include a streaming property, the model instance is already created with streaming: false. You can remove this line for code clarity. Additionally, the streaming variable declared on line 256 is unused and can also be removed.
hung101
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add fallback handling
Add a dedicated ChatOllama Cloud chat model component to integrate with Ollama Cloud API (https://ollama.com) with complete tool calling functionality.
Features:
Files added: