liuhua
liuhua
commited on
Commit
·
252d77a
1
Parent(s):
3a77303
Add top_k for create_chat and update_chat api (#4294)
Browse files### What problem does this PR solve?
Add top_k for create_chat and update_chat api #4157
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
---------
Co-authored-by: liuhua <[email protected]>
api/apps/sdk/chat.py
CHANGED
@@ -65,7 +65,7 @@ def create(tenant_id):
|
|
65 |
"system": "prompt",
|
66 |
"rerank_id": "rerank_model",
|
67 |
"vector_similarity_weight": "keywords_similarity_weight"}
|
68 |
-
key_list = ["similarity_threshold", "vector_similarity_weight", "top_n", "rerank_id"]
|
69 |
if prompt:
|
70 |
for new_key, old_key in key_mapping.items():
|
71 |
if old_key in prompt:
|
@@ -200,7 +200,7 @@ def update(tenant_id, chat_id):
|
|
200 |
"system": "prompt",
|
201 |
"rerank_id": "rerank_model",
|
202 |
"vector_similarity_weight": "keywords_similarity_weight"}
|
203 |
-
key_list = ["similarity_threshold", "vector_similarity_weight", "top_n", "rerank_id"]
|
204 |
if prompt:
|
205 |
for new_key, old_key in key_mapping.items():
|
206 |
if old_key in prompt:
|
|
|
65 |
"system": "prompt",
|
66 |
"rerank_id": "rerank_model",
|
67 |
"vector_similarity_weight": "keywords_similarity_weight"}
|
68 |
+
key_list = ["similarity_threshold", "vector_similarity_weight", "top_n", "rerank_id","top_k"]
|
69 |
if prompt:
|
70 |
for new_key, old_key in key_mapping.items():
|
71 |
if old_key in prompt:
|
|
|
200 |
"system": "prompt",
|
201 |
"rerank_id": "rerank_model",
|
202 |
"vector_similarity_weight": "keywords_similarity_weight"}
|
203 |
+
key_list = ["similarity_threshold", "vector_similarity_weight", "top_n", "rerank_id","top_k"]
|
204 |
if prompt:
|
205 |
for new_key, old_key in key_mapping.items():
|
206 |
if old_key in prompt:
|
docs/references/http_api_reference.md
CHANGED
@@ -1389,6 +1389,7 @@ curl --request POST \
|
|
1389 |
- All the variables in 'System' should be curly bracketed.
|
1390 |
- The default value is `[{"key": "knowledge", "optional": true}]`.
|
1391 |
- `"rerank_model"`: `string` If it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used.
|
|
|
1392 |
- `"empty_response"`: `string` If nothing is retrieved in the dataset for the user's question, this will be used as the response. To allow the LLM to improvise when nothing is found, leave this blank.
|
1393 |
- `"opener"`: `string` The opening greeting for the user. Defaults to `"Hi! I am your assistant, can I help you?"`.
|
1394 |
- `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `true`.
|
|
|
1389 |
- All the variables in 'System' should be curly bracketed.
|
1390 |
- The default value is `[{"key": "knowledge", "optional": true}]`.
|
1391 |
- `"rerank_model"`: `string` If it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used.
|
1392 |
+
- `top_k`: `int` Refers to the process of reordering or selecting the top-k items from a list or set based on a specific ranking criterion. Default to 1024.
|
1393 |
- `"empty_response"`: `string` If nothing is retrieved in the dataset for the user's question, this will be used as the response. To allow the LLM to improvise when nothing is found, leave this blank.
|
1394 |
- `"opener"`: `string` The opening greeting for the user. Defaults to `"Hi! I am your assistant, can I help you?"`.
|
1395 |
- `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `true`.
|
docs/references/python_api_reference.md
CHANGED
@@ -965,6 +965,7 @@ Instructions for the LLM to follow. A `Prompt` object contains the following at
|
|
965 |
- All the variables in 'System' should be curly bracketed.
|
966 |
- The default value is `[{"key": "knowledge", "optional": True}]`.
|
967 |
- `rerank_model`: `str` If it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used. Defaults to `""`.
|
|
|
968 |
- `empty_response`: `str` If nothing is retrieved in the dataset for the user's question, this will be used as the response. To allow the LLM to improvise when nothing is found, leave this blank. Defaults to `None`.
|
969 |
- `opener`: `str` The opening greeting for the user. Defaults to `"Hi! I am your assistant, can I help you?"`.
|
970 |
- `show_quote`: `bool` Indicates whether the source of text should be displayed. Defaults to `True`.
|
|
|
965 |
- All the variables in 'System' should be curly bracketed.
|
966 |
- The default value is `[{"key": "knowledge", "optional": True}]`.
|
967 |
- `rerank_model`: `str` If it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used. Defaults to `""`.
|
968 |
+
- `top_k`: `int` Refers to the process of reordering or selecting the top-k items from a list or set based on a specific ranking criterion. Default to 1024.
|
969 |
- `empty_response`: `str` If nothing is retrieved in the dataset for the user's question, this will be used as the response. To allow the LLM to improvise when nothing is found, leave this blank. Defaults to `None`.
|
970 |
- `opener`: `str` The opening greeting for the user. Defaults to `"Hi! I am your assistant, can I help you?"`.
|
971 |
- `show_quote`: `bool` Indicates whether the source of text should be displayed. Defaults to `True`.
|
sdk/python/ragflow_sdk/modules/chat.py
CHANGED
@@ -28,6 +28,7 @@ class Chat(Base):
|
|
28 |
self.similarity_threshold = 0.2
|
29 |
self.keywords_similarity_weight = 0.7
|
30 |
self.top_n = 8
|
|
|
31 |
self.variables = [{"key": "knowledge", "optional": True}]
|
32 |
self.rerank_model = None
|
33 |
self.empty_response = None
|
|
|
28 |
self.similarity_threshold = 0.2
|
29 |
self.keywords_similarity_weight = 0.7
|
30 |
self.top_n = 8
|
31 |
+
self.top_k = 1024
|
32 |
self.variables = [{"key": "knowledge", "optional": True}]
|
33 |
self.rerank_model = None
|
34 |
self.empty_response = None
|
sdk/python/ragflow_sdk/ragflow.py
CHANGED
@@ -108,6 +108,7 @@ class RAGFlow:
|
|
108 |
prompt = Chat.Prompt(self, {"similarity_threshold": 0.2,
|
109 |
"keywords_similarity_weight": 0.7,
|
110 |
"top_n": 8,
|
|
|
111 |
"variables": [{
|
112 |
"key": "knowledge",
|
113 |
"optional": True
|
|
|
108 |
prompt = Chat.Prompt(self, {"similarity_threshold": 0.2,
|
109 |
"keywords_similarity_weight": 0.7,
|
110 |
"top_n": 8,
|
111 |
+
"top_k": 1024,
|
112 |
"variables": [{
|
113 |
"key": "knowledge",
|
114 |
"optional": True
|