Merge remote-tracking branch 'paikchu/dev' into test-merge

This commit is contained in:
zoubobo 2025-10-22 13:12:53 +08:00
commit 97fd6506dd
4 changed files with 32 additions and 8 deletions

View File

@ -151,6 +151,9 @@ def select_shallow_thinking_agent(provider) -> str:
],
"ollama": [
("llama3.2 local", "llama3.2"),
],
"deepseek": [
("DeepSeek V3 - a 685B-parameter, mixture-of-experts model", "deepseek-chat")
]
}
@ -212,6 +215,10 @@ def select_deep_thinking_agent(provider) -> str:
],
"ollama": [
("qwen3", "qwen3"),
],
"deepseek": [
("DeepSeek V3 - a 685B-parameter, mixture-of-experts model", "deepseek-chat"),
("DeepSeek-R1 - latest iteration of the flagship chat model family from the DeepSeek team.", "deepseek-reasoner"),
]
}
@ -245,7 +252,8 @@ def select_llm_provider() -> tuple[str, str]:
("Anthropic", "https://api.anthropic.com/"),
("Google", "https://generativelanguage.googleapis.com/v1"),
("Openrouter", "https://openrouter.ai/api/v1"),
("Ollama", "http://localhost:11434/v1"),
("Ollama", "http://localhost:11434/v1"),
("DeepSeek", "https://api.deepseek.com/v1")
]
choice = questionary.select(

View File

@ -22,3 +22,8 @@ redis
chainlit
rich
questionary
langchain_anthropic
langchain_deepseek
langchain_google_genai
openai
sentence-transformers

View File

@ -1,7 +1,9 @@
import os
import chromadb
from chromadb.config import Settings
from openai import OpenAI
from sentence_transformers import SentenceTransformer
class FinancialSituationMemory:
def __init__(self, name, config):
@ -9,17 +11,22 @@ class FinancialSituationMemory:
self.embedding = "nomic-embed-text"
else:
self.embedding = "text-embedding-3-small"
self.client = OpenAI()
self.chroma_client = chromadb.Client(Settings(allow_reset=True))
self.situation_collection = self.chroma_client.create_collection(name=name)
def get_embedding(self, text):
"""Get OpenAI embedding for a text"""
response = self.client.embeddings.create(
model=self.embedding, input=text
)
return response.data[0].embedding
if os.environ.get("OPENAI_API_KEY"):
client = OpenAI()
response = client.embeddings.create(
model=self.embedding, input=text
)
return response.data[0].embedding
else:
model = SentenceTransformer("all-MiniLM-L6-v2")
embeddings = model.encode(text, convert_to_numpy=True)
return embeddings
def add_situations(self, situations_and_advice):
"""Add financial situations and their corresponding advice. Parameter is a list of tuples (situation, rec)"""

View File

@ -6,6 +6,7 @@ import json
from datetime import date
from typing import Dict, Any, Tuple, List, Optional
from langchain_deepseek import ChatDeepSeek
from langchain_openai import ChatOpenAI
from langchain_anthropic import ChatAnthropic
from langchain_google_genai import ChatGoogleGenerativeAI
@ -67,6 +68,9 @@ class TradingAgentsGraph:
elif self.config["llm_provider"].lower() == "google":
self.deep_thinking_llm = ChatGoogleGenerativeAI(model=self.config["deep_think_llm"])
self.quick_thinking_llm = ChatGoogleGenerativeAI(model=self.config["quick_think_llm"])
elif self.config["llm_provider"].lower() == 'deepseek':
self.deep_thinking_llm = ChatDeepSeek(model=self.config["deep_think_llm"])
self.quick_thinking_llm = ChatDeepSeek(model=self.config["quick_think_llm"])
else:
raise ValueError(f"Unsupported LLM provider: {self.config['llm_provider']}")