260603更新

This commit is contained in:
liubiren 2026-06-03 21:08:26 +08:00
parent 48e08eebb8
commit 4912303991
2 changed files with 40 additions and 21 deletions

View File

@ -10,7 +10,6 @@ from typing import List, Optional, Union, cast
from typing import TypeVar
from uuid import uuid4
from mistralai.client.models import Op
from pydantic_ai import Agent as BaseAgent, AgentRunResult
from pydantic_ai.capabilities import AgentCapability
from pydantic_ai.models.openai import OpenAIChatModel
@ -141,7 +140,7 @@ class Agent:
from pydantic_ai.ui.vercel_ai import VercelAIAdapter
from pydantic_ai.capabilities import NativeTool
async def options(request: Request) -> Response:
async def chat_options(request: Request) -> Response:
"""处理跨域预检请求"""
return Response()
@ -179,7 +178,7 @@ class Agent:
)
return JSONResponse(content=configurations.model_dump(by_alias=True))
async def chat(request: Request) -> Response:
async def chat_post(request: Request) -> Response:
"""处理对话请求"""
# 实例 Vercel AI 适配器
adapter = await VercelAIAdapter[
@ -216,10 +215,10 @@ class Agent:
return Starlette(
routes=[
Route("/chat", options, methods=["OPTIONS"]),
Route("/configure", configurations, methods=["GET"]),
Route("/chat", chat, methods=["POST"]),
Route("/health", health, methods=["GET"]),
Route(path="/chat", endpoint=chat_options, methods=["OPTIONS"]),
Route(path="/configure", endpoint=configurations, methods=["GET"]),
Route(path="/chat", endpoint=chat_post, methods=["POST"]),
Route(path="/health", endpoint=health, methods=["GET"]),
]
)
@ -244,7 +243,7 @@ class Agent:
)
]
)
application.router.add_route("/", index, methods=["GET"])
application.router.add_route("/{id}", index, methods=["GET"])
application.router.add_route(path="/", endpoint=index, methods=["GET"])
application.router.add_route(path="/{id}", endpoint=index, methods=["GET"])
return application

View File

@ -8,6 +8,7 @@ from base64 import b64decode, b64encode
from json import dumps, loads
from pathlib import Path
from secrets import token_bytes
import sys
from time import time_ns
from typing import cast
from typing import Any, Dict, Literal, Optional, Tuple
@ -21,10 +22,7 @@ from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives.serialization import load_pem_public_key
import sys
sys.path.append(Path(__file__).parent.parent.as_posix())
from utils.request import Request
@ -222,21 +220,24 @@ if __name__ == "__main__":
# 实例加密器
encryptor = Encryptor()
# 杭州汤然请求同步响应
# https://risk-gw.pangjukeji.com/api/v1/riskgateway/product/invokeSync.json
# 杭州汤然请求异步响应(创建任务)
# https://risk-gw.pangjukeji.com/api/v1/riskgateway/product/submitAsyncTask.json
# 杭州汤然请求异步响应(查询任务)
# https://risk-gw.pangjukeji.com/api/v1/riskgateway/result/queryAsyncResult.json
# 实例请求客户端
request = Request() # 不使用缓存
response = request.post(
url="https://risk-gw.pangjukeji.com/api/v1/riskgateway/product/invokeSync.json",
url="https://risk-gw.pangjukeji.com/api/v1/riskgateway/result/queryAsyncResult.json",
headers={
"Authorization": "Bearer 337162980141699072",
"Content-Type": "application/json;charset=utf-8",
},
json=encryptor.encrypt(
payload={
"productId": "BANK_CARD_4",
"name": "刘弼仁",
"certNo": "131002198705024619",
"mobilephone": "18058798752",
"bankCardNo": "6214835712066453",
"productId": "CAR_ACCIDENT_DETAIL",
"recordId": "337471805314961408",
},
fields_mapping={
"aes_key_encoded": "encryptedAesKey",
@ -267,8 +268,27 @@ if __name__ == "__main__":
"certNo": "131002196212124620"
}
{
"productId": "BANK_CARD_4",
"name": "刘弼仁",
"certNo": "131002198705024619",
"mobilephone": "18058798752",
"bankCardNo": "6228480328744527172",
},
{
"productId": "SOCIAL_CAPACITY",
"name": "刘弼仁",
"certNo": "131002198705024619",
"mobilephone": "18058798752",
},
{
"productId": "CREDIT_RISK_PRE_SCREEN",
"mobilephone": "13833652939",
"certNo": "131002196212124620"
},
{
"productId": "CAR_ACCIDENT_DETAIL",
"vin": "L6T7712Z2GN076782",
}
"""