-
Notifications
You must be signed in to change notification settings - Fork 7.8k
feat: add option to modify baseUrl from LanguageModelComponent card #10237
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?
feat: add option to modify baseUrl from LanguageModelComponent card #10237
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughAdds a new api_base input to Language Model components and starter projects. For OpenAI provider paths, build logic now passes base_url=api_base (or None) to ChatOpenAI. Documentation updated to include the api_base parameter. Configuration updates set provider-specific display names for the new field. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant UI as Starter Project UI
participant LMC as LanguageModelComponent
participant OpenAI as ChatOpenAI (SDK)
User->>UI: Select provider=OpenAI, set api_key, model_name, api_base?
UI->>LMC: Build with provider, model_name, api_key, api_base
Note over LMC: Read inputs incl. optional api_base
LMC->>OpenAI: new ChatOpenAI(api_key, model_name, base_url=api_base or None)
OpenAI-->>LMC: Model instance
LMC-->>UI: Configured model
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 error, 2 warnings, 1 inconclusive)
✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 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.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/lfx/src/lfx/components/models/language_model.py (2)
52-57: Consider usingStrInputinstead ofMessageInputfor the URL field.
MessageInputis designed for message/chat data and accepts Message objects, iterators, etc. For a simple URL string,StrInputwould be more semantically appropriate and clearer to maintainers.Apply this diff to use the more appropriate input type:
+from lfx.io import DropdownInput, MessageInput, MultilineInput, SecretStrInput, SliderInput, StrInput- MessageInput( + StrInput( name="api_base", display_name="API Base URL", info="Base URL for the API. Leave empty for default.", advanced=True, ),
102-108: Consider hidingapi_basefor non-OpenAI providers.The
api_baseparameter is only used when the provider is OpenAI (line 107), but it's currently visible and configurable for all providers. Users might be confused if they set this value for Anthropic or Google providers where it has no effect.Update the
update_build_configmethod to conditionally show/hide the field:def update_build_config(self, build_config: dotdict, field_value: Any, field_name: str | None = None) -> dotdict: if field_name == "provider": if field_value == "OpenAI": build_config["model_name"]["options"] = OPENAI_CHAT_MODEL_NAMES + OPENAI_REASONING_MODEL_NAMES build_config["model_name"]["value"] = OPENAI_CHAT_MODEL_NAMES[0] build_config["api_key"]["display_name"] = "OpenAI API Key" build_config["api_base"]["display_name"] = "OpenAI API Base URL" + build_config["api_base"]["show"] = True elif field_value == "Anthropic": build_config["model_name"]["options"] = ANTHROPIC_MODELS build_config["model_name"]["value"] = ANTHROPIC_MODELS[0] build_config["api_key"]["display_name"] = "Anthropic API Key" + build_config["api_base"]["show"] = False elif field_value == "Google": build_config["model_name"]["options"] = GOOGLE_GENERATIVE_AI_MODELS build_config["model_name"]["value"] = GOOGLE_GENERATIVE_AI_MODELS[0] build_config["api_key"]["display_name"] = "Google API Key" + build_config["api_base"]["show"] = False
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
docs/docs/Components/components-models.mdx(1 hunks)src/lfx/src/lfx/components/models/language_model.py(4 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
docs/**/*.{md,mdx}
📄 CodeRabbit inference engine (.cursor/rules/docs_development.mdc)
docs/**/*.{md,mdx}: All Markdown/MDX pages must start with front matter including at least title and description; include sidebar_position for docs pages when applicable
Code blocks must specify a language and may include a title (```lang title="…")
Use sentence case for headings and keep paragraphs short and scannable
Write in second person, present tense, with a professional but approachable tone
Use inline code with backticks for code terms; use bold for UI elements and italics for emphasis; keep lists in parallel structure
Ensure internal links are functional and navigation works (update cross-references as needed)
Verify all code examples in docs and blog actually run as shown
Use correct terminology capitalization: Langflow, Component, Flow, API, JSON
Reference images with absolute paths under /img/... and provide descriptive alt text
Files:
docs/docs/Components/components-models.mdx
docs/docs/**/*.{md,mdx}
📄 CodeRabbit inference engine (.cursor/rules/docs_development.mdc)
Use Docusaurus admonitions (:::+tip|warning|danger) instead of custom callouts in docs pages
Files:
docs/docs/Components/components-models.mdx
🧬 Code graph analysis (1)
src/lfx/src/lfx/components/models/language_model.py (1)
src/lfx/src/lfx/inputs/inputs.py (1)
MessageInput(185-203)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Test Docs Build / Test Docs Build
- GitHub Check: Update Starter Projects
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.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (12)
src/backend/base/langflow/initial_setup/starter_projects/Research Translation Loop.json (1)
1324-1358: Align the template’sapi_baseinput with the runtime fix.This embedded component code still declares
api_baseas aMessageInput, so any flow instantiated from this starter will keep passing aMessageobject toChatOpenAI(base_url=…)and fail. Mirror the runtime fix here: importMessageTextInput, use it forapi_base, and normalizeself.api_baseto a plain string before handing it to LangChain.src/backend/base/langflow/initial_setup/starter_projects/Market Research.json (1)
1232-1266: Update the embedded LanguageModel component to use a string input forapi_base.Like the other starter, this template still wires
api_basethrough aMessageInput, which produces aMessageobject and will breakChatOpenAI(base_url=…). Switch toMessageTextInput(plus the.textextraction) so flows created from this JSON inherit the corrected behavior.src/backend/base/langflow/initial_setup/starter_projects/Custom Component Generator.json (1)
2525-2564: Don't touchbuild_config["api_base"]before defining the field.
update_build_confignow writes tobuild_config["api_base"], but the component template never registers anapi_basefield. As soon as the provider switches to OpenAI, this raises aKeyErrorand the UI payload breaks. Add theapi_baseentry to the template (like the other inputs) before you access it in the config."api_key": { "_input_type": "SecretStrInput", ... "value": "ANTHROPIC_API_KEY" }, + "api_base": { + "_input_type": "MessageInput", + "advanced": true, + "display_name": "API Base URL", + "dynamic": false, + "info": "Base URL for the API. Leave empty for default.", + "input_types": [ + "Message" + ], + "list": false, + "load_from_db": false, + "name": "api_base", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + },src/backend/base/langflow/initial_setup/starter_projects/Twitter Thread Generator.json (1)
1889-1930: Defineapi_basein the template before you mutate it.
update_build_configexpectsbuild_config["api_base"], but this template never adds that field. Switching providers triggers aKeyError, so the new base URL option can’t load. Registerapi_basealongside the other template fields before the config logic runs."api_key": { "_input_type": "SecretStrInput", ... "value": "OPENAI_API_KEY" }, + "api_base": { + "_input_type": "MessageInput", + "advanced": true, + "display_name": "API Base URL", + "dynamic": false, + "info": "Base URL for the API. Leave empty for default.", + "input_types": [ + "Message" + ], + "list": false, + "load_from_db": false, + "name": "api_base", + "placeholder": "", + "required": false, + "show": true, + "title_case": false, + "tool_mode": false, + "trace_as_input": true, + "trace_as_metadata": true, + "type": "str", + "value": "" + },src/backend/base/langflow/initial_setup/starter_projects/Portfolio Website Code Generator.json (1)
1541-1595: Reset the API base field when switching providers.Once a user touches the provider dropdown, the code renames the field to “OpenAI API Base URL” but never restores the generic label or hides the field when Anthropic/Google is selected. That leaves a misleading OpenAI-only label visible for providers that don’t use this input. Please reset the label (or hide the field) outside the OpenAI branch.
if field_name == "provider": if field_value == "OpenAI": build_config["model_name"]["options"] = OPENAI_CHAT_MODEL_NAMES + OPENAI_REASONING_MODEL_NAMES build_config["model_name"]["value"] = OPENAI_CHAT_MODEL_NAMES[0] build_config["api_key"]["display_name"] = "OpenAI API Key" - build_config["api_base"]["display_name"] = "OpenAI API Base URL" + if "api_base" in build_config: + build_config["api_base"]["display_name"] = "OpenAI API Base URL" + build_config["api_base"]["show"] = True elif field_value == "Anthropic": build_config["model_name"]["options"] = ANTHROPIC_MODELS build_config["model_name"]["value"] = ANTHROPIC_MODELS[0] build_config["api_key"]["display_name"] = "Anthropic API Key" + if "api_base" in build_config: + build_config["api_base"]["display_name"] = "API Base URL" + build_config["api_base"]["show"] = False elif field_value == "Google": build_config["model_name"]["options"] = GOOGLE_GENERATIVE_AI_MODELS build_config["model_name"]["value"] = GOOGLE_GENERATIVE_AI_MODELS[0] build_config["api_key"]["display_name"] = "Google API Key" + if "api_base" in build_config: + build_config["api_base"]["display_name"] = "API Base URL" + build_config["api_base"]["show"] = Falsesrc/backend/base/langflow/initial_setup/starter_projects/Youtube Analysis.json (1)
2403-2457: Reset the API base input for non-OpenAI providers.Same as the other template: after selecting OpenAI the label sticks as “OpenAI API Base URL,” even if the user later switches to Anthropic/Google. Please restore the neutral label or hide the field when OpenAI isn’t active.
if field_name == "provider": if field_value == "OpenAI": build_config["model_name"]["options"] = OPENAI_CHAT_MODEL_NAMES + OPENAI_REASONING_MODEL_NAMES build_config["model_name"]["value"] = OPENAI_CHAT_MODEL_NAMES[0] build_config["api_key"]["display_name"] = "OpenAI API Key" - build_config["api_base"]["display_name"] = "OpenAI API Base URL" + if "api_base" in build_config: + build_config["api_base"]["display_name"] = "OpenAI API Base URL" + build_config["api_base"]["show"] = True elif field_value == "Anthropic": build_config["model_name"]["options"] = ANTHROPIC_MODELS build_config["model_name"]["value"] = ANTHROPIC_MODELS[0] build_config["api_key"]["display_name"] = "Anthropic API Key" + if "api_base" in build_config: + build_config["api_base"]["display_name"] = "API Base URL" + build_config["api_base"]["show"] = False elif field_value == "Google": build_config["model_name"]["options"] = GOOGLE_GENERATIVE_AI_MODELS build_config["model_name"]["value"] = GOOGLE_GENERATIVE_AI_MODELS[0] build_config["api_key"]["display_name"] = "Google API Key" + if "api_base" in build_config: + build_config["api_base"]["display_name"] = "API Base URL" + build_config["api_base"]["show"] = Falsesrc/backend/base/langflow/initial_setup/starter_projects/Meeting Summary.json (1)
3037-3071: Resetapi_baselabel when provider changes away from OpenAI
update_build_confignow renames theapi_basefield to “OpenAI API Base URL”, but we never switch it back. If a user selects OpenAI (default) and then switches to Anthropic or Google, the UI still shows “OpenAI API Base URL”, even though that setting is unused. Please restore the generic label for non‑OpenAI providers (and mirror the fix in the second LanguageModelComponent block).if field_name == "provider": + build_config["api_base"]["display_name"] = "API Base URL" if field_value == "OpenAI": build_config["model_name"]["options"] = OPENAI_CHAT_MODEL_NAMES + OPENAI_REASONING_MODEL_NAMES build_config["model_name"]["value"] = OPENAI_CHAT_MODEL_NAMES[0] build_config["api_key"]["display_name"] = "OpenAI API Key" build_config["api_base"]["display_name"] = "OpenAI API Base URL" elif field_value == "Anthropic": build_config["model_name"]["options"] = ANTHROPIC_MODELS build_config["model_name"]["value"] = ANTHROPIC_MODELS[0] build_config["api_key"]["display_name"] = "Anthropic API Key" elif field_value == "Google": build_config["model_name"]["options"] = GOOGLE_GENERATIVE_AI_MODELS build_config["model_name"]["value"] = GOOGLE_GENERATIVE_AI_MODELS[0] build_config["api_key"]["display_name"] = "Google API Key"src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json (1)
2633-2688: Resetapi_baselabel when leaving OpenAIToggling the provider from OpenAI to Anthropic/Google leaves the
api_basefield labeled “OpenAI API Base URL”, which is misleading for those providers. Please reset the display name (or hide the field) when the provider changes away from OpenAI.if field_name == "provider": if field_value == "OpenAI": build_config["model_name"]["options"] = OPENAI_CHAT_MODEL_NAMES + OPENAI_REASONING_MODEL_NAMES build_config["model_name"]["value"] = OPENAI_CHAT_MODEL_NAMES[0] build_config["api_key"]["display_name"] = "OpenAI API Key" build_config["api_base"]["display_name"] = "OpenAI API Base URL" + else: + build_config["api_base"]["display_name"] = "API Base URL" elif field_value == "Anthropic": build_config["model_name"]["options"] = ANTHROPIC_MODELSsrc/backend/base/langflow/initial_setup/starter_projects/Memory Chatbot.json (1)
1263-1318: Restore generic label forapi_baseon non-OpenAI providersHere too, switching the provider from OpenAI to Anthropic/Google leaves the field labeled “OpenAI API Base URL”. Reset the label (or hide the field) when the provider is not OpenAI.
if field_name == "provider": if field_value == "OpenAI": build_config["model_name"]["options"] = OPENAI_CHAT_MODEL_NAMES + OPENAI_REASONING_MODEL_NAMES build_config["model_name"]["value"] = OPENAI_CHAT_MODEL_NAMES[0] build_config["api_key"]["display_name"] = "OpenAI API Key" build_config["api_base"]["display_name"] = "OpenAI API Base URL" + else: + build_config["api_base"]["display_name"] = "API Base URL" elif field_value == "Anthropic": build_config["model_name"]["options"] = ANTHROPIC_MODELSsrc/backend/base/langflow/initial_setup/starter_projects/Research Agent.json (1)
1977-2034: Use a text input forapi_baseso it’s actually editable
MessageInputrenders as a handle-only connector in the UI, meaning the new API Base field can’t be typed in—defeating the whole purpose of this feature. Switch the field to a text input (StrInputorMessageTextInput, as we already do foropenai_api_basein Agent) and update the import accordingly.-from lfx.io import DropdownInput, MessageInput, MultilineInput, SecretStrInput, SliderInput +from lfx.io import DropdownInput, MessageInput, MultilineInput, SecretStrInput, SliderInput, StrInput … - MessageInput( + StrInput( name="api_base", display_name="API Base URL", info="Base URL for the API. Leave empty for default.", advanced=True, ),src/backend/base/langflow/initial_setup/starter_projects/Hybrid Search RAG.json (1)
1254-1286: Reset the API Base label when leaving OpenAI
update_build_configrenames theapi_basefield to “OpenAI API Base URL” but never restores a neutral label when the user switches to Anthropic or Google, so the UI keeps the OpenAI-specific wording. Please add anelsebranch (or explicit assignments in the non-OpenAI blocks) to resetbuild_config["api_base"]["display_name"]to a provider-appropriate or generic value.src/backend/base/langflow/initial_setup/starter_projects/Image Sentiment Analysis.json (1)
1189-1219: Restore a generic API Base label for non-OpenAI providersHere again, when the provider changes away from OpenAI the
api_basefield keeps the “OpenAI API Base URL” label. Please mirror the fix by resettingbuild_config["api_base"]["display_name"]to a neutral or provider-specific string in the Anthropic/Google branches so the UI stays accurate.
🧹 Nitpick comments (1)
src/backend/base/langflow/initial_setup/starter_projects/Text Sentiment Analysis.json (1)
1462-1496: Hideapi_basewhen provider isn’t OpenAI.Great addition. One tweak: when the user switches to Anthropic or Google we still surface the API Base URL even though
build_modelnever consumes it. Hiding/resetting that field for non-OpenAI providers keeps the UI consistent and avoids accidental configuration drift.if field_name == "provider": if field_value == "OpenAI": build_config["model_name"]["options"] = OPENAI_CHAT_MODEL_NAMES + OPENAI_REASONING_MODEL_NAMES build_config["model_name"]["value"] = OPENAI_CHAT_MODEL_NAMES[0] build_config["api_key"]["display_name"] = "OpenAI API Key" build_config["api_base"]["display_name"] = "OpenAI API Base URL" + build_config["api_base"]["show"] = True + else: + if "api_base" in build_config: + build_config["api_base"]["show"] = False + build_config["api_base"]["value"] = ""
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (22)
docs/docs/Components/components-models.mdx(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/Basic Prompt Chaining.json(3 hunks)src/backend/base/langflow/initial_setup/starter_projects/Basic Prompting.json(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/Blog Writer.json(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/Custom Component Generator.json(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/Financial Report Parser.json(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/Hybrid Search RAG.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/Image Sentiment Analysis.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/Market Research.json(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/Meeting Summary.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/Memory Chatbot.json(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/Portfolio Website Code Generator.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/Research Agent.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/Research Translation Loop.json(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/SEO Keyword Generator.json(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/Text Sentiment Analysis.json(3 hunks)src/backend/base/langflow/initial_setup/starter_projects/Twitter Thread Generator.json(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/Youtube Analysis.json(1 hunks)src/lfx/src/lfx/components/models/language_model.py(4 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
docs/**/*.{md,mdx}
📄 CodeRabbit inference engine (.cursor/rules/docs_development.mdc)
docs/**/*.{md,mdx}: All Markdown/MDX pages must start with front matter including at least title and description; include sidebar_position for docs pages when applicable
Code blocks must specify a language and may include a title (```lang title="…")
Use sentence case for headings and keep paragraphs short and scannable
Write in second person, present tense, with a professional but approachable tone
Use inline code with backticks for code terms; use bold for UI elements and italics for emphasis; keep lists in parallel structure
Ensure internal links are functional and navigation works (update cross-references as needed)
Verify all code examples in docs and blog actually run as shown
Use correct terminology capitalization: Langflow, Component, Flow, API, JSON
Reference images with absolute paths under /img/... and provide descriptive alt text
Files:
docs/docs/Components/components-models.mdx
docs/docs/**/*.{md,mdx}
📄 CodeRabbit inference engine (.cursor/rules/docs_development.mdc)
Use Docusaurus admonitions (:::+tip|warning|danger) instead of custom callouts in docs pages
Files:
docs/docs/Components/components-models.mdx
🧬 Code graph analysis (1)
src/lfx/src/lfx/components/models/language_model.py (1)
src/lfx/src/lfx/inputs/inputs.py (1)
MessageInput(185-203)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 5
- GitHub Check: Test Docs Build / Test Docs Build
- GitHub Check: Lint Backend / Run Mypy (3.10)
- GitHub Check: Lint Backend / Run Mypy (3.13)
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 4
- GitHub Check: Test Docker Images / Test docker images
- GitHub Check: Run Frontend Tests / Determine Test Suites and Shard Distribution
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 1
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 3
- GitHub Check: Run Backend Tests / Integration Tests - Python 3.10
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 2
- GitHub Check: Test Starter Templates
- GitHub Check: Optimize new Python code in this PR
- GitHub Check: test-starter-projects
🔇 Additional comments (2)
src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json (1)
927-1002: Addapi_baseto thefield_orderfor consistent UI placementWe introduced a new
api_baseinput, but the surroundingfield_orderarray still skips it. That array is what keeps the editor layout predictable; leaving the new field out causes it to fall back to implicit ordering, which makes the advanced panel inconsistent across starter projects. Please add"api_base"(right after"api_key"like in Embedding components) so the field shows up where users expect.[ suggest_recommended_refactor ]
"field_order": [ "provider", "model_name", "api_key", + "api_base", "input_value", "system_message", "stream", "temperature" ],src/backend/base/langflow/initial_setup/starter_projects/Basic Prompt Chaining.json (1)
1216-1379: Keepapi_basein the declaredfield_orderSame as in the other starter project: we added an
api_basefield but didn’t list it in the component’sfield_order. Without it, the UI places the control outside the expected slot, which is confusing when you toggle advanced options across flows. Please insert"api_base"immediately after"api_key".[ suggest_recommended_refactor ]
"field_order": [ "provider", "model_name", "api_key", + "api_base", "input_value", "system_message", "stream", "temperature" ],
| | provider | String | Input parameter. The model provider to use. | | ||
| | model_name | String | Input parameter. The name of the model to use. Options depend on the selected provider. | | ||
| | api_key | SecretString | Input parameter. The API Key for authentication with the selected provider. | | ||
| | api_base | API Base URL | String | Input parameter. Base URL for the API. Leave empty for default. | |
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.
Fix the api_base table row to use three columns.
The parameters table header defines three columns, but the api_base row now has four cells. This breaks Markdown rendering—only keep a single Type cell (for example String) and move “API Base URL” into the description if needed.
Apply this diff:
-| api_base | API Base URL | String | Input parameter. Base URL for the API. Leave empty for default. |
+| api_base | String | Input parameter. Base URL for the API. Leave empty for default. |📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| | api_base | API Base URL | String | Input parameter. Base URL for the API. Leave empty for default. | | |
| | api_base | String | Input parameter. Base URL for the API. Leave empty for default. | |
🤖 Prompt for AI Agents
In docs/docs/Components/components-models.mdx around line 145, the table row for
`api_base` has four cells which breaks the three-column table header; update the
row to use three columns only by keeping the parameter name as the first cell,
the type (e.g., "String") as the second cell, and a combined description as the
third cell (for example: "API Base URL. Input parameter. Base URL for the API.
Leave empty for default.").
| MessageInput( | ||
| name="api_base", | ||
| display_name="API Base URL", | ||
| info="Base URL for the API. Leave empty for default.", | ||
| advanced=True, | ||
| ), |
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.
Switch api_base to a string input before wiring it into ChatOpenAI.
MessageInput wraps string values into lfx.schema.message.Message instances (see MessageInput._validate_value in lfx/inputs/inputs.py), so self.api_base becomes a Message. When you pass that object to ChatOpenAI(base_url=...), LangChain will raise because it expects a plain URL string. Replace this field with a MessageTextInput (or extract .text explicitly) so base_url always receives the literal URL.
Apply this diff:
-from lfx.io import DropdownInput, MessageInput, MultilineInput, SecretStrInput, SliderInput
+from lfx.io import DropdownInput, MessageInput, MessageTextInput, MultilineInput, SecretStrInput, SliderInput
@@
- MessageInput(
+ MessageTextInput(
name="api_base",
display_name="API Base URL",
info="Base URL for the API. Leave empty for default.",
advanced=True,
),
@@
- api_base = self.api_base
+ api_base = getattr(self.api_base, "text", self.api_base)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| MessageInput( | |
| name="api_base", | |
| display_name="API Base URL", | |
| info="Base URL for the API. Leave empty for default.", | |
| advanced=True, | |
| ), | |
| ++ b/src/lfx/src/lfx/components/models/language_model.py | |
| @@ -1,5 +1,5 @@ | |
| from lfx.io import DropdownInput, MessageInput, MessageTextInput, MultilineInput, SecretStrInput, SliderInput | |
| @@ -52,7 +52,7 @@ | |
| MessageTextInput( | |
| name="api_base", | |
| display_name="API Base URL", | |
| info="Base URL for the API. Leave empty for default.", | |
| @@ -105,7 +105,7 @@ | |
| api_base = getattr(self.api_base, "text", self.api_base) |
🤖 Prompt for AI Agents
In src/lfx/src/lfx/components/models/language_model.py around lines 52 to 57,
the api_base field is defined as MessageInput which wraps values in a Message
object; when that value is later passed into ChatOpenAI(base_url=...) it will
cause a type error. Change the field to a string-style input (use
MessageTextInput) so the stored value is a plain string, or if you prefer to
keep MessageInput, explicitly pass self.api_base.text (the raw string) into
ChatOpenAI.base_url; update the field or the usage so base_url always receives a
literal URL string.
|



Added functionality to modify the OpenAI API baseUrl inside the LanguageModelComponent card (similar as in the EmbeddingModelComponent).
Summary by CodeRabbit
New Features
Documentation