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
344821ed
Unverified
Commit
344821ed
authored
Jan 09, 2024
by
Chenhe Gu
Committed by
GitHub
Jan 09, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enforce utf-8 encoding for provider response (#1973)
parent
126b4c33
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
llm.py
..._runtime/model_providers/openai_api_compatible/llm/llm.py
+9
-3
No files found.
api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py
View file @
344821ed
...
@@ -168,7 +168,8 @@ class OAIAPICompatLargeLanguageModel(_CommonOAI_API_Compat, LargeLanguageModel):
...
@@ -168,7 +168,8 @@ class OAIAPICompatLargeLanguageModel(_CommonOAI_API_Compat, LargeLanguageModel):
type
=
ParameterType
.
FLOAT
,
type
=
ParameterType
.
FLOAT
,
default
=
float
(
credentials
.
get
(
'temperature'
,
0.7
)),
default
=
float
(
credentials
.
get
(
'temperature'
,
0.7
)),
min
=
0
,
min
=
0
,
max
=
2
max
=
2
,
precision
=
2
),
),
ParameterRule
(
ParameterRule
(
name
=
DefaultParameterName
.
TOP_P
.
value
,
name
=
DefaultParameterName
.
TOP_P
.
value
,
...
@@ -176,7 +177,8 @@ class OAIAPICompatLargeLanguageModel(_CommonOAI_API_Compat, LargeLanguageModel):
...
@@ -176,7 +177,8 @@ class OAIAPICompatLargeLanguageModel(_CommonOAI_API_Compat, LargeLanguageModel):
type
=
ParameterType
.
FLOAT
,
type
=
ParameterType
.
FLOAT
,
default
=
float
(
credentials
.
get
(
'top_p'
,
1
)),
default
=
float
(
credentials
.
get
(
'top_p'
,
1
)),
min
=
0
,
min
=
0
,
max
=
1
max
=
1
,
precision
=
2
),
),
ParameterRule
(
ParameterRule
(
name
=
"top_k"
,
name
=
"top_k"
,
...
@@ -246,7 +248,8 @@ class OAIAPICompatLargeLanguageModel(_CommonOAI_API_Compat, LargeLanguageModel):
...
@@ -246,7 +248,8 @@ class OAIAPICompatLargeLanguageModel(_CommonOAI_API_Compat, LargeLanguageModel):
:return: full response or stream response chunk generator result
:return: full response or stream response chunk generator result
"""
"""
headers
=
{
headers
=
{
'Content-Type'
:
'application/json'
'Content-Type'
:
'application/json'
,
'Accept-Charset'
:
'utf-8'
,
}
}
api_key
=
credentials
.
get
(
'api_key'
)
api_key
=
credentials
.
get
(
'api_key'
)
...
@@ -298,6 +301,9 @@ class OAIAPICompatLargeLanguageModel(_CommonOAI_API_Compat, LargeLanguageModel):
...
@@ -298,6 +301,9 @@ class OAIAPICompatLargeLanguageModel(_CommonOAI_API_Compat, LargeLanguageModel):
stream
=
stream
stream
=
stream
)
)
if
response
.
encoding
is
None
or
response
.
encoding
==
'ISO-8859-1'
:
response
.
encoding
=
'utf-8'
if
response
.
status_code
!=
200
:
if
response
.
status_code
!=
200
:
raise
InvokeError
(
f
"API request failed with status code {response.status_code}: {response.text}"
)
raise
InvokeError
(
f
"API request failed with status code {response.status_code}: {response.text}"
)
...
...
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