File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
volcenginesdkwafruntime/api Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change 22from volcenginesdkwaf import WAFApi , CheckLLMResponseStreamRequest
33from volcenginesdkwafruntime .models .llm_stream_session import LLMStreamSession
44
5+ global_llm_send_len = 10
56
67class 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
You can’t perform that action at this time.
0 commit comments