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
3f5177b6
Commit
3f5177b6
authored
Jul 17, 2023
by
John Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: replace args in universal chat
parent
055d2c45
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
3 deletions
+30
-3
chat.py
api/controllers/console/universal_chat/chat.py
+14
-3
model.py
api/models/model.py
+16
-0
No files found.
api/controllers/console/universal_chat/chat.py
View file @
3f5177b6
...
...
@@ -12,6 +12,7 @@ from controllers.console import api
from
controllers.console.app.error
import
ConversationCompletedError
,
AppUnavailableError
,
ProviderNotInitializeError
,
\
ProviderQuotaExceededError
,
ProviderModelCurrentlyNotSupportError
,
CompletionRequestError
from
controllers.console.universal_chat.wraps
import
UniversalChatResource
from
core.constant
import
llm_constant
from
core.conversation_message_task
import
PubHandler
from
core.llm.error
import
ProviderTokenNotInitError
,
QuotaExceededError
,
ModelCurrentlyNotSupportError
,
\
LLMBadRequestError
,
LLMAPIConnectionError
,
LLMAPIUnavailableError
,
LLMRateLimitError
,
LLMAuthorizationError
...
...
@@ -30,8 +31,17 @@ class UniversalChatApi(UniversalChatResource):
parser
.
add_argument
(
'tools'
,
type
=
list
,
required
=
True
,
location
=
'json'
)
args
=
parser
.
parse_args
()
# todo update app model config
args
[
'model_config'
]
=
{}
app_model_config
=
app_model
.
app_model_config
# update app model config
args
[
'model_config'
]
=
app_model_config
.
to_dict
()
args
[
'model_config'
][
'model'
][
'name'
]
=
args
[
'model'
]
if
not
llm_constant
.
models
[
args
[
'model'
]]:
raise
ValueError
(
"Model not exists."
)
args
[
'model_config'
][
'model'
][
'provider'
]
=
llm_constant
.
models
[
args
[
'model'
]]
args
[
'model_config'
][
'agent_mode'
][
'tools'
]
=
args
[
'tools'
]
args
[
'inputs'
]
=
{}
...
...
@@ -44,7 +54,8 @@ class UniversalChatApi(UniversalChatResource):
user
=
current_user
,
args
=
args
,
from_source
=
'console'
,
streaming
=
True
streaming
=
True
,
is_model_config_override
=
True
,
)
return
compact_response
(
response
)
...
...
api/models/model.py
View file @
3f5177b6
...
...
@@ -130,6 +130,22 @@ class AppModelConfig(db.Model):
def
agent_mode_dict
(
self
)
->
dict
:
return
json
.
loads
(
self
.
agent_mode
)
if
self
.
agent_mode
else
{
"enabled"
:
False
,
"strategy"
:
None
,
"tools"
:
[]}
def
to_dict
(
self
)
->
dict
:
return
{
"provider"
:
""
,
"model_id"
:
""
,
"configs"
:
{},
"opening_statement"
:
self
.
opening_statement
,
"suggested_questions"
:
self
.
suggested_questions_list
,
"suggested_questions_after_answer"
:
self
.
suggested_questions_after_answer_dict
,
"speech_to_text"
:
self
.
speech_to_text_dict
,
"more_like_this"
:
self
.
more_like_this_dict
,
"sensitive_word_avoidance"
:
self
.
sensitive_word_avoidance_dict
,
"model"
:
self
.
model_dict
,
"user_input_form"
:
self
.
user_input_form_list
,
"pre_prompt"
:
self
.
pre_prompt
,
"agent_mode"
:
self
.
agent_mode_dict
}
class
RecommendedApp
(
db
.
Model
):
__tablename__
=
'recommended_apps'
...
...
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