Skip to content

Commit 643a90c

Browse files
authored
fix: use removeprefix() instead of lstrip() to remove the data: prefix (langgenius#11272)
Signed-off-by: -LAN- <[email protected]>
1 parent 2a448a8 commit 643a90c

File tree

3 files changed

+3
-3
lines changed
  • api/core/model_runtime/model_providers

3 files changed

+3
-3
lines changed

api/core/model_runtime/model_providers/moonshot/llm/llm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def get_tool_call(tool_name: str):
252252
# ignore sse comments
253253
if chunk.startswith(":"):
254254
continue
255-
decoded_chunk = chunk.strip().lstrip("data: ").lstrip()
255+
decoded_chunk = chunk.strip().removeprefix("data: ")
256256
chunk_json = None
257257
try:
258258
chunk_json = json.loads(decoded_chunk)

api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ def get_tool_call(tool_call_id: str):
462462
# ignore sse comments
463463
if chunk.startswith(":"):
464464
continue
465-
decoded_chunk = chunk.strip().lstrip("data: ").lstrip()
465+
decoded_chunk = chunk.strip().removeprefix("data: ")
466466
if decoded_chunk == "[DONE]": # Some provider returns "data: [DONE]"
467467
continue
468468

api/core/model_runtime/model_providers/stepfun/llm/llm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def get_tool_call(tool_name: str):
250250
# ignore sse comments
251251
if chunk.startswith(":"):
252252
continue
253-
decoded_chunk = chunk.strip().lstrip("data: ").lstrip()
253+
decoded_chunk = chunk.strip().removeprefix("data: ")
254254
chunk_json = None
255255
try:
256256
chunk_json = json.loads(decoded_chunk)

0 commit comments

Comments
 (0)