From 8abe0c00c371255b2734db9a8f82d762d1a228f1 Mon Sep 17 00:00:00 2001 From: userpj Date: Mon, 22 Jul 2024 09:46:35 +0800 Subject: [PATCH] update --- .../core/console/knowledge_base/data_class.py | 4 +-- appbuilder/tests/test_knowledge_base.py | 30 +++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/appbuilder/core/console/knowledge_base/data_class.py b/appbuilder/core/console/knowledge_base/data_class.py index 759cdef96..0917cda36 100644 --- a/appbuilder/core/console/knowledge_base/data_class.py +++ b/appbuilder/core/console/knowledge_base/data_class.py @@ -76,8 +76,8 @@ class KnowledgeBaseGetDocumentsListRequest(BaseModel): class DocumentMeta(BaseModel): - source: str = Field("", description="文档来源") - file_id: str = Field("", description="文档对应的文件ID") + source: str = Field(None, description="文档来源") + file_id: str = Field(None, description="文档对应的文件ID") class Document(BaseModel): diff --git a/appbuilder/tests/test_knowledge_base.py b/appbuilder/tests/test_knowledge_base.py index 9f896a14f..e34a77205 100644 --- a/appbuilder/tests/test_knowledge_base.py +++ b/appbuilder/tests/test_knowledge_base.py @@ -104,19 +104,25 @@ def test_create_knowledge_base(self): ), ) - list_res = knowledge.get_documents_list() - document_id = list_res.data[-1].id - res = knowledge.describe_chunks(document_id) - knowledge.describe_chunk(res.data[0].id) - resp = knowledge.create_chunk(document_id, content="test") - chunk_id = resp.id - knowledge.modify_chunk(chunk_id, content="new test", enable=True) - knowledge.delete_chunk(chunk_id) + try: + list_res = knowledge.get_documents_list() + document_id = list_res.data[-1].id + res = knowledge.describe_chunks(document_id) + knowledge.describe_chunk(res.data[0].id) + resp = knowledge.create_chunk(document_id, content="test") + chunk_id = resp.id + knowledge.modify_chunk(chunk_id, content="new test", enable=True) + knowledge.delete_chunk(chunk_id) + + knowledge.modify_knowledge_base( + knowledge_base_id=knowledge_base_id, name="test" + ) + knowledge.delete_knowledge_base(knowledge_base_id) + except Exception as e: + print("错误为 {}".format(e)) + finally: + knowledge.delete_knowledge_base(knowledge_base_id) - knowledge.modify_knowledge_base( - knowledge_base_id=knowledge_base_id, name="test" - ) - knowledge.delete_knowledge_base(knowledge_base_id) self.assertIsNotNone(knowledge_base_id)