Skip to content

Commit

Permalink
fix: close #12215 for yi special case (#12222)
Browse files Browse the repository at this point in the history
Signed-off-by: yihong0618 <[email protected]>
  • Loading branch information
yihong0618 authored Jan 2, 2025
1 parent a640803 commit f30bf08
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/core/model_runtime/model_providers/openai/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,12 @@ def _handle_chat_generate_stream_response(

delta = chunk.choices[0]
has_finish_reason = delta.finish_reason is not None
# to fix issue #12215 yi model has special case for ligthing
# FIXME drop the case when yi model is updated
if model.startswith("yi-"):
if isinstance(delta.finish_reason, str):
# doc: https://platform.lingyiwanwu.com/docs/api-reference
has_finish_reason = delta.finish_reason.startswith(("length", "stop", "content_filter"))

if (
not has_finish_reason
Expand Down

0 comments on commit f30bf08

Please sign in to comment.