Shailendra-cts commited on
Commit
11f0ccf
·
verified ·
1 Parent(s): 5db680c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -7
app.py CHANGED
@@ -6,21 +6,43 @@ import requests
6
  import pytz
7
  import yaml
8
  from tools.final_answer import FinalAnswerTool
 
9
 
10
  from Gradio_UI import GradioUI
11
 
12
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
13
  @tool
14
- def recipe_engine(query: str) -> str:
15
- """
16
- Allows you to find the best recipe from local database. Do not search over internet. Returns a string representation of the result.
17
-
18
  Args:
19
- query: The query to perform. This should be a string.
20
  """
21
- output = "This is my test tools"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
- return output
24
 
25
  @tool
26
  def get_current_time_in_timezone(timezone: str) -> str:
 
6
  import pytz
7
  import yaml
8
  from tools.final_answer import FinalAnswerTool
9
+ import spacy
10
 
11
  from Gradio_UI import GradioUI
12
 
13
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
14
  @tool
15
+ def diagnose_disease(symptoms: str) -> str:
16
+ """Fetches health articles based on symptoms and extracts possible diseases.
17
+
 
18
  Args:
19
+ symptoms: A comma-separated list of symptoms (e.g., 'fever, headache, sore throat').
20
  """
21
+ try:
22
+ search_tool = DuckDuckGoSearchTool()
23
+ query = f"Possible diseases for symptoms: {symptoms}"
24
+ search_results = search_tool.forward(query)
25
+
26
+ if not search_results:
27
+ return "No relevant medical information found. Please consult a doctor."
28
+
29
+ articles = search_results.split("\n\n")[:10] # Get top 10 articles
30
+ possible_diseases = set()
31
+
32
+ for article in articles:
33
+ doc = nlp(article)
34
+ for ent in doc.ents:
35
+ if ent.label_ == "DISEASE":
36
+ possible_diseases.add(ent.text)
37
+
38
+ if not possible_diseases:
39
+ return "No specific diseases could be identified. Consider seeking medical advice."
40
+
41
+ return f"Based on your symptoms, possible conditions could be: {', '.join(possible_diseases)}."
42
+
43
+ except Exception as e:
44
+ return f"An error occurred: {e}"
45
 
 
46
 
47
  @tool
48
  def get_current_time_in_timezone(timezone: str) -> str: