之前存在106.52上的仓库被重新初始化了,同时增加了测试账号的兼容,测试账号hxbtest001,...hxbtest005

This commit is contained in:
qcloud
2025-09-01 20:09:26 +08:00
parent e6644a5262
commit 8d90798647
16 changed files with 25420 additions and 157 deletions

View File

@@ -114,7 +114,7 @@ def generate_before_payload(sequence: int):
# 构建完整请求
def construct_request(reqid):
def construct_request(reqid,museum_id):
req = {
"user": {
"uid": "test",
@@ -133,11 +133,13 @@ def construct_request(reqid):
"show_utterances": False
}
}
if museum_id==3 or museum_id=='3':
req['boosting_table_id'] = "71164be7-04d7-4b9f-a281-a91b76505297"
return req
def construct_full_request(reqid, seq):
request_params = construct_request(reqid)
def construct_full_request(reqid, seq, museum_id):
request_params = construct_request(reqid,museum_id)
payload_bytes = str.encode(json.dumps(request_params))
payload_bytes = gzip.compress(payload_bytes)
full_client_request = bytearray(generate_header(message_type_specific_flags=POS_SEQUENCE))
@@ -263,7 +265,7 @@ async def forward_to_client(websocket: WebSocket, client_ws: websockets.WebSocke
await websocket.close()
async def send_full_request():
async def send_full_request(museum_id):
reqid = str(uuid.uuid4())
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
@@ -280,7 +282,7 @@ async def send_full_request():
try:
# connect doubao 时带了extra_headers 所以只能使用websockets 12.0 版本, pip install websockets == 12.0
async with websockets.connect(TARGET_WS_URL, extra_headers=header, ssl=ssl_context) as client_ws:
await client_ws.send(construct_full_request(reqid, seq))
await client_ws.send(construct_full_request(reqid, seq, museum_id))
print("send full_request to doubao server")
res = await client_ws.recv()
@@ -315,11 +317,15 @@ async def websocket_endpoint(websocket: WebSocket):
"X-Api-Request-Id": reqid
}
seq = 1
# 获取查询参数因为WebSocket不能直接传递header
query_params = websocket.query_params
museum_id = query_params.get("museum_id")
print(f"asr websocket connect {museum_id}")
await websocket.accept()
try:
async with websockets.connect(TARGET_WS_URL, extra_headers=header, ssl=ssl_context) as client_ws:
await client_ws.send(construct_full_request(reqid, seq))
await client_ws.send(construct_full_request(reqid, seq, museum_id))
print("send full_request to doubao server")
res = await client_ws.recv()
result = parse_response(res)