Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions python/third_party/TradingAgents/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ FINNHUB_API_KEY=your_finnhub_api_key_here
# because they don't support OpenAI's embeddings API
# If not set, the system will try to use OPENAI_API_KEY for embeddings
# Get your key from: https://platform.openai.com/api-keys
EMBEDDINGS_API_KEY=your_openai_embeddings_key_here
EMBEDDER_API_KEY=your_openai_embeddings_key_here
# Default embedding URL is OpenAI
EMBEDDINGS_BACKEND_URL=your_embedding_model_backend_url_here
EMBEDDER_BASE_URL=your_embedding_model_backend_url_here
# Default embedding model
EMBEDDINGS_MODEL=text-embedding-3-small
EMBEDDER_MODEL_ID=text-embedding-3-small


# =============================================================================
Expand Down Expand Up @@ -118,7 +118,7 @@ TRADINGAGENTS_ONLINE_TOOLS=true
# OpenRouter does not support OpenAI's embeddings API, which is required for
# the memory functionality in TradingAgents. You MUST set both:
# OPENAI_API_KEY=sk-or-v1-your-openrouter-key-here (for chat models)
# EMBEDDINGS_API_KEY=sk-your-real-openai-key-here (for embeddings)
# EMBEDDER_API_KEY=sk-your-real-openai-key-here (for embeddings)

# For Azure OpenAI
# TRADINGAGENTS_LLM_PROVIDER=azure
Expand All @@ -136,15 +136,15 @@ TRADINGAGENTS_ONLINE_TOOLS=true

# Solution 1 - Use dedicated OpenAI key for embeddings (RECOMMENDED):
# OPENAI_API_KEY=sk-or-v1-your-openrouter-key-here
# EMBEDDINGS_API_KEY=sk-your-real-openai-key-here
# EMBEDDER_API_KEY=sk-your-real-openai-key-here

# Solution 2 - Switch to Ollama for fully local processing:
# TRADINGAGENTS_LLM_PROVIDER=ollama
# TRADINGAGENTS_BACKEND_URL=http://localhost:11434/v1
# Then run: ollama pull llama3.1 && ollama pull nomic-embed-text

# Solution 3 - Accept limited memory functionality:
# If you don't set EMBEDDINGS_API_KEY, the system will use dummy
# If you don't set EMBEDDER_API_KEY, the system will use dummy
# embeddings and continue running, but memory features will be limited.

# Affected providers that need separate embeddings key:
Expand All @@ -162,6 +162,6 @@ TRADINGAGENTS_ONLINE_TOOLS=true
# 1. Copy this file to .env: cp .env.example .env
# 2. Fill in your actual API keys and configuration values
# 3. Make sure .env is in your .gitignore to keep your keys private
# 4. For OpenRouter users: Set both OPENAI_API_KEY and EMBEDDINGS_API_KEY
# 4. For OpenRouter users: Set both OPENAI_API_KEY and EMBEDDER_API_KEY
# 5. For Ollama users: Run 'ollama pull nomic-embed-text' for embeddings support
# 6. Run the application: python main.py or python -m cli.main
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

class FinancialSituationMemory:
def __init__(self, name, config):
self.embedding = config["embeddings_model"]
self.client = OpenAI(base_url=config["embeddings_backend_url"])
if "localhost" not in config["embeddings_backend_url"]:
embeddings_api_key = os.getenv("EMBEDDINGS_API_KEY") or os.getenv("OPENAI_API_KEY")
self.client = OpenAI(api_key=embeddings_api_key, base_url=config["embeddings_backend_url"])
self.embedding = config["EMBEDDER_MODEL_ID"]
self.client = OpenAI(base_url=config["EMBEDDER_BASE_URL"])
if "localhost" not in config["EMBEDDER_BASE_URL"]:
EMBEDDER_API_KEY = os.getenv("EMBEDDER_API_KEY") or os.getenv("OPENAI_API_KEY")
self.client = OpenAI(api_key=EMBEDDER_API_KEY, base_url=config["EMBEDDER_BASE_URL"])

self.chroma_client = chromadb.Client(Settings(allow_reset=True))
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def str_to_bool(value):
"quick_think_llm": os.getenv("TRADINGAGENTS_QUICK_THINK_LLM", "gpt-4o-mini"),
"backend_url": os.getenv("TRADINGAGENTS_BACKEND_URL", "https://api.openai.com/v1"),
# Embeddings settings
"embeddings_backend_url": os.getenv("EMBEDDINGS_BACKEND_URL", "https://api.openai.com/v1"),
"embeddings_model": os.getenv("EMBEDDINGS_MODEL", "text-embedding-3-small"),
"EMBEDDER_BASE_URL": os.getenv("EMBEDDER_BASE_URL", "https://api.openai.com/v1"),
"EMBEDDER_MODEL_ID": os.getenv("EMBEDDER_MODEL_ID", "text-embedding-3-small"),
# Debate and discussion settings
"max_debate_rounds": int(os.getenv("TRADINGAGENTS_MAX_DEBATE_ROUNDS", "1")),
"max_risk_discuss_rounds": int(os.getenv("TRADINGAGENTS_MAX_RISK_DISCUSS_ROUNDS", "1")),
Expand Down