Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,7 +19,7 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
| 21 |
|
| 22 |
-
def
|
| 23 |
# API endpoint
|
| 24 |
url = f"https://api.dictionaryapi.dev/api/v2/entries/en/{word}"
|
| 25 |
|
|
@@ -28,6 +28,7 @@ def get_word_info_from_API(word):
|
|
| 28 |
|
| 29 |
if response.status_code == 200: # Successful request
|
| 30 |
data = response.json()
|
|
|
|
| 31 |
return data[0] # Return the first entry
|
| 32 |
else:
|
| 33 |
print(f"Error: Unable to fetch data for '{word}'. Status code: {response.status_code}")
|
|
@@ -76,14 +77,14 @@ def parse_word_info(word):
|
|
| 76 |
return ret_str
|
| 77 |
|
| 78 |
@tool
|
| 79 |
-
def
|
| 80 |
"""A tool that fetches the detailed meaning of the given word.Each definition includes multiple meanings, sentence examples, synonyms and antonyms.
|
| 81 |
Args:
|
| 82 |
word: A string that represents a valid word in quotes (e.g. "Fabulous").
|
| 83 |
|
| 84 |
"""
|
| 85 |
|
| 86 |
-
word_info =
|
| 87 |
if not word_info:
|
| 88 |
return "Sorry I was unable to find this word in my thesarus"
|
| 89 |
else:
|
|
@@ -129,7 +130,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 129 |
|
| 130 |
agent = CodeAgent(
|
| 131 |
model=model,
|
| 132 |
-
tools=[
|
| 133 |
max_steps=6,
|
| 134 |
verbosity_level=1,
|
| 135 |
grammar=None,
|
|
|
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
| 21 |
|
| 22 |
+
def get_info_from_API(word):
|
| 23 |
# API endpoint
|
| 24 |
url = f"https://api.dictionaryapi.dev/api/v2/entries/en/{word}"
|
| 25 |
|
|
|
|
| 28 |
|
| 29 |
if response.status_code == 200: # Successful request
|
| 30 |
data = response.json()
|
| 31 |
+
print("Successful API call")
|
| 32 |
return data[0] # Return the first entry
|
| 33 |
else:
|
| 34 |
print(f"Error: Unable to fetch data for '{word}'. Status code: {response.status_code}")
|
|
|
|
| 77 |
return ret_str
|
| 78 |
|
| 79 |
@tool
|
| 80 |
+
def get_info_dictionary(word:str) -> str:
|
| 81 |
"""A tool that fetches the detailed meaning of the given word.Each definition includes multiple meanings, sentence examples, synonyms and antonyms.
|
| 82 |
Args:
|
| 83 |
word: A string that represents a valid word in quotes (e.g. "Fabulous").
|
| 84 |
|
| 85 |
"""
|
| 86 |
|
| 87 |
+
word_info = get_info_from_API(word)
|
| 88 |
if not word_info:
|
| 89 |
return "Sorry I was unable to find this word in my thesarus"
|
| 90 |
else:
|
|
|
|
| 130 |
|
| 131 |
agent = CodeAgent(
|
| 132 |
model=model,
|
| 133 |
+
tools=[get_info_dictionary, final_answer], ## add your tools here (don't remove final answer)
|
| 134 |
max_steps=6,
|
| 135 |
verbosity_level=1,
|
| 136 |
grammar=None,
|