Spaces:
Sleeping
Sleeping
test
Browse files
app.py
CHANGED
|
@@ -4,15 +4,6 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
-
import os
|
| 8 |
-
os.system('pip install nltk')
|
| 9 |
-
os.system('pip install textstat')
|
| 10 |
-
os.system('pip install collections')
|
| 11 |
-
import nltk
|
| 12 |
-
import textstat
|
| 13 |
-
from nltk.tokenize import word_tokenize, sent_tokenize
|
| 14 |
-
from collections import Counter
|
| 15 |
-
nltk.download("punkt")
|
| 16 |
from Gradio_UI import GradioUI
|
| 17 |
|
| 18 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
|
@@ -34,19 +25,15 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 34 |
|
| 35 |
#Following my creation.
|
| 36 |
@tool
|
| 37 |
-
def
|
| 38 |
-
"""A tool that
|
| 39 |
Args:
|
| 40 |
-
|
|
|
|
| 41 |
"""
|
| 42 |
try:
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
word_count = len(words)
|
| 46 |
-
sentence_count = len(sentences)
|
| 47 |
-
reading_level = textstat.flesch_kincaid_grade(text)
|
| 48 |
-
most_common_words = Counter(words).most_common(5)
|
| 49 |
-
return f"I completed the analysis. The text has {word_count} words and {sentence_count} sentences. The reading level is {reading_level}. The 5 most common words are {most_common_words}"
|
| 50 |
except Exception as e:
|
| 51 |
return f"I could not complete the task. I got this error: {e}"
|
| 52 |
|
|
@@ -71,7 +58,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 71 |
|
| 72 |
agent = CodeAgent(
|
| 73 |
model=model,
|
| 74 |
-
tools=[final_answer,
|
| 75 |
max_steps=6,
|
| 76 |
verbosity_level=1,
|
| 77 |
grammar=None,
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
from Gradio_UI import GradioUI
|
| 8 |
|
| 9 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
|
|
|
| 25 |
|
| 26 |
#Following my creation.
|
| 27 |
@tool
|
| 28 |
+
def sum_numbers_test(a:float, b:float)-> float:
|
| 29 |
+
"""A tool that sum two numbers.
|
| 30 |
Args:
|
| 31 |
+
a: A float number
|
| 32 |
+
b: A float number
|
| 33 |
"""
|
| 34 |
try:
|
| 35 |
+
sum=a+b
|
| 36 |
+
return sum
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
except Exception as e:
|
| 38 |
return f"I could not complete the task. I got this error: {e}"
|
| 39 |
|
|
|
|
| 58 |
|
| 59 |
agent = CodeAgent(
|
| 60 |
model=model,
|
| 61 |
+
tools=[final_answer, sum_numbers_test], ## add your tools here (don't remove final answer)
|
| 62 |
max_steps=6,
|
| 63 |
verbosity_level=1,
|
| 64 |
grammar=None,
|