diff --git a/main.py b/main.py index b7e4192..d034e97 100644 --- a/main.py +++ b/main.py @@ -76,8 +76,8 @@ class TokenData(BaseModel): class IndexItem(BaseModel): - collection: str = Field("default", title="Collection name", description="Collection name") - texts: list = Field([], title="Textual content list", description="The stored text content list to be vectorized") + collection: str = Field(..., title="Collection name", description="Collection name") + texts: list = Field(..., title="Textual content list", description="The stored text content list to be vectorized") metadatas: list = Field([], title="Metadata list", description="Metadata list, structured data") type: str = Field("text", title="The type of text", description="Text type, text: text,webbase: web page, webpdf: web page pdf") @@ -91,9 +91,10 @@ class IndexItem(BaseModel): class MindmapItem(BaseModel): - title: str = Field(default="Mindmap", title="Mindmap Title as root node", description="Mindmap Title, Root node", + title: str = Field(..., title="Mindmap Title as root node,required", description="Mindmap Title, Root node", example="Python 学习") - structure: Dict[str, List[str]] = Field(default={}, title="Mindmap Structure data", + structure: Dict[str, List[str]] = Field(..., + title="Mindmap Structure data, required", description="Mindmap Structure data, " "The title value must be included in the structure's keys", example={ @@ -102,14 +103,16 @@ class MindmapItem(BaseModel): "高级主题": ["面向对象", "装饰器", "迭代器"] }) + class IndexSearchItem(BaseModel): - collection: str = Field("default", title="Collection name", + collection: str = Field(..., title="Collection name", description="The name of the knowledge base index store") - query: str = Field(title="Query content", description="Query the text content of the knowledge base index store") + query: str = Field(..., title="Query content", description="Query the text content of the knowledge base" + " index store") class IndexDeleteItem(BaseModel): - collection: str = Field("not_exist", title="Collection name", + collection: str = Field(..., title="Collection name, required", description="The name of the knowledge base index store") @@ -143,7 +146,7 @@ async def root(): return "ok" -@app.get("/assets/{filename}",include_in_schema=False) +@app.get("/assets/{filename}", include_in_schema=False) async def download_file(filename: str): if not re.match(r'^[\w,\s-]+\.[A-Za-z]{3}$', filename): raise HTTPException(status_code=400, detail="Invalid file name") diff --git a/tests/test.http b/tests/test.http index 11a340b..0fb1b18 100644 --- a/tests/test.http +++ b/tests/test.http @@ -44,22 +44,29 @@ Content-Type: application/json Authorization: Bearer a99e05501a0405531caf783eef419b56a5a32f57b64ae3b89587b3a0d5202ee167d80d727a1b8181 { - "title": "Python学习", + "title": "对数", "structure": { - "Python学习": ["基础知识", "高级主题"], - "基础知识": ["变量", "数据类型", "控制流"], - "高级主题": ["面向对象", "装饰器", "迭代器"], - "变量": ["定义", "赋值"], - "数据类型": ["整数", "浮点数", "字符串"], - "控制流": ["if语句", "for循环", "while循环"], - "面向对象": ["类", "继承", "多态"], - "装饰器": ["定义", "应用"], - "迭代器": ["创建", "使用"] + "对数": ["定义", "性质", "类型", "应用"], + "定义": ["对数的概念", "对数的表示"], + "性质": ["对数定律", "换底公式"], + "类型": ["常用对数", "自然对数"], + "应用": ["科学计算", "复利计算", "音乐理论", "信息熵"], + "对数的概念": ["对数与指数的关系"], + "对数的表示": ["底数", "真数"], + "对数定律": ["乘法定律", "除法定律", "幂的定律"], + "换底公式": ["公式描述"], + "常用对数": ["十进制", "应用举例"], + "自然对数": ["以e为底", "特性"], + "科学计算": ["对数尺", "数据压缩"], + "复利计算": ["金融领域应用"], + "音乐理论": ["音程与频率"], + "信息熵": ["信息论中的应用"] } } + ### POST http://127.0.0.1:8700/knowledge/search