Skip to content

Commit 74c87be

Browse files
authored
Merge pull request #167 from wrapss/feature/ollama-env
feat: add Ollama endpoint configuration
2 parents af3a84f + be01aaf commit 74c87be

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ AZURE_OPENAI_API_KEY=
1111
DEEPSEEK_ENDPOINT=https://api.deepseek.com
1212
DEEPSEEK_API_KEY=
1313

14+
OLLAMA_ENDPOINT=http://localhost:11434
15+
1416
# Set to false to disable anonymized telemetry
1517
ANONYMIZED_TELEMETRY=true
1618

src/utils/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,16 @@ def get_llm_model(provider: str, **kwargs):
8989
google_api_key=api_key,
9090
)
9191
elif provider == "ollama":
92+
if not kwargs.get("base_url", ""):
93+
base_url = os.getenv("OLLAMA_ENDPOINT", "http://localhost:11434")
94+
else:
95+
base_url = kwargs.get("base_url")
96+
9297
return ChatOllama(
9398
model=kwargs.get("model_name", "qwen2.5:7b"),
9499
temperature=kwargs.get("temperature", 0.0),
95100
num_ctx=kwargs.get("num_ctx", 32000),
96-
base_url=kwargs.get("base_url", "http://localhost:11434"),
101+
base_url=base_url,
97102
)
98103
elif provider == "azure_openai":
99104
if not kwargs.get("base_url", ""):

0 commit comments

Comments
 (0)