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
f8951d7f
Unverified
Commit
f8951d7f
authored
Mar 11, 2024
by
Yeuoly
Committed by
GitHub
Mar 11, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: api tool provider not found (#2782)
parent
6454e1d6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
35 deletions
+44
-35
app.py
api/controllers/console/app/app.py
+22
-19
model_config.py
api/controllers/console/app/model_config.py
+22
-16
No files found.
api/controllers/console/app/app.py
View file @
f8951d7f
...
...
@@ -247,27 +247,30 @@ class AppApi(Resource):
for
tool
in
agent_mode
.
get
(
'tools'
)
or
[]:
agent_tool_entity
=
AgentToolEntity
(
**
tool
)
# get tool
tool_runtime
=
ToolManager
.
get_agent_tool_runtime
(
tenant_id
=
current_user
.
current_tenant_id
,
agent_tool
=
agent_tool_entity
,
agent_callback
=
None
)
manager
=
ToolParameterConfigurationManager
(
tenant_id
=
current_user
.
current_tenant_id
,
tool_runtime
=
tool_runtime
,
provider_name
=
agent_tool_entity
.
provider_id
,
provider_type
=
agent_tool_entity
.
provider_type
,
)
try
:
tool_runtime
=
ToolManager
.
get_agent_tool_runtime
(
tenant_id
=
current_user
.
current_tenant_id
,
agent_tool
=
agent_tool_entity
,
agent_callback
=
None
)
manager
=
ToolParameterConfigurationManager
(
tenant_id
=
current_user
.
current_tenant_id
,
tool_runtime
=
tool_runtime
,
provider_name
=
agent_tool_entity
.
provider_id
,
provider_type
=
agent_tool_entity
.
provider_type
,
)
# get decrypted parameters
if
agent_tool_entity
.
tool_parameters
:
parameters
=
manager
.
decrypt_tool_parameters
(
agent_tool_entity
.
tool_parameters
or
{})
masked_parameter
=
manager
.
mask_tool_parameters
(
parameters
or
{})
else
:
masked_parameter
=
{}
# get decrypted parameters
if
agent_tool_entity
.
tool_parameters
:
parameters
=
manager
.
decrypt_tool_parameters
(
agent_tool_entity
.
tool_parameters
or
{})
masked_parameter
=
manager
.
mask_tool_parameters
(
parameters
or
{})
else
:
masked_parameter
=
{}
# override tool parameters
tool
[
'tool_parameters'
]
=
masked_parameter
# override tool parameters
tool
[
'tool_parameters'
]
=
masked_parameter
except
Exception
as
e
:
pass
# override agent mode
model_config
.
agent_mode
=
json
.
dumps
(
agent_mode
)
...
...
api/controllers/console/app/model_config.py
View file @
f8951d7f
...
...
@@ -54,17 +54,20 @@ class ModelConfigResource(Resource):
for
tool
in
agent_mode
.
get
(
'tools'
)
or
[]:
agent_tool_entity
=
AgentToolEntity
(
**
tool
)
# get tool
tool_runtime
=
ToolManager
.
get_agent_tool_runtime
(
tenant_id
=
current_user
.
current_tenant_id
,
agent_tool
=
agent_tool_entity
,
agent_callback
=
None
)
manager
=
ToolParameterConfigurationManager
(
tenant_id
=
current_user
.
current_tenant_id
,
tool_runtime
=
tool_runtime
,
provider_name
=
agent_tool_entity
.
provider_id
,
provider_type
=
agent_tool_entity
.
provider_type
,
)
try
:
tool_runtime
=
ToolManager
.
get_agent_tool_runtime
(
tenant_id
=
current_user
.
current_tenant_id
,
agent_tool
=
agent_tool_entity
,
agent_callback
=
None
)
manager
=
ToolParameterConfigurationManager
(
tenant_id
=
current_user
.
current_tenant_id
,
tool_runtime
=
tool_runtime
,
provider_name
=
agent_tool_entity
.
provider_id
,
provider_type
=
agent_tool_entity
.
provider_type
,
)
except
Exception
as
e
:
continue
# get decrypted parameters
if
agent_tool_entity
.
tool_parameters
:
...
...
@@ -89,11 +92,14 @@ class ModelConfigResource(Resource):
if
key
in
tool_map
:
tool_runtime
=
tool_map
[
key
]
else
:
tool_runtime
=
ToolManager
.
get_agent_tool_runtime
(
tenant_id
=
current_user
.
current_tenant_id
,
agent_tool
=
agent_tool_entity
,
agent_callback
=
None
)
try
:
tool_runtime
=
ToolManager
.
get_agent_tool_runtime
(
tenant_id
=
current_user
.
current_tenant_id
,
agent_tool
=
agent_tool_entity
,
agent_callback
=
None
)
except
Exception
as
e
:
continue
manager
=
ToolParameterConfigurationManager
(
tenant_id
=
current_user
.
current_tenant_id
,
...
...
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