From de45b8822596f9d421757e4c00b3db5d84fc46a6 Mon Sep 17 00:00:00 2001 From: QingGang Date: Tue, 23 Dec 2025 01:07:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=90=9C=E7=B4=A2=E8=8A=82?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/launch.json | 15 +++++++++++++++ nodes/parse_search.json | 41 +++++++++++++++++++++++++++++++++++++++++ nodes/parse_search.py | 20 ++++++++++++++++++++ scripts/init_db.py | 8 ++++++++ 4 files changed, 84 insertions(+) create mode 100644 .vscode/launch.json create mode 100644 nodes/parse_search.json create mode 100644 nodes/parse_search.py diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..1b22d63 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "configurations": [ + { + "name": "Python Debugger: FastAPI", + "type": "debugpy", + "request": "launch", + "module": "uvicorn", + "args": [ + "backend.main:app", + "--reload" + ], + "jinja": true + } + ] +} \ No newline at end of file diff --git a/nodes/parse_search.json b/nodes/parse_search.json new file mode 100644 index 0000000..4f4ca5c --- /dev/null +++ b/nodes/parse_search.json @@ -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 + } + ] +} \ No newline at end of file diff --git a/nodes/parse_search.py b/nodes/parse_search.py new file mode 100644 index 0000000..d1d9dad --- /dev/null +++ b/nodes/parse_search.py @@ -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 + } diff --git a/scripts/init_db.py b/scripts/init_db.py index e69de29..5600bf4 100644 --- a/scripts/init_db.py +++ b/scripts/init_db.py @@ -0,0 +1,8 @@ +import random + +# 生成1536 8位随机向量 +def generate_random_vector(dim=1536): + return [round(random.uniform(-1, 1), 8) for _ in range(dim)] + +data = [generate_random_vector() for _ in range(1000)] +print(data[0])