liuhua liuhua Kevin Hu commited on
Commit
73a56f9
·
1 Parent(s): 71b8b06

Fix bugs in api (#3624)

Browse files

### What problem does this PR solve?

#3488

### Type of change

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

---------

Co-authored-by: liuhua <[email protected]>
Co-authored-by: Kevin Hu <[email protected]>

api/apps/sdk/chat.py CHANGED
@@ -111,7 +111,7 @@ def create(tenant_id):
111
  req['prompt_config'] = {}
112
  for key in key_list_2:
113
  temp = req['prompt_config'].get(key)
114
- if not temp:
115
  req['prompt_config'][key] = default_prompt[key]
116
  for p in req['prompt_config']["parameters"]:
117
  if p["optional"]:
 
111
  req['prompt_config'] = {}
112
  for key in key_list_2:
113
  temp = req['prompt_config'].get(key)
114
+ if (not temp and key == 'system') or (key not in req["prompt_config"]):
115
  req['prompt_config'][key] = default_prompt[key]
116
  for p in req['prompt_config']["parameters"]:
117
  if p["optional"]:
api/apps/sdk/session.py CHANGED
@@ -413,7 +413,7 @@ def list_session(chat_id,tenant_id):
413
  "document_id": chunk["doc_id"],
414
  "document_name": chunk["docnm_kwd"],
415
  "dataset_id": chunk["kb_id"],
416
- "image_id": chunk["img_id"],
417
  "similarity": chunk["similarity"],
418
  "vector_similarity": chunk["vector_similarity"],
419
  "term_similarity": chunk["term_similarity"],
 
413
  "document_id": chunk["doc_id"],
414
  "document_name": chunk["docnm_kwd"],
415
  "dataset_id": chunk["kb_id"],
416
+ "image_id": chunk["image_id"],
417
  "similarity": chunk["similarity"],
418
  "vector_similarity": chunk["vector_similarity"],
419
  "term_similarity": chunk["term_similarity"],
sdk/python/ragflow_sdk/modules/session.py CHANGED
@@ -17,11 +17,11 @@ class Session(Base):
17
  self.__session_type = "agent"
18
  super().__init__(rag, res_dict)
19
 
20
- def ask(self, question):
21
  if self.__session_type == "agent":
22
- res=self._ask_agent(question)
23
  elif self.__session_type == "chat":
24
- res=self._ask_chat(question)
25
  for line in res.iter_lines():
26
  line = line.decode("utf-8")
27
  if line.startswith("{"):
@@ -43,11 +43,11 @@ class Session(Base):
43
  yield message
44
 
45
 
46
- def _ask_chat(self, question: str, stream: bool = False):
47
  res = self.post(f"/chats/{self.chat_id}/completions",
48
  {"question": question, "stream": True,"session_id":self.id}, stream=stream)
49
  return res
50
- def _ask_agent(self,question:str,stream:bool=False):
51
  res = self.post(f"/agents/{self.agent_id}/completions",
52
  {"question": question, "stream": True,"session_id":self.id}, stream=stream)
53
  return res
 
17
  self.__session_type = "agent"
18
  super().__init__(rag, res_dict)
19
 
20
+ def ask(self, question,stream=True):
21
  if self.__session_type == "agent":
22
+ res=self._ask_agent(question,stream)
23
  elif self.__session_type == "chat":
24
+ res=self._ask_chat(question,stream)
25
  for line in res.iter_lines():
26
  line = line.decode("utf-8")
27
  if line.startswith("{"):
 
43
  yield message
44
 
45
 
46
+ def _ask_chat(self, question: str, stream: bool):
47
  res = self.post(f"/chats/{self.chat_id}/completions",
48
  {"question": question, "stream": True,"session_id":self.id}, stream=stream)
49
  return res
50
+ def _ask_agent(self,question:str,stream:bool):
51
  res = self.post(f"/agents/{self.agent_id}/completions",
52
  {"question": question, "stream": True,"session_id":self.id}, stream=stream)
53
  return res