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
6921ee5d
Commit
6921ee5d
authored
Jul 10, 2023
by
John Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: dataset query when single dataset
parent
77146b50
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
2 deletions
+7
-2
multi_dataset_router_agent.py
api/core/agent/agent/multi_dataset_router_agent.py
+4
-2
completion.py
api/core/completion.py
+1
-0
dataset_retriever_tool.py
api/core/tool/dataset_retriever_tool.py
+2
-0
No files found.
api/core/agent/agent/multi_dataset_router_agent.py
View file @
6921ee5d
from
typing
import
Tuple
,
List
,
Any
,
Union
,
Sequence
,
Optional
from
typing
import
Tuple
,
List
,
Any
,
Union
,
Sequence
,
Optional
,
cast
from
langchain.agents
import
OpenAIFunctionsAgent
,
BaseSingleActionAgent
from
langchain.agents
import
OpenAIFunctionsAgent
,
BaseSingleActionAgent
from
langchain.callbacks.base
import
BaseCallbackManager
from
langchain.callbacks.base
import
BaseCallbackManager
...
@@ -42,7 +42,9 @@ class MultiDatasetRouterAgent(OpenAIFunctionsAgent):
...
@@ -42,7 +42,9 @@ class MultiDatasetRouterAgent(OpenAIFunctionsAgent):
if
len
(
self
.
tools
)
==
0
:
if
len
(
self
.
tools
)
==
0
:
return
AgentFinish
(
return_values
=
{
"output"
:
''
},
log
=
''
)
return
AgentFinish
(
return_values
=
{
"output"
:
''
},
log
=
''
)
elif
len
(
self
.
tools
)
==
1
:
elif
len
(
self
.
tools
)
==
1
:
rst
=
next
(
iter
(
self
.
tools
))
.
run
(
kwargs
[
'input'
])
tool
=
next
(
iter
(
self
.
tools
))
tool
=
cast
(
DatasetRetrieverTool
,
tool
)
rst
=
tool
.
run
(
tool_input
=
{
'dataset_id'
:
tool
.
dataset_id
,
'query'
:
kwargs
[
'input'
]})
return
AgentFinish
(
return_values
=
{
"output"
:
rst
},
log
=
rst
)
return
AgentFinish
(
return_values
=
{
"output"
:
rst
},
log
=
rst
)
if
intermediate_steps
:
if
intermediate_steps
:
...
...
api/core/completion.py
View file @
6921ee5d
...
@@ -103,6 +103,7 @@ class Completion:
...
@@ -103,6 +103,7 @@ class Completion:
# # todo streaming flush the agent result to user, not call final llm
# # todo streaming flush the agent result to user, not call final llm
# pass
# pass
# todo or use fake llm
cls
.
run_final_llm
(
cls
.
run_final_llm
(
tenant_id
=
app
.
tenant_id
,
tenant_id
=
app
.
tenant_id
,
mode
=
app
.
mode
,
mode
=
app
.
mode
,
...
...
api/core/tool/dataset_retriever_tool.py
View file @
6921ee5d
...
@@ -27,6 +27,7 @@ class DatasetRetrieverTool(BaseTool):
...
@@ -27,6 +27,7 @@ class DatasetRetrieverTool(BaseTool):
description
:
str
=
"use this to retrieve a dataset. "
description
:
str
=
"use this to retrieve a dataset. "
tenant_id
:
str
tenant_id
:
str
dataset_id
:
str
k
:
int
=
3
k
:
int
=
3
@
classmethod
@
classmethod
...
@@ -38,6 +39,7 @@ class DatasetRetrieverTool(BaseTool):
...
@@ -38,6 +39,7 @@ class DatasetRetrieverTool(BaseTool):
description
+=
'
\n
ID of dataset MUST be '
+
dataset
.
id
description
+=
'
\n
ID of dataset MUST be '
+
dataset
.
id
return
cls
(
return
cls
(
tenant_id
=
dataset
.
tenant_id
,
tenant_id
=
dataset
.
tenant_id
,
dataset_id
=
dataset
.
id
,
description
=
description
,
description
=
description
,
**
kwargs
**
kwargs
)
)
...
...
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