Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
b2ee738b
Unverified
Commit
b2ee738b
authored
Feb 16, 2024
by
johnpccd
Committed by
GitHub
Feb 16, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore SSE comments to support openrouter streaming (#2432)
parent
c8ca3ff4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
llm.py
..._runtime/model_providers/openai_api_compatible/llm/llm.py
+4
-1
No files found.
api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py
View file @
b2ee738b
...
...
@@ -367,13 +367,16 @@ class OAIAPICompatLargeLanguageModel(_CommonOAI_API_Compat, LargeLanguageModel):
for
chunk
in
response
.
iter_lines
(
decode_unicode
=
True
,
delimiter
=
delimiter
):
if
chunk
:
#ignore sse comments
if
chunk
.
startswith
(
':'
):
continue
decoded_chunk
=
chunk
.
strip
()
.
lstrip
(
'data: '
)
.
lstrip
()
chunk_json
=
None
try
:
chunk_json
=
json
.
loads
(
decoded_chunk
)
# stream ended
except
json
.
JSONDecodeError
as
e
:
logger
.
error
(
f
"decoded_chunk error
,delimiter={delimiter},
decoded_chunk={decoded_chunk}"
)
logger
.
error
(
f
"decoded_chunk error
: {e}, delimiter={delimiter},
decoded_chunk={decoded_chunk}"
)
yield
create_final_llm_result_chunk
(
index
=
chunk_index
+
1
,
message
=
AssistantPromptMessage
(
content
=
""
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment