mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-25 16:26:51 +08:00
Change knowledge base to dataset (#11976)
### What problem does this PR solve? As title ### Type of change - [x] Refactoring --------- Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
@ -226,7 +226,7 @@ class TestChatAssistantCreate:
|
||||
assert res["data"]["prompt"]["show_quote"] is True
|
||||
assert (
|
||||
res["data"]["prompt"]["prompt"]
|
||||
== 'You are an intelligent assistant. Please summarize the content of the knowledge base to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence "The answer you are looking for is not found in the knowledge base!" Answers need to consider chat history.\n Here is the knowledge base:\n {knowledge}\n The above is the knowledge base.'
|
||||
== 'You are an intelligent assistant. Please summarize the content of the dataset to answer the question. Please list the data in the dataset and answer in detail. When all dataset content is irrelevant to the question, your answer must include the sentence "The answer you are looking for is not found in the dataset!" Answers need to consider chat history.\n Here is the knowledge base:\n {knowledge}\n The above is the knowledge base.'
|
||||
)
|
||||
else:
|
||||
assert res["message"] == expected_message
|
||||
|
||||
@ -223,7 +223,7 @@ class TestChatAssistantUpdate:
|
||||
assert res["data"]["prompt"][0]["show_quote"] is True
|
||||
assert (
|
||||
res["data"]["prompt"][0]["prompt"]
|
||||
== 'You are an intelligent assistant. Please summarize the content of the knowledge base to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence "The answer you are looking for is not found in the knowledge base!" Answers need to consider chat history.\n Here is the knowledge base:\n {knowledge}\n The above is the knowledge base.'
|
||||
== 'You are an intelligent assistant. Please summarize the content of the dataset to answer the question. Please list the data in the dataset and answer in detail. When all dataset content is irrelevant to the question, your answer must include the sentence "The answer you are looking for is not found in the dataset!" Answers need to consider chat history.\n Here is the knowledge base:\n {knowledge}\n The above is the knowledge base.'
|
||||
)
|
||||
else:
|
||||
assert expected_message in res["message"]
|
||||
|
||||
@ -211,7 +211,7 @@ class TestChatAssistantCreate:
|
||||
assert attrgetter("show_quote")(chat_assistant.prompt) is True
|
||||
assert (
|
||||
attrgetter("prompt")(chat_assistant.prompt)
|
||||
== 'You are an intelligent assistant. Please summarize the content of the knowledge base to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence "The answer you are looking for is not found in the knowledge base!" Answers need to consider chat history.\n Here is the knowledge base:\n {knowledge}\n The above is the knowledge base.'
|
||||
== 'You are an intelligent assistant. Please summarize the content of the dataset to answer the question. Please list the data in the dataset and answer in detail. When all dataset content is irrelevant to the question, your answer must include the sentence "The answer you are looking for is not found in the dataset!" Answers need to consider chat history.\n Here is the knowledge base:\n {knowledge}\n The above is the knowledge base.'
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -202,7 +202,7 @@ class TestChatAssistantUpdate:
|
||||
"empty_response": "Sorry! No relevant content was found in the knowledge base!",
|
||||
"opener": "Hi! I'm your assistant. What can I do for you?",
|
||||
"show_quote": True,
|
||||
"prompt": 'You are an intelligent assistant. Please summarize the content of the knowledge base to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence "The answer you are looking for is not found in the knowledge base!" Answers need to consider chat history.\n Here is the knowledge base:\n {knowledge}\n The above is the knowledge base.',
|
||||
"prompt": 'You are an intelligent assistant. Please summarize the content of the dataset to answer the question. Please list the data in the dataset and answer in detail. When all dataset content is irrelevant to the question, your answer must include the sentence "The answer you are looking for is not found in the dataset!" Answers need to consider chat history.\n Here is the knowledge base:\n {knowledge}\n The above is the knowledge base.',
|
||||
},
|
||||
)
|
||||
assert str(updated_chat.prompt) == str(excepted_value), str(updated_chat)
|
||||
|
||||
@ -21,7 +21,7 @@ from common import create_dialog, delete_dialog, get_dialog, update_dialog
|
||||
class TestDialogEdgeCases:
|
||||
@pytest.mark.p2
|
||||
def test_create_dialog_with_tavily_api_key(self, WebApiAuth):
|
||||
"""Test creating dialog with Tavily API key instead of knowledge base"""
|
||||
"""Test creating dialog with Tavily API key instead of dataset"""
|
||||
payload = {
|
||||
"name": "tavily_dialog",
|
||||
"prompt_config": {"system": "You are a helpful assistant. Use this knowledge: {knowledge}", "parameters": [{"key": "knowledge", "optional": True}], "tavily_api_key": "test_tavily_key"},
|
||||
|
||||
@ -60,7 +60,7 @@ class TestDocumentCreate:
|
||||
def test_invalid_kb_id(self, WebApiAuth):
|
||||
res = create_document(WebApiAuth, {"name": "ragflow_test.txt", "kb_id": "invalid_kb_id"})
|
||||
assert res["code"] == 102, res
|
||||
assert res["message"] == "Can't find this knowledgebase!", res
|
||||
assert res["message"] == "Can't find this dataset!", res
|
||||
|
||||
@pytest.mark.p3
|
||||
def test_filename_special_characters(self, WebApiAuth, add_dataset_func):
|
||||
|
||||
@ -51,7 +51,7 @@ class TestDocumentsList:
|
||||
"kb_id, expected_code, expected_message",
|
||||
[
|
||||
("", 101, 'Lack of "KB ID"'),
|
||||
("invalid_dataset_id", 103, "Only owner of knowledgebase authorized for this operation."),
|
||||
("invalid_dataset_id", 103, "Only owner of dataset authorized for this operation."),
|
||||
],
|
||||
)
|
||||
def test_invalid_dataset_id(self, WebApiAuth, kb_id, expected_code, expected_message):
|
||||
|
||||
@ -136,7 +136,7 @@ class TestDocumentsUpload:
|
||||
fp = create_txt_file(tmp_path / "ragflow_test.txt")
|
||||
res = upload_documents(WebApiAuth, {"kb_id": "invalid_kb_id"}, [fp])
|
||||
assert res["code"] == 100, res
|
||||
assert res["message"] == """LookupError("Can't find this knowledgebase!")""", res
|
||||
assert res["message"] == """LookupError("Can't find this dataset!")""", res
|
||||
|
||||
@pytest.mark.p2
|
||||
def test_duplicate_files(self, WebApiAuth, add_dataset_func, tmp_path):
|
||||
|
||||
@ -50,4 +50,4 @@ class TestDatasetsDetail:
|
||||
payload = {"kb_id": "d94a8dc02c9711f0930f7fbc369eab6d"}
|
||||
res = detail_kb(WebApiAuth, payload)
|
||||
assert res["code"] == 103, res
|
||||
assert "Only owner of knowledgebase authorized for this operation." in res["message"], res
|
||||
assert "Only owner of dataset authorized for this operation." in res["message"], res
|
||||
|
||||
@ -111,7 +111,7 @@ class TestDatasetUpdate:
|
||||
payload = {"name": name, "description": "", "parser_id": "naive", "kb_id": kb_id}
|
||||
res = update_kb(WebApiAuth, payload)
|
||||
assert res["code"] == 102, res
|
||||
assert res["message"] == "Duplicated knowledgebase name.", res
|
||||
assert res["message"] == "Duplicated dataset name.", res
|
||||
|
||||
@pytest.mark.p3
|
||||
def test_name_case_insensitive(self, WebApiAuth, add_datasets_func):
|
||||
@ -120,7 +120,7 @@ class TestDatasetUpdate:
|
||||
payload = {"name": name, "description": "", "parser_id": "naive", "kb_id": kb_id}
|
||||
res = update_kb(WebApiAuth, payload)
|
||||
assert res["code"] == 102, res
|
||||
assert res["message"] == "Duplicated knowledgebase name.", res
|
||||
assert res["message"] == "Duplicated dataset name.", res
|
||||
|
||||
@pytest.mark.p2
|
||||
def test_avatar(self, WebApiAuth, add_dataset_func, tmp_path):
|
||||
|
||||
Reference in New Issue
Block a user