Skip to content

FinceptTerminal is a modern finance application offering advanced market analytics, investment research, and economic data tools, designed for interactive exploration and data-driven decision-making in a user-friendly environment.

fix(agents): Ollama provider needs host+options, ship ollama pkg

tilakpatel2276421f6624a2
diff --git a/fincept-qt/resources/requirements-numpy2.txt b/fincept-qt/resources/requirements-numpy2.txt
index 00f9144aa..33a734671 100644
--- a/fincept-qt/resources/requirements-numpy2.txt
+++ b/fincept-qt/resources/requirements-numpy2.txt
@@ -77,6 +77,11 @@ tiktoken>=0.5.0
# Agno AI Framework
agno>=1.0.0
+# Ollama client — required by agno.models.ollama.Ollama and the Ollama embedder.
+# Without it, selecting the Ollama provider for an agent raises
+# ImportError("`ollama` not installed") at model-init time.
+ollama>=0.4.0
+
# Agno Tool Dependencies (free tools - no API keys required)
ddgs>=6.0.0
wikipedia>=1.4.0
diff --git a/fincept-qt/scripts/agents/finagent_core/agent_factory.py b/fincept-qt/scripts/agents/finagent_core/agent_factory.py
index adde42474..140c3fa25 100644
--- a/fincept-qt/scripts/agents/finagent_core/agent_factory.py
+++ b/fincept-qt/scripts/agents/finagent_core/agent_factory.py
@@ -108,7 +108,10 @@ class AgentFactory:
# Any provider configured with a custom base_url (e.g. minimax served
# on an Anthropic-compatible endpoint, OpenRouter, LM Studio, etc.)
# is routed through OpenAIChat with that base_url.
- if base_url:
+ # Ollama is excluded: it has a native agno class that takes `host` (not
+ # base_url), and routing it here would hit /chat/completions instead of
+ # Ollama's /v1/chat/completions endpoint. It's handled in its own branch.
+ if base_url and provider != "ollama":
from agno.models.openai import OpenAIChat
# Override Agno's default role_map which maps "system"→"developer".
# Custom endpoints (MiniMax, OpenRouter, etc.) expect standard roles.
@@ -164,7 +167,21 @@ class AgentFactory:
if provider == "ollama":
from agno.models.ollama import Ollama
- return Ollama(id=model_id, temperature=temperature, num_predict=max_tokens)
+ # Ollama's constructor uses `host` (not base_url) and takes sampling
+ # params via an `options` dict — num_predict is its max-tokens key.
+ # Passing temperature/max_tokens/base_url directly raises
+ # "Ollama.__init__() got an unexpected keyword argument ...".
+ options = {}
+ if temperature is not None:
+ options["temperature"] = temperature
+ if max_tokens is not None:
+ options["num_predict"] = max_tokens
+ ol_kwargs = {"id": model_id}
+ if base_url:
+ ol_kwargs["host"] = base_url
+ if options:
+ ol_kwargs["options"] = options
+ return Ollama(**ol_kwargs)
if provider in ("openrouter",):
from agno.models.openai import OpenAIChat
diff --git a/fincept-qt/scripts/agents/finagent_core/registries/models_registry.py b/fincept-qt/scripts/agents/finagent_core/registries/models_registry.py
index 64b6b774f..f0fc20f2f 100644
--- a/fincept-qt/scripts/agents/finagent_core/registries/models_registry.py
+++ b/fincept-qt/scripts/agents/finagent_core/registries/models_registry.py
@@ -378,6 +378,11 @@ class ModelsRegistry:
"internlm", "dashscope", "siliconflow",
}
+ # Providers whose SDK constructor names the endpoint `host` rather than
+ # `base_url`. agno.models.ollama.Ollama takes host=... — passing base_url
+ # raises "Ollama.__init__() got an unexpected keyword argument 'base_url'".
+ HOST_NOT_BASE_URL_PROVIDERS = {"ollama"}
+
# Always pop base_url from kwargs so it never leaks via catch-all
kwarg_base_url = kwargs.pop("base_url", None)
@@ -435,23 +440,43 @@ class ModelsRegistry:
if provider_lower not in NO_BASE_URL_PROVIDERS:
if effective_base_url:
- model_kwargs["base_url"] = effective_base_url
+ if provider_lower in HOST_NOT_BASE_URL_PROVIDERS:
+ model_kwargs["host"] = effective_base_url
+ else:
+ model_kwargs["base_url"] = effective_base_url
# Add optional parameters with provider-specific name mapping
# Google Gemini uses max_output_tokens instead of max_tokens
USES_MAX_OUTPUT_TOKENS = {"google", "vertexai"}
- if "temperature" in kwargs:
- model_kwargs["temperature"] = kwargs.pop("temperature")
- if "max_tokens" in kwargs:
- max_tok = kwargs.pop("max_tokens")
+ if provider_lower in HOST_NOT_BASE_URL_PROVIDERS:
+ # Ollama's constructor has no temperature/max_tokens fields — sampling
+ # params ride in an `options` dict (num_predict is its max-tokens key).
+ # Passing them top-level raises "unexpected keyword argument 'temperature'".
+ ollama_options = dict(model_kwargs.pop("options", {}) or {})
+ temp = kwargs.pop("temperature", None)
+ if temp is not None:
+ ollama_options["temperature"] = temp
+ max_tok = kwargs.pop("max_tokens", None)
if max_tok is not None:
- if provider_lower in USES_MAX_OUTPUT_TOKENS:
- model_kwargs["max_output_tokens"] = max_tok
- else:
- model_kwargs["max_tokens"] = max_tok
- if "max_completion_tokens" in kwargs:
- model_kwargs["max_completion_tokens"] = kwargs.pop("max_completion_tokens")
+ ollama_options["num_predict"] = max_tok
+ max_ctok = kwargs.pop("max_completion_tokens", None)
+ if max_ctok is not None:
+ ollama_options.setdefault("num_predict", max_ctok)
+ if ollama_options:
+ model_kwargs["options"] = ollama_options
+ else:
+ if "temperature" in kwargs:
+ model_kwargs["temperature"] = kwargs.pop("temperature")
+ if "max_tokens" in kwargs:
+ max_tok = kwargs.pop("max_tokens")
+ if max_tok is not None:
+ if provider_lower in USES_MAX_OUTPUT_TOKENS:
+ model_kwargs["max_output_tokens"] = max_tok
+ else:
+ model_kwargs["max_tokens"] = max_tok
+ if "max_completion_tokens" in kwargs:
+ model_kwargs["max_completion_tokens"] = kwargs.pop("max_completion_tokens")
# Add remaining kwargs (filter out None values)
for k, v in kwargs.items():
diff --git a/fincept-qt/scripts/agents/hedgeFundAgents/renaissance_technologies_hedge_fund_agent/models/model_factory.py b/fincept-qt/scripts/agents/hedgeFundAgents/renaissance_technologies_hedge_fund_agent/models/model_factory.py
index 3ac6a528e..d5bdec8a7 100644
--- a/fincept-qt/scripts/agents/hedgeFundAgents/renaissance_technologies_hedge_fund_agent/models/model_factory.py
+++ b/fincept-qt/scripts/agents/hedgeFundAgents/renaissance_technologies_hedge_fund_agent/models/model_factory.py
@@ -164,9 +164,11 @@ def create_ollama_model(config: ModelConfig) -> Any:
try:
from agno.models.ollama import Ollama
+ # Ollama takes sampling params via an `options` dict — passing
+ # temperature directly raises "unexpected keyword argument 'temperature'".
return Ollama(
id=config.model_id,
- temperature=config.temperature,
+ options={"temperature": config.temperature},
)
except ImportError:
return {
diff --git a/fincept-qt/scripts/agents/hedgeFundAgents/renaissance_technologies_hedge_fund_agent/utils/model_factory.py b/fincept-qt/scripts/agents/hedgeFundAgents/renaissance_technologies_hedge_fund_agent/utils/model_factory.py
index 6912360e5..757ba763e 100644
--- a/fincept-qt/scripts/agents/hedgeFundAgents/renaissance_technologies_hedge_fund_agent/utils/model_factory.py
+++ b/fincept-qt/scripts/agents/hedgeFundAgents/renaissance_technologies_hedge_fund_agent/utils/model_factory.py
@@ -249,11 +249,16 @@ class ModelFactory:
"""Create Ollama local model"""
from agno.models.ollama import Ollama
+ # Ollama uses `host` (not base_url) and takes sampling params via an
+ # `options` dict (num_predict is its max-tokens key) — passing
+ # temperature/max_tokens directly raises "unexpected keyword argument".
return Ollama(
id=config.model_id,
host=config.base_url or self.PROVIDER_BASE_URLS["ollama"],
- temperature=config.temperature,
- max_tokens=config.max_tokens
+ options={
+ "temperature": config.temperature,
+ "num_predict": config.max_tokens,
+ },
)
def _create_openai_like_model(self, config: ModelConfig):