main works, cli bugs

This commit is contained in:
Edward Sun
2025-06-15 22:20:59 -07:00
parent 90b23e72f5
commit da84ef43aa
11 changed files with 5577 additions and 50 deletions

View File

@@ -12,14 +12,22 @@ from dateutil.relativedelta import relativedelta
from langchain_openai import ChatOpenAI
import tradingagents.dataflows.interface as interface
from tradingagents.default_config import DEFAULT_CONFIG
from langchain_core.messages import HumanMessage
def create_msg_delete():
def delete_messages(state):
"""To prevent message history from overflowing, regularly clear message history after a stage of the pipeline is done"""
"""Clear messages and add placeholder for Anthropic compatibility"""
messages = state["messages"]
return {"messages": [RemoveMessage(id=m.id) for m in messages]}
# Remove all messages
removal_operations = [RemoveMessage(id=m.id) for m in messages]
# Add a minimal placeholder message
placeholder = HumanMessage(content="Continue analysis")
return {"messages": removal_operations + [placeholder]}
return delete_messages

View File

@@ -5,11 +5,11 @@ from openai import OpenAI
class FinancialSituationMemory:
def __init__(self, name, config):
if config["openai_backend"] == "http://localhost:11434/v1":
if config["backend_url"] == "http://localhost:11434/v1":
self.embedding = "nomic-embed-text"
else:
self.embedding = "text-embedding-ada-002"
self.client = OpenAI(base_url=config["openai_backend"])
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)