数据导入schema分析功能接口和测试用例

This commit is contained in:
zhaoawd
2025-10-29 22:35:29 +08:00
parent 76b8c9d79b
commit f43590585b
5 changed files with 380 additions and 37 deletions

View File

@ -0,0 +1,42 @@
"""Minimal example for hitting the /v1/import/analyze endpoint with Excel data."""
from __future__ import annotations
import asyncio
from pathlib import Path
import httpx
import pandas as pd
API_URL = "http://localhost:8000/v1/import/analyze"
CALLBACK_URL = "http://localhost:8000/__mock__/import-callback"
EXCEL_PATH = Path(__file__).resolve().parents[1] / "file" / "全国品牌.xlsx"
async def main() -> None:
excel = pd.ExcelFile(EXCEL_PATH)
sheet_name = excel.sheet_names[0]
df = excel.parse(sheet_name)
sampled = df.head(10)
rows = sampled.to_dict(orient="records")
headers = [str(column) for column in sampled.columns]
payload = {
"import_record_id": "demo-import-001",
"rows": rows,
"struce": headers,
"llm_model": "deepseek:deepseek-chat",
"temperature": 0.2,
"callback_url": CALLBACK_URL,
}
async with httpx.AsyncClient(timeout=httpx.Timeout(15.0)) as client:
response = await client.post(API_URL, json=payload)
print("Status:", response.status_code)
print("Body:", response.json())
if __name__ == "__main__":
asyncio.run(main())