Skip to content

Commit

Permalink
fix bugs in session api
Browse files Browse the repository at this point in the history
  • Loading branch information
liuhua committed Nov 25, 2024
1 parent 5713b25 commit 085c1ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion api/apps/sdk/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def list_session(chat_id,tenant_id):
"document_id": chunk["doc_id"],
"document_name": chunk["docnm_kwd"],
"dataset_id": chunk["kb_id"],
"image_id": chunk["img_id"],
"image_id": chunk["image_id"],
"similarity": chunk["similarity"],
"vector_similarity": chunk["vector_similarity"],
"term_similarity": chunk["term_similarity"],
Expand Down
10 changes: 5 additions & 5 deletions sdk/python/ragflow_sdk/modules/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ def __init__(self, rag, res_dict):
self.__session_type = "agent"
super().__init__(rag, res_dict)

def ask(self, question):
def ask(self, question,stream=True):
if self.__session_type == "agent":
res=self._ask_agent(question)
res=self._ask_agent(question,stream)
elif self.__session_type == "chat":
res=self._ask_chat(question)
res=self._ask_chat(question,stream)
for line in res.iter_lines():
line = line.decode("utf-8")
if line.startswith("{"):
Expand All @@ -43,11 +43,11 @@ def ask(self, question):
yield message


def _ask_chat(self, question: str, stream: bool = False):
def _ask_chat(self, question: str, stream: bool):
res = self.post(f"/chats/{self.chat_id}/completions",
{"question": question, "stream": True,"session_id":self.id}, stream=stream)
return res
def _ask_agent(self,question:str,stream:bool=False):
def _ask_agent(self,question:str,stream:bool):
res = self.post(f"/agents/{self.agent_id}/completions",
{"question": question, "stream": True,"session_id":self.id}, stream=stream)
return res
Expand Down

0 comments on commit 085c1ac

Please sign in to comment.