Skip to content

Commit b11ef24

Browse files
committed
根据review 结果进行修改
1 parent daf4f13 commit b11ef24

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

volcenginesdkwafruntime/api/waf_runtime_api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from volcenginesdkwaf import WAFApi, CheckLLMResponseStreamRequest
33
from volcenginesdkwafruntime.models.llm_stream_session import LLMStreamSession
44

5+
global_llm_send_len = 10
56

67
class WAFRuntimeApi(WAFApi):
78
"""继承自 WAFApi 并重写 check_llm_response_stream 方法"""
@@ -57,7 +58,7 @@ def check_llm_response_stream(
5758
# 3. 处理 use_stream 为其他值的情况(累计长度,超过阈值才发送)
5859
else:
5960
# 如果未发送长度超过 10 个字符,调用 API
60-
if session.get_stream_send_len() > 10:
61+
if session.get_stream_send_len() > global_llm_send_len:
6162
# 准备请求体,使用 session 中的完整流内容
6263
body.content = session.get_stream_buf()
6364
body.msg_id = session.get_msg_id()
@@ -67,7 +68,7 @@ def check_llm_response_stream(
6768

6869
# 同步调用并处理结果
6970
resp = self.check_llm_response_stream_with_http_info(body, **kwargs)
70-
if isinstance(resp, tuple):
71+
if isinstance(resp, tuple) and len(resp) > 0:
7172
response = resp[0] # 获取元组的第一个元素
7273
else:
7374
response = resp

0 commit comments

Comments
 (0)