Skip to content

Commit cfd400d

Browse files
authored
Revert "Refa: Chats /chat API to RESTFul (#13871)"
This reverts commit 1a608ac.
1 parent 1a608ac commit cfd400d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3553
-2013
lines changed

admin/client/ragflow_client.py

Lines changed: 81 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -977,13 +977,76 @@ def list_user_chats(self, command):
977977
def create_user_chat(self, command):
978978
if self.server_type != "user":
979979
print("This command is only allowed in USER mode")
980+
'''
981+
description
982+
:
983+
""
984+
icon
985+
:
986+
""
987+
language
988+
:
989+
"English"
990+
llm_id
991+
:
992+
"glm-4-flash@ZHIPU-AI"
993+
llm_setting
994+
:
995+
{}
996+
name
997+
:
998+
"xx"
999+
prompt_config
1000+
:
1001+
{empty_response: "", prologue: "Hi! I'm your assistant. What can I do for you?", quote: true,…}
1002+
empty_response
1003+
:
1004+
""
1005+
keyword
1006+
:
1007+
false
1008+
parameters
1009+
:
1010+
[{key: "knowledge", optional: false}]
1011+
prologue
1012+
:
1013+
"Hi! I'm your assistant. What can I do for you?"
1014+
quote
1015+
:
1016+
true
1017+
reasoning
1018+
:
1019+
false
1020+
refine_multiturn
1021+
:
1022+
false
1023+
system
1024+
:
1025+
"You are an intelligent assistant. Your primary function is to answer questions based strictly on the provided knowledge base.\n\n **Essential Rules:**\n - Your answer must be derived **solely** from this knowledge base: `{knowledge}`.\n - **When information is available**: Summarize the content to give a detailed answer.\n - **When information is unavailable**: Your response must contain this exact sentence: \"The answer you are looking for is not found in the knowledge base!\"\n - **Always consider** the entire conversation history."
1026+
toc_enhance
1027+
:
1028+
false
1029+
tts
1030+
:
1031+
false
1032+
use_kg
1033+
:
1034+
false
1035+
similarity_threshold
1036+
:
1037+
0.2
1038+
top_n
1039+
:
1040+
8
1041+
vector_similarity_weight
1042+
:
1043+
0.3
1044+
'''
9801045
chat_name = command["chat_name"]
981-
default_models = self._get_default_models() or {}
9821046
payload = {
983-
"name": chat_name,
9841047
"description": "",
9851048
"icon": "",
986-
"dataset_ids": [],
1049+
"language": "English",
9871050
"llm_setting": {},
9881051
"prompt_config": {
9891052
"empty_response": "",
@@ -1001,24 +1064,16 @@ def create_user_chat(self, command):
10011064
"optional": False
10021065
}
10031066
],
1004-
"toc_enhance": False,
1067+
"toc_enhance": False
10051068
},
10061069
"similarity_threshold": 0.2,
10071070
"top_n": 8,
1008-
"top_k": 1024,
1009-
"vector_similarity_weight": 0.3,
1010-
"rerank_id": default_models.get("rerank_id", ""),
1071+
"vector_similarity_weight": 0.3
10111072
}
1012-
if default_models.get("llm_id"):
1013-
payload["llm_id"] = default_models["llm_id"]
1014-
1015-
response = self.http_client.request(
1016-
"POST",
1017-
"/chats",
1018-
json_body=payload,
1019-
use_api_base=True,
1020-
auth_kind="web",
1021-
)
1073+
1074+
payload.update({"name": chat_name})
1075+
response = self.http_client.request("POST", "/dialog/set", json_body=payload, use_api_base=False,
1076+
auth_kind="web")
10221077
res_json = response.json()
10231078
if response.status_code == 200 and res_json["code"] == 0:
10241079
print(f"Success to create chat: {chat_name}")
@@ -1103,14 +1158,9 @@ def drop_user_chat(self, command):
11031158
for elem in res_json:
11041159
if elem["name"] == chat_name:
11051160
to_drop_chat_ids.append(elem["id"])
1106-
payload = {"ids": to_drop_chat_ids}
1107-
response = self.http_client.request(
1108-
"DELETE",
1109-
"/chats",
1110-
json_body=payload,
1111-
use_api_base=True,
1112-
auth_kind="web",
1113-
)
1161+
payload = {"dialog_ids": to_drop_chat_ids}
1162+
response = self.http_client.request("POST", "/dialog/rm", json_body=payload, use_api_base=False,
1163+
auth_kind="web")
11141164
res_json = response.json()
11151165
if response.status_code == 200 and res_json["code"] == 0:
11161166
print(f"Success to drop chat: {chat_name}")
@@ -1572,27 +1622,17 @@ def _get_dataset_id(self, dataset_name: str):
15721622
def _list_chats(self, command):
15731623
iterations = command.get("iterations", 1)
15741624
if iterations > 1:
1575-
response = self.http_client.request(
1576-
"GET",
1577-
"/chats",
1578-
use_api_base=True,
1579-
auth_kind="web",
1580-
iterations=iterations,
1581-
)
1625+
response = self.http_client.request("POST", "/dialog/next", use_api_base=False, auth_kind="web",
1626+
iterations=iterations)
15821627
return response
15831628
else:
1584-
response = self.http_client.request(
1585-
"GET",
1586-
"/chats",
1587-
use_api_base=True,
1588-
auth_kind="web",
1589-
iterations=iterations,
1590-
)
1629+
response = self.http_client.request("POST", "/dialog/next", use_api_base=False, auth_kind="web",
1630+
iterations=iterations)
15911631
res_json = response.json()
15921632
if response.status_code == 200 and res_json["code"] == 0:
1593-
return res_json["data"]["chats"]
1633+
return res_json["data"]["dialogs"]
15941634
else:
1595-
print(f"Fail to list chats, code: {res_json['code']}, message: {res_json['message']}")
1635+
print(f"Fail to list datasets, code: {res_json['code']}, message: {res_json['message']}")
15961636
return None
15971637

15981638
def _get_default_models(self):

0 commit comments

Comments
 (0)