Chmonya1 commited on
Commit
fd32a0a
·
verified ·
1 Parent(s): 9055084

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -6
app.py CHANGED
@@ -9,14 +9,38 @@ 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(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
  #Keep this format for the description / args / args description but feel free to modify the tool
14
- """A tool that does nothing yet
 
 
 
 
 
15
  Args:
16
- arg1: the first argument
17
- arg2: the second argument
 
 
 
 
 
 
 
 
 
18
  """
19
- return arg1 * arg2
 
 
 
 
 
 
 
 
 
 
20
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -55,7 +79,7 @@ with open("prompts.yaml", 'r') as stream:
55
 
56
  agent = CodeAgent(
57
  model=model,
58
- tools=[final_answer, my_custom_tool, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
 
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
+ def my_custom_tool(str1:str, api_key:str)-> str: #it's import to specify the return type
13
  #Keep this format for the description / args / args description but feel free to modify the tool
14
+ """
15
+ A tool that performs a search in the PubMed database using the NCBI E-utilities API.
16
+
17
+ This tool sends a request to the PubMed database with a specified search term and returns
18
+ the results in XML format. It requires an API key for authentication and rate limit management.
19
+
20
  Args:
21
+ str1 (str): The search term to query in the PubMed database (e.g., "cancer").
22
+ api_key (str): The API key for accessing the NCBI E-utilities API. This key is required
23
+ to increase the rate limit and ensure uninterrupted access.
24
+
25
+ Returns:
26
+ str: The response from the PubMed database in XML format, containing the search results.
27
+
28
+ Example:
29
+ To search for articles related to "cancer" in PubMed:
30
+ >>> result = my_custom_tool("cancer", "your_api_key_here")
31
+ >>> print(result) # Outputs the XML response with PubMed search results.
32
  """
33
+ base_url = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi"
34
+ params = {
35
+ "db": "pubmed",
36
+ "term": str1,
37
+ "retmax": 5, # Ограничение количества результатов
38
+ "api_key": api_key # Необязательно, но рекомендуется
39
+ }
40
+
41
+ # Отправка запроса
42
+ response = requests.get(base_url, params=params)
43
+ return response.text
44
 
45
  @tool
46
  def get_current_time_in_timezone(timezone: str) -> str:
 
79
 
80
  agent = CodeAgent(
81
  model=model,
82
+ tools=[final_answer, my_custom_tool, get_current_time_in_timezone, image_generation_tool], ## add your tools here (don't remove final answer)
83
  max_steps=6,
84
  verbosity_level=1,
85
  grammar=None,