update chroma chat

This commit is contained in:
ACBBZ
2024-05-07 06:24:35 +00:00
parent a6b2d6c3e7
commit 31dbe29b8b

View File

@ -4,6 +4,9 @@ from fastapi import Request, Response, status
from fastapi.responses import JSONResponse
from .blackbox import Blackbox
from ..utils import chroma_setting
DEFAULT_COLLECTION_ID = "123"
from injector import singleton
@singleton
class ChromaChat(Blackbox):
@ -19,13 +22,13 @@ class ChromaChat(Blackbox):
data = args[0]
return isinstance(data, list)
def processing(self, question, context) -> str:
def processing(self, question, setting: chroma_setting) -> str:
# load or create collection
if context is None:
collection_id = "123"
if setting is None:
collection_id = DEFAULT_COLLECTION_ID
else:
collection_id = context["collections"][0]
collection_id = setting.ChromaSetting.collection_ids[0]
# query it
chroma_result = self.chroma_query(question, collection_id)