mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-19 03:58:30 +02:00
API support for Chat to have citations (#569)
This commit is contained in:
@@ -37,15 +37,24 @@ def send_chat_message(
|
||||
"persona_id": persona_id,
|
||||
}
|
||||
|
||||
docs: list[dict] | None = None
|
||||
with requests.post(
|
||||
LOCAL_CHAT_ENDPOINT + "send-message", json=data, stream=True
|
||||
) as r:
|
||||
for json_response in r.iter_lines():
|
||||
response_text = json.loads(json_response.decode())
|
||||
new_token = response_text.get("answer_piece")
|
||||
print(new_token, end="", flush=True)
|
||||
if docs is None:
|
||||
docs = response_text.get("top_documents")
|
||||
if new_token:
|
||||
print(new_token, end="", flush=True)
|
||||
print()
|
||||
|
||||
if docs:
|
||||
print("\nReference Docs:")
|
||||
for ind, doc in enumerate(docs, start=1):
|
||||
print(f"\t - Doc {ind}: {doc.get('semantic_identifier')}")
|
||||
|
||||
|
||||
def run_chat(contextual: bool) -> None:
|
||||
try:
|
||||
|
Reference in New Issue
Block a user