Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ from Gradio_UI import GradioUI
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
-
def my_custom_tool(
|
| 13 |
"""
|
| 14 |
A tool that performs a search in the PubMed database using the NCBI E-utilities API.
|
| 15 |
|
|
@@ -17,22 +17,17 @@ def my_custom_tool(str1: str, api_key: str) -> str:
|
|
| 17 |
the results in XML format. It requires an API key for authentication and rate limit management.
|
| 18 |
|
| 19 |
Args:
|
| 20 |
-
|
| 21 |
-
api_key
|
| 22 |
to increase the rate limit and ensure uninterrupted access.
|
| 23 |
|
| 24 |
Returns:
|
| 25 |
str: The response from the PubMed database in XML format, containing the search results.
|
| 26 |
-
|
| 27 |
-
Example:
|
| 28 |
-
To search for articles related to "cancer" in PubMed:
|
| 29 |
-
>>> result = my_custom_tool("cancer", "your_api_key_here")
|
| 30 |
-
>>> print(result) # Outputs the XML response with PubMed search results.
|
| 31 |
"""
|
| 32 |
base_url = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi"
|
| 33 |
params = {
|
| 34 |
"db": "pubmed",
|
| 35 |
-
"term":
|
| 36 |
"retmax": 5, # Limit the number of results
|
| 37 |
"api_key": api_key # API key for authentication
|
| 38 |
}
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
+
def my_custom_tool(term: str, api_key: str) -> str:
|
| 13 |
"""
|
| 14 |
A tool that performs a search in the PubMed database using the NCBI E-utilities API.
|
| 15 |
|
|
|
|
| 17 |
the results in XML format. It requires an API key for authentication and rate limit management.
|
| 18 |
|
| 19 |
Args:
|
| 20 |
+
term: The search term to query in the PubMed database (e.g., "cancer").
|
| 21 |
+
api_key: The API key for accessing the NCBI E-utilities API. This key is required
|
| 22 |
to increase the rate limit and ensure uninterrupted access.
|
| 23 |
|
| 24 |
Returns:
|
| 25 |
str: The response from the PubMed database in XML format, containing the search results.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
"""
|
| 27 |
base_url = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi"
|
| 28 |
params = {
|
| 29 |
"db": "pubmed",
|
| 30 |
+
"term": term,
|
| 31 |
"retmax": 5, # Limit the number of results
|
| 32 |
"api_key": api_key # API key for authentication
|
| 33 |
}
|