ソースを参照

Fix bugs in api (#3624)

### What problem does this PR solve?

#3488

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

---------

Co-authored-by: liuhua <10215101452@stu.ecun.edu.cn>
Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
tags/v0.14.0
liuhua 11ヶ月前
コミット
86e48179a1
コミッターのメールアドレスに関連付けられたアカウントが存在しません
3個のファイルの変更7行の追加7行の削除
  1. 1
    1
      api/apps/sdk/chat.py
  2. 1
    1
      api/apps/sdk/session.py
  3. 5
    5
      sdk/python/ragflow_sdk/modules/session.py

+ 1
- 1
api/apps/sdk/chat.py ファイルの表示

@@ -111,7 +111,7 @@ def create(tenant_id):
req['prompt_config'] = {}
for key in key_list_2:
temp = req['prompt_config'].get(key)
if not temp:
if (not temp and key == 'system') or (key not in req["prompt_config"]):
req['prompt_config'][key] = default_prompt[key]
for p in req['prompt_config']["parameters"]:
if p["optional"]:

+ 1
- 1
api/apps/sdk/session.py ファイルの表示

@@ -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"],

+ 5
- 5
sdk/python/ragflow_sdk/modules/session.py ファイルの表示

@@ -17,11 +17,11 @@ class Session(Base):
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("{"):
@@ -43,11 +43,11 @@ class Session(Base):
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

読み込み中…
キャンセル
保存