Spaces:
Running
Running
Commit Β·
8005d62
1
Parent(s): b21d706
fix(llm): update OpenRouter model chain to currently-available free models
Browse filesAll 5 previously configured free-tier models (stepfun/step-3.5-flash,
z-ai/glm-4.5-air, arcee-ai/trinity-*, nvidia/nemotron-3-nano-30b-a3b,
meta-llama/llama-3.3-70b-instruct) returned 404 β no longer on the
free tier, silently breaking the analyst/structured-output pipeline.
New chain (verified live via OpenRouter API 2026-09):
- nvidia/nemotron-3.5-lightning:free (primary, clean tool-calling)
- nvidia/nemotron-3-super-120b-a12b:free
- dots-studio/dots-3-note-preview:free
- inclusionai/ling-3.0-flash-sante:free
- openrouter/free (resilient router catch-all)
STRUCTURED_MODEL -> nemotron-3.5-lightning:free (reliable
finish_reason=tool_calls for InvestmentVerdict structured output).
Updated debate defaults, EVAL_MODEL, model benchmark list, and docs.
- LANGSMITH_GUIDE.md +3 -3
- README.md +4 -4
- TEAM_GUIDE.md +5 -6
- scripts/evaluators.py +2 -2
- src/agents/debate.py +2 -2
- src/llm.py +13 -12
- test_models.py +5 -5
LANGSMITH_GUIDE.md
CHANGED
|
@@ -44,7 +44,7 @@ Test prompts interactively against different models and inputs.
|
|
| 44 |
3. Configure OpenRouter:
|
| 45 |
- **Base URL:** `https://openrouter.ai/api/v1`
|
| 46 |
- **API Key:** your `OPENROUTER_API_KEY`
|
| 47 |
-
- **Model:** e.g. `
|
| 48 |
4. Fill in template variables (`ticker`, `price`, `eps`, etc.)
|
| 49 |
5. Click **Run** to test
|
| 50 |
|
|
@@ -79,8 +79,8 @@ Find specific model failures or fallback events.
|
|
| 79 |
1. Go to `Tracing` β `primogreedy`
|
| 80 |
2. Click `+ Add filter` β `Tags`
|
| 81 |
3. Examples:
|
| 82 |
-
- `model:
|
| 83 |
-
- `model:nvidia/nemotron-3-
|
| 84 |
- Filter by `Error` column to find 429 rate limits
|
| 85 |
|
| 86 |
---
|
|
|
|
| 44 |
3. Configure OpenRouter:
|
| 45 |
- **Base URL:** `https://openrouter.ai/api/v1`
|
| 46 |
- **API Key:** your `OPENROUTER_API_KEY`
|
| 47 |
+
- **Model:** e.g. `nvidia/nemotron-3.5-lightning:free`
|
| 48 |
4. Fill in template variables (`ticker`, `price`, `eps`, etc.)
|
| 49 |
5. Click **Run** to test
|
| 50 |
|
|
|
|
| 79 |
1. Go to `Tracing` β `primogreedy`
|
| 80 |
2. Click `+ Add filter` β `Tags`
|
| 81 |
3. Examples:
|
| 82 |
+
- `model:nvidia/nemotron-3.5-lightning:free` β primary model calls
|
| 83 |
+
- `model:nvidia/nemotron-3-super-120b-a12b:free` β fallback model calls
|
| 84 |
- Filter by `Error` column to find 429 rate limits
|
| 85 |
|
| 86 |
---
|
README.md
CHANGED
|
@@ -33,7 +33,7 @@ START --> initial_routing --> [chat] --> END
|
|
| 33 |
- Zombie Filter: rejects unprofitable companies with < 6 months cash runway
|
| 34 |
- Routes directly to `analyst` (PASS / retries exhausted) or back to `scout` (FAIL) via `Command`.
|
| 35 |
3. **Analyst Node** β Two modes controlled by `USE_DEBATE` env var:
|
| 36 |
-
- **Single-LLM** (default): Senior Broker analysis via OpenRouter (
|
| 37 |
- **Multi-Agent Debate** (`USE_DEBATE=true`): Three-agent Investment Committee subgraph (Pitcher β Skeptic β Judge) that produces a hallucination-resistant verdict.
|
| 38 |
|
| 39 |
Both modes fetch **SEC EDGAR** 10-K/10-Q filings (US equities), call Finnhub tools for deep fundamentals, and compute **Kelly Criterion position sizing**.
|
|
@@ -51,7 +51,7 @@ A linear 4-node pipeline for deep single-ticker analysis (used by `main.py` CLI)
|
|
| 51 |
When `USE_DEBATE=true`, the analyst node runs a 3-agent LangGraph subgraph:
|
| 52 |
|
| 53 |
```
|
| 54 |
-
START --> [pitcher (
|
| 55 |
```
|
| 56 |
|
| 57 |
1. **The Pitcher** β Writes the strongest bullish thesis using only provided data.
|
|
@@ -196,7 +196,7 @@ pip install -r requirements.txt
|
|
| 196 |
|
| 197 |
### 2. Configuration (`.env`)
|
| 198 |
```env
|
| 199 |
-
OPENROUTER_API_KEY=your_key # LLM Inference (
|
| 200 |
FINNHUB_API_KEY=your_key # Deep Fundamentals & Insider Data
|
| 201 |
BRAVE_API_KEY=your_key # Web Search
|
| 202 |
RESEND_API_KEY_CISCO=your_key # Email Reporting (Cron only)
|
|
@@ -255,7 +255,7 @@ primogreedy/
|
|
| 255 |
βββ src/
|
| 256 |
β βββ agent.py # Interactive Chainlit pipeline (scout/gatekeeper/analyst)
|
| 257 |
β βββ whale_hunter.py # Daily cron pipeline + parallel Send orchestrator
|
| 258 |
-
β βββ llm.py # OpenRouter LLM with
|
| 259 |
β βββ sec_edgar.py # SEC EDGAR 10-K/10-Q filing fetcher + parser (@tool)
|
| 260 |
β βββ finance_tools.py # Finnhub tools (@tool decorated)
|
| 261 |
β βββ portfolio_tracker.py # Paper trade recording + Alpaca execution
|
|
|
|
| 33 |
- Zombie Filter: rejects unprofitable companies with < 6 months cash runway
|
| 34 |
- Routes directly to `analyst` (PASS / retries exhausted) or back to `scout` (FAIL) via `Command`.
|
| 35 |
3. **Analyst Node** β Two modes controlled by `USE_DEBATE` env var:
|
| 36 |
+
- **Single-LLM** (default): Senior Broker analysis via OpenRouter (5-model fallback chain) with structured `InvestmentVerdict` output.
|
| 37 |
- **Multi-Agent Debate** (`USE_DEBATE=true`): Three-agent Investment Committee subgraph (Pitcher β Skeptic β Judge) that produces a hallucination-resistant verdict.
|
| 38 |
|
| 39 |
Both modes fetch **SEC EDGAR** 10-K/10-Q filings (US equities), call Finnhub tools for deep fundamentals, and compute **Kelly Criterion position sizing**.
|
|
|
|
| 51 |
When `USE_DEBATE=true`, the analyst node runs a 3-agent LangGraph subgraph:
|
| 52 |
|
| 53 |
```
|
| 54 |
+
START --> [pitcher (Nemotron 3.5)] --> [skeptic (Nemotron Super)] --> [judge (Nemotron 3.5)] --> END
|
| 55 |
```
|
| 56 |
|
| 57 |
1. **The Pitcher** β Writes the strongest bullish thesis using only provided data.
|
|
|
|
| 196 |
|
| 197 |
### 2. Configuration (`.env`)
|
| 198 |
```env
|
| 199 |
+
OPENROUTER_API_KEY=your_key # LLM Inference (5-model fallback chain)
|
| 200 |
FINNHUB_API_KEY=your_key # Deep Fundamentals & Insider Data
|
| 201 |
BRAVE_API_KEY=your_key # Web Search
|
| 202 |
RESEND_API_KEY_CISCO=your_key # Email Reporting (Cron only)
|
|
|
|
| 255 |
βββ src/
|
| 256 |
β βββ agent.py # Interactive Chainlit pipeline (scout/gatekeeper/analyst)
|
| 257 |
β βββ whale_hunter.py # Daily cron pipeline + parallel Send orchestrator
|
| 258 |
+
β βββ llm.py # OpenRouter LLM with 5-model fallback + structured output
|
| 259 |
β βββ sec_edgar.py # SEC EDGAR 10-K/10-Q filing fetcher + parser (@tool)
|
| 260 |
β βββ finance_tools.py # Finnhub tools (@tool decorated)
|
| 261 |
β βββ portfolio_tracker.py # Paper trade recording + Alpaca execution
|
TEAM_GUIDE.md
CHANGED
|
@@ -152,12 +152,11 @@ All keys are stored as GitHub Secrets for the cron job and in `.env` for local d
|
|
| 152 |
|
| 153 |
The system uses free models via OpenRouter. If one model is rate-limited (429 error), it automatically tries the next:
|
| 154 |
|
| 155 |
-
1. `nvidia/nemotron-3-
|
| 156 |
-
2. `
|
| 157 |
-
3. `
|
| 158 |
-
4. `
|
| 159 |
-
5. `
|
| 160 |
-
6. `mistralai/mistral-small-3.1-24b-instruct`
|
| 161 |
|
| 162 |
---
|
| 163 |
|
|
|
|
| 152 |
|
| 153 |
The system uses free models via OpenRouter. If one model is rate-limited (429 error), it automatically tries the next:
|
| 154 |
|
| 155 |
+
1. `nvidia/nemotron-3.5-lightning` (primary β fast, reliable, tool-calling)
|
| 156 |
+
2. `nvidia/nemotron-3-super-120b-a12b`
|
| 157 |
+
3. `dots-studio/dots-3-note-preview`
|
| 158 |
+
4. `inclusionai/ling-3.0-flash-sante`
|
| 159 |
+
5. `openrouter/free` (router catch-all)
|
|
|
|
| 160 |
|
| 161 |
---
|
| 162 |
|
scripts/evaluators.py
CHANGED
|
@@ -65,7 +65,7 @@ def catalyst_grounding_score(run, example) -> dict:
|
|
| 65 |
from langchain_openai import ChatOpenAI
|
| 66 |
|
| 67 |
judge_llm = ChatOpenAI(
|
| 68 |
-
model=os.getenv("EVAL_MODEL", "nvidia/nemotron-3-
|
| 69 |
api_key=os.getenv("OPENROUTER_API_KEY"),
|
| 70 |
base_url="https://openrouter.ai/api/v1",
|
| 71 |
temperature=0,
|
|
@@ -121,7 +121,7 @@ def company_identity_score(run, example) -> dict:
|
|
| 121 |
import json
|
| 122 |
|
| 123 |
judge_llm = ChatOpenAI(
|
| 124 |
-
model=os.getenv("EVAL_MODEL", "nvidia/nemotron-3-
|
| 125 |
api_key=os.getenv("OPENROUTER_API_KEY"),
|
| 126 |
base_url="https://openrouter.ai/api/v1",
|
| 127 |
temperature=0,
|
|
|
|
| 65 |
from langchain_openai import ChatOpenAI
|
| 66 |
|
| 67 |
judge_llm = ChatOpenAI(
|
| 68 |
+
model=os.getenv("EVAL_MODEL", "nvidia/nemotron-3.5-lightning:free"),
|
| 69 |
api_key=os.getenv("OPENROUTER_API_KEY"),
|
| 70 |
base_url="https://openrouter.ai/api/v1",
|
| 71 |
temperature=0,
|
|
|
|
| 121 |
import json
|
| 122 |
|
| 123 |
judge_llm = ChatOpenAI(
|
| 124 |
+
model=os.getenv("EVAL_MODEL", "nvidia/nemotron-3.5-lightning:free"),
|
| 125 |
api_key=os.getenv("OPENROUTER_API_KEY"),
|
| 126 |
base_url="https://openrouter.ai/api/v1",
|
| 127 |
temperature=0,
|
src/agents/debate.py
CHANGED
|
@@ -23,8 +23,8 @@ from src.llm import MODEL_CHAIN
|
|
| 23 |
|
| 24 |
logger = get_logger(__name__)
|
| 25 |
|
| 26 |
-
PITCHER_MODEL = os.getenv("DEBATE_PITCHER_MODEL", "
|
| 27 |
-
SKEPTIC_MODEL = os.getenv("DEBATE_SKEPTIC_MODEL", "
|
| 28 |
JUDGE_MODEL = os.getenv("DEBATE_JUDGE_MODEL", MODEL_CHAIN[0])
|
| 29 |
|
| 30 |
# Free-tier rate limits: 8 req/min per model.
|
|
|
|
| 23 |
|
| 24 |
logger = get_logger(__name__)
|
| 25 |
|
| 26 |
+
PITCHER_MODEL = os.getenv("DEBATE_PITCHER_MODEL", "nvidia/nemotron-3.5-lightning:free")
|
| 27 |
+
SKEPTIC_MODEL = os.getenv("DEBATE_SKEPTIC_MODEL", "nvidia/nemotron-3-super-120b-a12b:free")
|
| 28 |
JUDGE_MODEL = os.getenv("DEBATE_JUDGE_MODEL", MODEL_CHAIN[0])
|
| 29 |
|
| 30 |
# Free-tier rate limits: 8 req/min per model.
|
src/llm.py
CHANGED
|
@@ -8,21 +8,22 @@ load_dotenv()
|
|
| 8 |
|
| 9 |
_llm_instance = None
|
| 10 |
|
| 11 |
-
# Ordered by preference: quality + reliability + speed
|
| 12 |
-
#
|
| 13 |
-
#
|
| 14 |
-
#
|
| 15 |
MODEL_CHAIN = [
|
| 16 |
-
"
|
| 17 |
-
"
|
| 18 |
-
"
|
| 19 |
-
"
|
| 20 |
-
"
|
| 21 |
]
|
| 22 |
|
| 23 |
-
# Best model for structured (JSON) output
|
| 24 |
-
#
|
| 25 |
-
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
def get_llm() -> ChatOpenAI:
|
|
|
|
| 8 |
|
| 9 |
_llm_instance = None
|
| 10 |
|
| 11 |
+
# Ordered by preference: quality + reliability + speed.
|
| 12 |
+
# All entries verified available on the OpenRouter free tier (checked 2026-09).
|
| 13 |
+
# `openrouter/free` is the router catch-all, so even if the specific free
|
| 14 |
+
# models above get de-listed or rate-limited, the chain can still complete.
|
| 15 |
MODEL_CHAIN = [
|
| 16 |
+
"nvidia/nemotron-3.5-lightning:free",
|
| 17 |
+
"nvidia/nemotron-3-super-120b-a12b:free",
|
| 18 |
+
"dots-studio/dots-3-note-preview:free",
|
| 19 |
+
"inclusionai/ling-3.0-flash-sante:free",
|
| 20 |
+
"openrouter/free",
|
| 21 |
]
|
| 22 |
|
| 23 |
+
# Best model for structured (JSON) output. Nemotron 3.5 Lightning handles
|
| 24 |
+
# function/tool calls cleanly (finish_reason=tool_calls), which is what
|
| 25 |
+
# `with_structured_output` relies on for valid InvestmentVerdict JSON.
|
| 26 |
+
STRUCTURED_MODEL = "nvidia/nemotron-3.5-lightning:free"
|
| 27 |
|
| 28 |
|
| 29 |
def get_llm() -> ChatOpenAI:
|
test_models.py
CHANGED
|
@@ -7,11 +7,11 @@ load_dotenv()
|
|
| 7 |
api_key = os.getenv("OPENROUTER_API_KEY")
|
| 8 |
|
| 9 |
models_to_test = [
|
| 10 |
-
"
|
| 11 |
-
"
|
| 12 |
-
"
|
| 13 |
-
"
|
| 14 |
-
"
|
| 15 |
]
|
| 16 |
|
| 17 |
prompt = "Extract a stock ticker from this text: Apple is launching new iPhones. I am buying AAPL calls tomorrow. Reply only with the ticker."
|
|
|
|
| 7 |
api_key = os.getenv("OPENROUTER_API_KEY")
|
| 8 |
|
| 9 |
models_to_test = [
|
| 10 |
+
"nvidia/nemotron-3.5-lightning:free",
|
| 11 |
+
"nvidia/nemotron-3-super-120b-a12b:free",
|
| 12 |
+
"dots-studio/dots-3-note-preview:free",
|
| 13 |
+
"inclusionai/ling-3.0-flash-sante:free",
|
| 14 |
+
"openrouter/free"
|
| 15 |
]
|
| 16 |
|
| 17 |
prompt = "Extract a stock ticker from this text: Apple is launching new iPhones. I am buying AAPL calls tomorrow. Reply only with the ticker."
|