print request
This commit is contained in:
29
main.py
29
main.py
@@ -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"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user