You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I follow the Python API Reference but does not work. What should be the correct way to do so.
My Code:
from ragflow_sdk import RAGFlow
api = "<my api key>"
url = "http://<my ip>:9222"
rag_object = RAGFlow(api_key=api, base_url=url)
from ragflow_sdk import Agent
AGENT_ID = "4f1464d0b6ba11efb3570242ac120006"
session = Agent.create_session(AGENT_ID,rag_object)
while True:
question = input("\n===== User ====\n> ")
if question.lower() == "end":
break
print("\n==== Miss R ====\n")
cont = ""
for ans in session.ask(question, stream=True):
print(ans.content[len(cont):], end='', flush=True)
cont = ans.content
Error:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In[11], line 8
5 print("\n==== Miss R ====\n")
7 cont = ""
----> 8 for ans in session.ask(question, stream=True):
9 print(ans.content[len(cont):], end='', flush=True)
10 cont = ans.content
File [~/environments/my_env/lib/python3.12/site-packages/ragflow_sdk/modules/session.py:34](http://<my ip>:9956/lab/tree/my_env/lib/python3.12/site-packages/ragflow_sdk/modules/session.py#line=33), in Session.ask(self, question, stream)
32 if json_data["data"] != True:
33 answer = json_data["data"]["answer"]
---> 34 reference = json_data["data"]["reference"]
35 temp_dict = {
36 "content": answer,
37 "role": "assistant"
38 }
39 if "chunks" in reference:
KeyError: 'reference'
The text was updated successfully, but these errors were encountered:
val-life
changed the title
[Question]: Converse with agent with Python api.
[Question]: Correct way to converse with agent with Python api
Dec 20, 2024
Describe your problem
I follow the Python API Reference but does not work. What should be the correct way to do so.
My Code:
Error:
The text was updated successfully, but these errors were encountered: