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
dbd1d797
Unverified
Commit
dbd1d797
authored
Feb 29, 2024
by
Yash Parmar
Committed by
GitHub
Feb 29, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FEAT: Add arxiv tool for searching scientific papers and articles fro… (#2632)
parent
19101781
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
93 additions
and
1 deletion
+93
-1
icon.svg
api/core/tools/provider/builtin/arxiv/_assets/icon.svg
+1
-0
arxiv.py
api/core/tools/provider/builtin/arxiv/arxiv.py
+20
-0
arxiv.yaml
api/core/tools/provider/builtin/arxiv/arxiv.yaml
+10
-0
arxiv_search.py
api/core/tools/provider/builtin/arxiv/tools/arxiv_search.py
+37
-0
arxiv_search.yaml
...core/tools/provider/builtin/arxiv/tools/arxiv_search.yaml
+23
-0
requirements.txt
api/requirements.txt
+2
-1
No files found.
api/core/tools/provider/builtin/arxiv/_assets/icon.svg
0 → 100644
View file @
dbd1d797
<svg
id=
"logomark"
xmlns=
"http://www.w3.org/2000/svg"
viewBox=
"0 0 17.732 24.269"
><g
id=
"tiny"
><path
d=
"M573.549,280.916l2.266,2.738,6.674-7.84c.353-.47.52-.717.353-1.117a1.218,1.218,0,0,0-1.061-.748h0a.953.953,0,0,0-.712.262Z"
transform=
"translate(-566.984 -271.548)"
fill=
"#bdb9b4"
/><path
d=
"M579.525,282.225l-10.606-10.174a1.413,1.413,0,0,0-.834-.5,1.09,1.09,0,0,0-1.027.66c-.167.4-.047.681.319,1.206l8.44,10.242h0l-6.282,7.716a1.336,1.336,0,0,0-.323,1.3,1.114,1.114,0,0,0,1.04.69A.992.992,0,0,0,571,293l8.519-7.92A1.924,1.924,0,0,0,579.525,282.225Z"
transform=
"translate(-566.984 -271.548)"
fill=
"#b31b1b"
/><path
d=
"M584.32,293.912l-8.525-10.275,0,0L573.53,280.9l-1.389,1.254a2.063,2.063,0,0,0,0,2.965l10.812,10.419a.925.925,0,0,0,.742.282,1.039,1.039,0,0,0,.953-.667A1.261,1.261,0,0,0,584.32,293.912Z"
transform=
"translate(-566.984 -271.548)"
fill=
"#bdb9b4"
/></g></svg>
\ No newline at end of file
api/core/tools/provider/builtin/arxiv/arxiv.py
0 → 100644
View file @
dbd1d797
from
core.tools.errors
import
ToolProviderCredentialValidationError
from
core.tools.provider.builtin.arxiv.tools.arxiv_search
import
ArxivSearchTool
from
core.tools.provider.builtin_tool_provider
import
BuiltinToolProviderController
class
ArxivProvider
(
BuiltinToolProviderController
):
def
_validate_credentials
(
self
,
credentials
:
dict
)
->
None
:
try
:
ArxivSearchTool
()
.
fork_tool_runtime
(
meta
=
{
"credentials"
:
credentials
,
}
)
.
invoke
(
user_id
=
''
,
tool_parameters
=
{
"query"
:
"John Doe"
,
},
)
except
Exception
as
e
:
raise
ToolProviderCredentialValidationError
(
str
(
e
))
\ No newline at end of file
api/core/tools/provider/builtin/arxiv/arxiv.yaml
0 → 100644
View file @
dbd1d797
identity
:
author
:
Yash Parmar
name
:
arxiv
label
:
en_US
:
ArXiv
zh_Hans
:
ArXiv
description
:
en_US
:
Access to a vast repository of scientific papers and articles in various fields of research.
zh_Hans
:
访问各个研究领域大量科学论文和文章的存储库。
icon
:
icon.svg
api/core/tools/provider/builtin/arxiv/tools/arxiv_search.py
0 → 100644
View file @
dbd1d797
from
typing
import
Any
from
langchain.utilities
import
ArxivAPIWrapper
from
pydantic
import
BaseModel
,
Field
from
core.tools.entities.tool_entities
import
ToolInvokeMessage
from
core.tools.tool.builtin_tool
import
BuiltinTool
class
ArxivSearchInput
(
BaseModel
):
query
:
str
=
Field
(
...
,
description
=
"Search query."
)
class
ArxivSearchTool
(
BuiltinTool
):
"""
A tool for searching articles on Arxiv.
"""
def
_invoke
(
self
,
user_id
:
str
,
tool_parameters
:
dict
[
str
,
Any
])
->
ToolInvokeMessage
|
list
[
ToolInvokeMessage
]:
"""
Invokes the Arxiv search tool with the given user ID and tool parameters.
Args:
user_id (str): The ID of the user invoking the tool.
tool_parameters (dict[str, Any]): The parameters for the tool, including the 'query' parameter.
Returns:
ToolInvokeMessage | list[ToolInvokeMessage]: The result of the tool invocation, which can be a single message or a list of messages.
"""
query
=
tool_parameters
.
get
(
'query'
,
''
)
if
not
query
:
return
self
.
create_text_message
(
'Please input query'
)
arxiv
=
ArxivAPIWrapper
()
response
=
arxiv
.
run
(
query
)
return
self
.
create_text_message
(
self
.
summary
(
user_id
=
user_id
,
content
=
response
))
api/core/tools/provider/builtin/arxiv/tools/arxiv_search.yaml
0 → 100644
View file @
dbd1d797
identity
:
name
:
arxiv_search
author
:
Yash Parmar
label
:
en_US
:
Arxiv Search
zh_Hans
:
Arxiv 搜索
description
:
human
:
en_US
:
A tool for searching scientific papers and articles from the Arxiv repository. Input can be an Arxiv ID or an author's name.
zh_Hans
:
一个用于从Arxiv存储库搜索科学论文和文章的工具。 输入可以是Arxiv ID或作者姓名。
llm
:
A tool for searching scientific papers and articles from the Arxiv repository. Input can be an Arxiv ID or an author's name.
parameters
:
-
name
:
query
type
:
string
required
:
true
label
:
en_US
:
Query string
zh_Hans
:
查询字符串
human_description
:
en_US
:
The Arxiv ID or author's name used for searching.
zh_Hans
:
用于搜索的Arxiv ID或作者姓名。
llm_description
:
The Arxiv ID or author's name used for searching.
form
:
llm
api/requirements.txt
View file @
dbd1d797
...
@@ -66,4 +66,5 @@ yfinance~=0.2.35
...
@@ -66,4 +66,5 @@ yfinance~=0.2.35
pydub~=0.25.1
pydub~=0.25.1
gmpy2~=2.1.5
gmpy2~=2.1.5
numexpr~=2.9.0
numexpr~=2.9.0
duckduckgo-search==4.4.3
duckduckgo-search==4.4.3
\ No newline at end of file
arxiv==2.1.0
\ No newline at end of file
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