添加搜索节点
This commit is contained in:
41
nodes/parse_search.json
Normal file
41
nodes/parse_search.json
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"code": 1,
|
||||
"msg": "搜索完成",
|
||||
"data": [
|
||||
{
|
||||
"task_id": 12,
|
||||
"source_url": "https://example.com/wiki_5492",
|
||||
"title": "测试页面标题 - 切片1",
|
||||
"content": "这是模拟抓取到的第一段网页内容...",
|
||||
"chunk_index": 0
|
||||
},
|
||||
{
|
||||
"task_id": 12,
|
||||
"source_url": "https://example.com/wiki_5492",
|
||||
"title": "测试页面标题 - 切片2",
|
||||
"content": "这是模拟抓取到的第二段网页内容...",
|
||||
"chunk_index": 1
|
||||
},
|
||||
{
|
||||
"task_id": 13,
|
||||
"source_url": "https://example.com/wiki_6541/page1",
|
||||
"title": "测试页面标题 - 切片1",
|
||||
"content": "这是模拟抓取到的第一段网页内容...",
|
||||
"chunk_index": 0
|
||||
},
|
||||
{
|
||||
"task_id": 13,
|
||||
"source_url": "https://example.com/wiki_6541/page1",
|
||||
"title": "测试页面标题 - 切片2",
|
||||
"content": "这是模拟抓取到的第二段网页内容...",
|
||||
"chunk_index": 1
|
||||
},
|
||||
{
|
||||
"task_id": 14,
|
||||
"source_url": "https://example.com/wiki_9324/page1",
|
||||
"title": "测试页面标题 - 切片1",
|
||||
"content": "这是模拟抓取到的第一段网页内容...",
|
||||
"chunk_index": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
20
nodes/parse_search.py
Normal file
20
nodes/parse_search.py
Normal file
@@ -0,0 +1,20 @@
|
||||
def check_status(status_code: float, body: str):
|
||||
'''
|
||||
检查状态码和约定的返回值
|
||||
'''
|
||||
if status_code != 200:
|
||||
raise Exception(f"注册任务失败,状态码:{status_code}")
|
||||
if "code" not in body or body["code"] != 1:
|
||||
raise Exception(f"注册任务失败,返回值:{body}")
|
||||
|
||||
def main(status_code: float, body: str):
|
||||
try:
|
||||
check_status(status_code, body)
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
data = body["data"]
|
||||
|
||||
return {
|
||||
"RAG_results": data
|
||||
}
|
||||
Reference in New Issue
Block a user