Initial commit: AI Interview System
This commit is contained in:
38
backend/test_single_insert.py
Normal file
38
backend/test_single_insert.py
Normal file
@@ -0,0 +1,38 @@
|
||||
"""测试单条 INSERT"""
|
||||
import asyncio
|
||||
import httpx
|
||||
import json
|
||||
import uuid
|
||||
|
||||
COZE_API_BASE = "https://api.coze.cn"
|
||||
COZE_PAT_TOKEN = "pat_nd1wU47WyPS9GCIyJ1clnH8h1WOQXGrYELX8w73TnSZaYbFdYD4swIhzcETBUbfT"
|
||||
WORKFLOW_ID = "7597376294612107318"
|
||||
|
||||
async def main():
|
||||
log_id = f"LOG_TEST_{uuid.uuid4().hex[:8]}"
|
||||
|
||||
sql = f"""INSERT INTO ci_interview_logs (log_id, session_id, stage, round, ai_question, user_answer, log_type) VALUES ('{log_id}', 'TEST_001', '测试', '1', '测试问题', '测试回答', 'test')"""
|
||||
|
||||
input_json = json.dumps({"table": "logs", "sql": sql}, ensure_ascii=False)
|
||||
|
||||
print(f"log_id: {log_id}")
|
||||
print(f"sql: {sql[:80]}...")
|
||||
|
||||
headers = {
|
||||
"Authorization": f"Bearer {COZE_PAT_TOKEN}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
async with httpx.AsyncClient(timeout=30.0) as client:
|
||||
response = await client.post(
|
||||
f"{COZE_API_BASE}/v1/workflow/run",
|
||||
headers=headers,
|
||||
json={"workflow_id": WORKFLOW_ID, "parameters": {"input": input_json}}
|
||||
)
|
||||
result = response.json()
|
||||
print(f"code: {result.get('code')}")
|
||||
print(f"msg: {result.get('msg')}")
|
||||
print(f"data: {result.get('data', '')[:200]}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user