|
|
@@ -6,8 +6,8 @@ import csv
|
|
|
from fastapi.responses import StreamingResponse
|
|
|
import io
|
|
|
import urllib.parse
|
|
|
-from llmops.complete_agent_flow_rule import run_complete_agent_flow
|
|
|
-from llmops.config import DEEPSEEK_API_KEY
|
|
|
+from llmops.complete_agent_flow_rule import run_complete_agent_flow, run_flow
|
|
|
+from llmops.config import DEEPSEEK_API_KEY, LLM_API_KEY, LLM_BASE_URL, LLM_MODEL_NAME
|
|
|
from llmops.agents.data_stardard import TransactionParserAgent
|
|
|
from llmops.config import multimodal_api_url
|
|
|
|
|
|
@@ -102,15 +102,6 @@ async def dataset_classify(file: UploadFile = File(...), industry: str = Form(..
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-# 数据标准化agent
|
|
|
-standard_agent = TransactionParserAgent(
|
|
|
- api_key=DEEPSEEK_API_KEY,
|
|
|
- multimodal_api_url=multimodal_api_url
|
|
|
-)
|
|
|
-
|
|
|
@app.post("/api/report/gen")
|
|
|
async def gen_report(file: UploadFile = File(...), question: str = Form(...), industry: str = Form(...)):
|
|
|
"""
|
|
|
@@ -127,46 +118,30 @@ async def gen_report(file: UploadFile = File(...), question: str = Form(...), in
|
|
|
full_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), file_path)
|
|
|
|
|
|
print(f"上传文件绝对路径:{full_path}")
|
|
|
+ print(f"大模型名称:{LLM_MODEL_NAME}")
|
|
|
|
|
|
try:
|
|
|
# 将文件内容写入到上传目录中
|
|
|
with open(full_path, "wb") as f:
|
|
|
f.write(file.file.read())
|
|
|
|
|
|
- # 数据标准化
|
|
|
- result = await standard_agent.run_workflow_task(full_path)
|
|
|
- if result["status"] == "success":
|
|
|
- print(f"🎯 Workflow 任务完成!")
|
|
|
- # 标准化后的文件
|
|
|
- standard_file_path = result['file_path']
|
|
|
- standard_file_name = os.path.basename(standard_file_path)
|
|
|
- print(f"📂 文件全路径: {standard_file_path}, 文件名:{standard_file_name}")
|
|
|
-
|
|
|
- # 读取文件内容,标准化文件
|
|
|
- data_set = DataManager.load_data_from_csv_file(standard_file_path)
|
|
|
- # 执行测试
|
|
|
- result = await run_complete_agent_flow(
|
|
|
- question=question,
|
|
|
- industry=industry,
|
|
|
- data=data_set,
|
|
|
- file_name=standard_file_name,
|
|
|
- api_key=DEEPSEEK_API_KEY,
|
|
|
- session_id="direct-test"
|
|
|
- )
|
|
|
- print(result)
|
|
|
- return {
|
|
|
- "status": 0,
|
|
|
- "message": "success",
|
|
|
- "outline_draft": result["result"]["outline_draft"],
|
|
|
- "computed_metrics": result["result"]["computed_metrics"]
|
|
|
- }
|
|
|
- else:
|
|
|
- print(f"❌ 任务失败: {result['message']}")
|
|
|
- return {
|
|
|
- "status": 1,
|
|
|
- "message": result['message'],
|
|
|
- "report": {}
|
|
|
- }
|
|
|
+ # 执行测试
|
|
|
+ result = await run_flow(
|
|
|
+ question=question,
|
|
|
+ industry=industry,
|
|
|
+ original_file_path=full_path,
|
|
|
+ api_key=LLM_API_KEY,
|
|
|
+ base_url=LLM_BASE_URL,
|
|
|
+ model_name=LLM_MODEL_NAME,
|
|
|
+ session_id="direct-test"
|
|
|
+ )
|
|
|
+ print(result)
|
|
|
+ return {
|
|
|
+ "status": 0,
|
|
|
+ "message": "success",
|
|
|
+ "outline_draft": result["result"]["outline_draft"],
|
|
|
+ "computed_metrics": result["result"]["computed_metrics"]
|
|
|
+ }
|
|
|
except Exception as e:
|
|
|
print(f"生成流水分析报告异常: {e}")
|
|
|
import traceback
|