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
025b859c
Unverified
Commit
025b859c
authored
Jan 04, 2024
by
takatost
Committed by
GitHub
Jan 04, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: tongyi generate error (#1904)
parent
0e239a4f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
llm.py
api/core/model_runtime/model_providers/tongyi/llm/llm.py
+6
-6
No files found.
api/core/model_runtime/model_providers/tongyi/llm/llm.py
View file @
025b859c
...
@@ -52,9 +52,13 @@ class TongyiLargeLanguageModel(LargeLanguageModel):
...
@@ -52,9 +52,13 @@ class TongyiLargeLanguageModel(LargeLanguageModel):
:param tools: tools for tool calling
:param tools: tools for tool calling
:return:
:return:
"""
"""
# transform credentials to kwargs for model instance
credentials_kwargs
=
self
.
_to_credential_kwargs
(
credentials
)
response
=
dashscope
.
Tokenization
.
call
(
response
=
dashscope
.
Tokenization
.
call
(
model
=
model
,
model
=
model
,
prompt
=
self
.
_convert_messages_to_prompt
(
prompt_messages
),
prompt
=
self
.
_convert_messages_to_prompt
(
prompt_messages
),
**
credentials_kwargs
)
)
if
response
.
status_code
==
HTTPStatus
.
OK
:
if
response
.
status_code
==
HTTPStatus
.
OK
:
...
@@ -108,10 +112,6 @@ class TongyiLargeLanguageModel(LargeLanguageModel):
...
@@ -108,10 +112,6 @@ class TongyiLargeLanguageModel(LargeLanguageModel):
# transform credentials to kwargs for model instance
# transform credentials to kwargs for model instance
credentials_kwargs
=
self
.
_to_credential_kwargs
(
credentials
)
credentials_kwargs
=
self
.
_to_credential_kwargs
(
credentials
)
dashscope
.
api_key
=
credentials_kwargs
[
'api_key'
]
print
(
credentials_kwargs
,
'credentials_kwargs'
)
client
=
EnhanceTongyi
(
client
=
EnhanceTongyi
(
model_name
=
model
,
model_name
=
model
,
streaming
=
stream
,
streaming
=
stream
,
...
@@ -121,7 +121,8 @@ class TongyiLargeLanguageModel(LargeLanguageModel):
...
@@ -121,7 +121,8 @@ class TongyiLargeLanguageModel(LargeLanguageModel):
params
=
{
params
=
{
'model'
:
model
,
'model'
:
model
,
'prompt'
:
self
.
_convert_messages_to_prompt
(
prompt_messages
),
'prompt'
:
self
.
_convert_messages_to_prompt
(
prompt_messages
),
**
model_parameters
**
model_parameters
,
**
credentials_kwargs
}
}
if
stream
:
if
stream
:
responses
=
stream_generate_with_retry
(
responses
=
stream_generate_with_retry
(
...
@@ -222,7 +223,6 @@ class TongyiLargeLanguageModel(LargeLanguageModel):
...
@@ -222,7 +223,6 @@ class TongyiLargeLanguageModel(LargeLanguageModel):
:param credentials:
:param credentials:
:return:
:return:
"""
"""
print
(
credentials
,
'credentials'
)
credentials_kwargs
=
{
credentials_kwargs
=
{
"api_key"
:
credentials
[
'dashscope_api_key'
],
"api_key"
:
credentials
[
'dashscope_api_key'
],
}
}
...
...
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