fix: make OLLAMA_BASE_URL optional with sensible default#1755
Open
octo-patch wants to merge 6 commits into
Open
fix: make OLLAMA_BASE_URL optional with sensible default#1755octo-patch wants to merge 6 commits into
octo-patch wants to merge 6 commits into
Conversation
Adds ModelsLab as an alternative image generation provider alongside the existing Google Gemini/Imagen provider. ModelsLab (https://modelslab.com) provides access to Flux, SDXL, Stable Diffusion, and 50k+ community models via a simple REST API. Usage: export MODELSLAB_API_KEY=your_key # In config: IMAGE_GENERATION_ENABLED=true IMAGE_GENERATION_PROVIDER=modelslab IMAGE_GENERATION_MODEL=flux # or sdxl, stable-diffusion-2-1, etc. Changes: - llm_provider/image/modelslab_image_generator.py: new ModelsLabImageGeneratorProvider - llm_provider/image/__init__.py: export new class - config/variables/base.py: add IMAGE_GENERATION_PROVIDER field - config/variables/default.py: default provider is 'google' (backward compatible) - skills/image_generator.py: select provider based on IMAGE_GENERATION_PROVIDER
…age-provider feat: add ModelsLab image generation provider
When STRATEGIC_LLM env var is set without colon (e.g., 'gpt-4o'), model_name is undefined, causing NameError. Fix: assign strategic_llm directly to task['model'] in elif branch. Fixes assafelovic#1673
fix: NameError when STRATEGIC_LLM lacks colon separator (assafelovic#1673)
…elovic#1087) os.environ["OLLAMA_BASE_URL"] raised KeyError for users who hadn't set the variable, crashing the Ollama provider before any LLM call was made. Additionally, always passing base_url as a positional-style kwarg while kwargs could also contain base_url caused "got multiple values for keyword argument 'base_url'" errors when callers passed it explicitly. Fix: use os.environ.get with "http://localhost:11434" as the default (standard Ollama listen address) and only inject it when base_url is not already present in kwargs. Co-Authored-By: Octopus <liyuan851277048@icloud.com>
Owner
|
hey @octo-patch not sure why we need all that extra commits around images? |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1087
Problem
base.pyalways readsos.environ["OLLAMA_BASE_URL"]with a hard dictlookup, which raises
KeyErrorfor any user who runs Ollama on thedefault
localhost:11434and hasn't set the environment variable.A second related failure occurs when a caller already supplies
base_urlin kwargs: the code also injects it from the env variable, causing
ChatOllama() got multiple values for keyword argument 'base_url'.Both of these were reported in #1087.
Solution
os.environ["OLLAMA_BASE_URL"]withos.environ.get("OLLAMA_BASE_URL", "http://localhost:11434")so usersrunning a stock Ollama install get the correct default without setting
any environment variable.
base_urlkwarg when the caller hasn't alreadysupplied it, eliminating the "multiple values" error.
Testing
OLLAMA_BASE_URL:get_llm("ollama", model="llama3")no longer raisesKeyError.OLLAMA_BASE_URL: the env value is used as before.base_urlin kwargs: no "multiple values" error.