Преглед изворни кода

Add top_k for create_chat and update_chat api (#4294)

### 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 <10215101452@stu.ecun.edu.cn>
tags/nightly
liuhua пре 10 месеци
родитељ
комит
b52b0f68fc
No account linked to committer's email address

+ 2
- 2
api/apps/sdk/chat.py Прегледај датотеку

"system": "prompt", "system": "prompt",
"rerank_id": "rerank_model", "rerank_id": "rerank_model",
"vector_similarity_weight": "keywords_similarity_weight"} "vector_similarity_weight": "keywords_similarity_weight"}
key_list = ["similarity_threshold", "vector_similarity_weight", "top_n", "rerank_id"]
key_list = ["similarity_threshold", "vector_similarity_weight", "top_n", "rerank_id","top_k"]
if prompt: if prompt:
for new_key, old_key in key_mapping.items(): for new_key, old_key in key_mapping.items():
if old_key in prompt: if old_key in prompt:
"system": "prompt", "system": "prompt",
"rerank_id": "rerank_model", "rerank_id": "rerank_model",
"vector_similarity_weight": "keywords_similarity_weight"} "vector_similarity_weight": "keywords_similarity_weight"}
key_list = ["similarity_threshold", "vector_similarity_weight", "top_n", "rerank_id"]
key_list = ["similarity_threshold", "vector_similarity_weight", "top_n", "rerank_id","top_k"]
if prompt: if prompt:
for new_key, old_key in key_mapping.items(): for new_key, old_key in key_mapping.items():
if old_key in prompt: if old_key in prompt:

+ 1
- 0
docs/references/http_api_reference.md Прегледај датотеку

- All the variables in 'System' should be curly bracketed. - All the variables in 'System' should be curly bracketed.
- The default value is `[{"key": "knowledge", "optional": true}]`. - The default value is `[{"key": "knowledge", "optional": true}]`.
- `"rerank_model"`: `string` If it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used. - `"rerank_model"`: `string` If it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used.
- `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.
- `"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. - `"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.
- `"opener"`: `string` The opening greeting for the user. Defaults to `"Hi! I am your assistant, can I help you?"`. - `"opener"`: `string` The opening greeting for the user. Defaults to `"Hi! I am your assistant, can I help you?"`.
- `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `true`. - `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `true`.

+ 1
- 0
docs/references/python_api_reference.md Прегледај датотеку

- All the variables in 'System' should be curly bracketed. - All the variables in 'System' should be curly bracketed.
- The default value is `[{"key": "knowledge", "optional": True}]`. - The default value is `[{"key": "knowledge", "optional": True}]`.
- `rerank_model`: `str` If it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used. Defaults to `""`. - `rerank_model`: `str` If it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used. Defaults to `""`.
- `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.
- `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`. - `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`.
- `opener`: `str` The opening greeting for the user. Defaults to `"Hi! I am your assistant, can I help you?"`. - `opener`: `str` The opening greeting for the user. Defaults to `"Hi! I am your assistant, can I help you?"`.
- `show_quote`: `bool` Indicates whether the source of text should be displayed. Defaults to `True`. - `show_quote`: `bool` Indicates whether the source of text should be displayed. Defaults to `True`.

+ 1
- 0
sdk/python/ragflow_sdk/modules/chat.py Прегледај датотеку

self.similarity_threshold = 0.2 self.similarity_threshold = 0.2
self.keywords_similarity_weight = 0.7 self.keywords_similarity_weight = 0.7
self.top_n = 8 self.top_n = 8
self.top_k = 1024
self.variables = [{"key": "knowledge", "optional": True}] self.variables = [{"key": "knowledge", "optional": True}]
self.rerank_model = None self.rerank_model = None
self.empty_response = None self.empty_response = None

+ 1
- 0
sdk/python/ragflow_sdk/ragflow.py Прегледај датотеку

prompt = Chat.Prompt(self, {"similarity_threshold": 0.2, prompt = Chat.Prompt(self, {"similarity_threshold": 0.2,
"keywords_similarity_weight": 0.7, "keywords_similarity_weight": 0.7,
"top_n": 8, "top_n": 8,
"top_k": 1024,
"variables": [{ "variables": [{
"key": "knowledge", "key": "knowledge",
"optional": True "optional": True

Loading…
Откажи
Сачувај