Merge remote-tracking branch 'origin/chat_and_cache' into websocket
This commit is contained in:
commit
aa8a45bab6
2 changed files with 11 additions and 0 deletions
|
|
@ -120,10 +120,20 @@ class ChatManager:
|
||||||
raise e
|
raise e
|
||||||
# Send a response back to the frontend, if needed
|
# Send a response back to the frontend, if needed
|
||||||
intermediate_steps = intermediate_steps or ""
|
intermediate_steps = intermediate_steps or ""
|
||||||
|
history = self.chat_history.get_history(client_id, filter=False)
|
||||||
|
file_responses = []
|
||||||
|
if history:
|
||||||
|
for msg in history:
|
||||||
|
if isinstance(msg, FileResponse):
|
||||||
|
file_responses.append(msg)
|
||||||
|
if msg.type == "start":
|
||||||
|
break
|
||||||
|
|
||||||
response = ChatResponse(
|
response = ChatResponse(
|
||||||
message=result or "",
|
message=result or "",
|
||||||
intermediate_steps=intermediate_steps.strip(),
|
intermediate_steps=intermediate_steps.strip(),
|
||||||
type="end",
|
type="end",
|
||||||
|
files=file_responses,
|
||||||
)
|
)
|
||||||
self.chat_history.add_message(client_id, response)
|
self.chat_history.add_message(client_id, response)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ class ChatResponse(ChatMessage):
|
||||||
intermediate_steps: str
|
intermediate_steps: str
|
||||||
type: str
|
type: str
|
||||||
is_bot: bool = True
|
is_bot: bool = True
|
||||||
|
files: list = []
|
||||||
|
|
||||||
@validator("type")
|
@validator("type")
|
||||||
def validate_message_type(cls, v):
|
def validate_message_type(cls, v):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue