Skip to content

Commit

Permalink
api param update
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiesun committed Nov 22, 2023
1 parent e8f5f11 commit 45c820d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
19 changes: 11 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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={
Expand All @@ -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")


Expand Down Expand Up @@ -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")
Expand Down
27 changes: 17 additions & 10 deletions tests/test.http
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 45c820d

Please sign in to comment.