print request

This commit is contained in:
2026-03-05 15:22:21 +08:00
parent d9e5347f3e
commit 7470b5fe2d

29
main.py
View File

@@ -2,7 +2,7 @@
import logging import logging
from fastapi import FastAPI from fastapi import FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel from pydantic import BaseModel
@@ -43,7 +43,7 @@ class FullWorkflowResponse(BaseModel):
status: str = "success" status: str = "success"
@app.post("/workflow/full", response_model=FullWorkflowResponse) @app.post("/workflow/full", response_model=FullWorkflowResponse)
async def full_workflow(request: RequirementRequest): async def full_workflow(request: Request):
""" """
完整工作流PM Agent -> QA Agent -> Dev Agent 完整工作流PM Agent -> QA Agent -> Dev Agent
@@ -65,12 +65,29 @@ async def full_workflow(request: RequirementRequest):
} }
""" """
try: try:
logger.info(f"开始处理需求: {request.message}") # 2. 获取原始 body字节串
body_bytes = await request.body()
# 调用编排函数执行三个Agent的工作流 # 3. 尝试解码为字符串并打印
await orchestrate_agents(request.message) try:
body_str = body_bytes.decode('utf-8')
print(f"Raw body (string): {body_str}")
except UnicodeDecodeError:
print("Raw body is not valid UTF-8")
# 构建响应 # 4. 尝试解析 JSON如果失败则记录错误但不影响返回
try:
json_data = await request.json()
print(f"Parsed JSON: {json_data}")
except Exception as e:
print(f"JSON parse error: {e}")
# logger.info(f"开始处理需求: {request.message}")
#
# # 调用编排函数执行三个Agent的工作流
# await orchestrate_agents(request.message)
#
# # 构建响应
response = FullWorkflowResponse( response = FullWorkflowResponse(
status="success" status="success"
) )