This commit is contained in:
Henry Zhang 2025-10-20 15:01:51 +08:00 committed by GitHub
commit 6f74560fa0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 1 deletions

View File

@ -11,7 +11,13 @@ class FinancialSituationMemory:
self.embedding = "text-embedding-3-small"
self.client = OpenAI(base_url=config["backend_url"])
self.chroma_client = chromadb.Client(Settings(allow_reset=True))
self.situation_collection = self.chroma_client.create_collection(name=name)
# Try to get existing collection, create if it doesn't exist
try:
self.situation_collection = self.chroma_client.get_collection(name=name)
except Exception:
# Collection doesn't exist, create it
self.situation_collection = self.chroma_client.create_collection(name=name)
def get_embedding(self, text):
"""Get OpenAI embedding for a text"""