Spaces:
Build error
Build error
Removed my_env from repository
Browse files- .gitignore +96 -0
- .gradio/certificate.pem +31 -0
- agent.json +3 -1
- app.py +108 -13
- requirements.txt +3 -0
.gitignore
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Byte-compiled / cached files
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.py[cod]
|
| 4 |
+
*$py.class
|
| 5 |
+
|
| 6 |
+
# Virtual environment
|
| 7 |
+
venv/
|
| 8 |
+
.env/
|
| 9 |
+
env/
|
| 10 |
+
.venv/
|
| 11 |
+
pip-log.txt
|
| 12 |
+
pip-delete-this-directory.txt
|
| 13 |
+
my_env/
|
| 14 |
+
# Distribution / packaging
|
| 15 |
+
build/
|
| 16 |
+
dist/
|
| 17 |
+
*.egg-info/
|
| 18 |
+
*.egg
|
| 19 |
+
.eggs/
|
| 20 |
+
|
| 21 |
+
# Installer logs
|
| 22 |
+
pip-log.txt
|
| 23 |
+
|
| 24 |
+
# Unit test / coverage reports
|
| 25 |
+
htmlcov/
|
| 26 |
+
.tox/
|
| 27 |
+
.nox/
|
| 28 |
+
.coverage
|
| 29 |
+
.coverage.*
|
| 30 |
+
.cache
|
| 31 |
+
nosetests.xml
|
| 32 |
+
coverage.xml
|
| 33 |
+
*.cover
|
| 34 |
+
*.py,cover
|
| 35 |
+
.hypothesis/
|
| 36 |
+
|
| 37 |
+
# Jupyter Notebook
|
| 38 |
+
.ipynb_checkpoints/
|
| 39 |
+
|
| 40 |
+
# PyCharm
|
| 41 |
+
.idea/
|
| 42 |
+
|
| 43 |
+
# VSCode
|
| 44 |
+
.vscode/
|
| 45 |
+
*.code-workspace
|
| 46 |
+
|
| 47 |
+
# Pytest cache
|
| 48 |
+
.pytest_cache/
|
| 49 |
+
|
| 50 |
+
# mypy
|
| 51 |
+
.mypy_cache/
|
| 52 |
+
.dmypy.json
|
| 53 |
+
dmypy.json
|
| 54 |
+
|
| 55 |
+
# Pyre
|
| 56 |
+
.pyre/
|
| 57 |
+
|
| 58 |
+
# Pylint
|
| 59 |
+
.pylint.d/
|
| 60 |
+
|
| 61 |
+
# Bandit
|
| 62 |
+
.bandit/
|
| 63 |
+
|
| 64 |
+
# Local and sensitive files
|
| 65 |
+
.envrc
|
| 66 |
+
*.env
|
| 67 |
+
.env.local
|
| 68 |
+
secrets.json
|
| 69 |
+
|
| 70 |
+
# Logs and debugging files
|
| 71 |
+
logs/
|
| 72 |
+
*.log
|
| 73 |
+
debug.log
|
| 74 |
+
|
| 75 |
+
# Temporary files
|
| 76 |
+
*.swp
|
| 77 |
+
*.swo
|
| 78 |
+
*.bak
|
| 79 |
+
*.tmp
|
| 80 |
+
*.orig
|
| 81 |
+
|
| 82 |
+
# Docker
|
| 83 |
+
docker-compose.override.yml
|
| 84 |
+
|
| 85 |
+
# Machine learning and large files
|
| 86 |
+
*.h5
|
| 87 |
+
*.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4nLCgdNbOhdjsnvzqvHu7Ur
|
| 25 |
+
TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC
|
| 26 |
+
jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc
|
| 27 |
+
oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq
|
| 28 |
+
4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA
|
| 29 |
+
mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d
|
| 30 |
+
emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=
|
| 31 |
+
-----END CERTIFICATE-----
|
agent.json
CHANGED
|
@@ -48,6 +48,8 @@
|
|
| 48 |
"queue",
|
| 49 |
"time",
|
| 50 |
"collections",
|
| 51 |
-
"re"
|
|
|
|
|
|
|
| 52 |
]
|
| 53 |
}
|
|
|
|
| 48 |
"queue",
|
| 49 |
"time",
|
| 50 |
"collections",
|
| 51 |
+
"re",
|
| 52 |
+
"requests"
|
| 53 |
+
|
| 54 |
]
|
| 55 |
}
|
app.py
CHANGED
|
@@ -1,16 +1,24 @@
|
|
| 1 |
-
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
-
|
|
|
|
| 8 |
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 |
-
|
| 13 |
-
|
|
|
|
| 14 |
"""A tool that does nothing yet
|
| 15 |
Args:
|
| 16 |
arg1: the first argument
|
|
@@ -18,6 +26,79 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 18 |
"""
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 23 |
"""A tool that fetches the current local time in a specified timezone.
|
|
@@ -34,28 +115,42 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
final_answer = FinalAnswerTool()
|
| 38 |
|
| 39 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
| 40 |
-
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
| 41 |
|
| 42 |
model = HfApiModel(
|
| 43 |
-
max_tokens=2096,
|
| 44 |
-
temperature=0.5,
|
| 45 |
-
|
| 46 |
-
|
|
|
|
| 47 |
)
|
| 48 |
|
| 49 |
|
| 50 |
# Import tool from Hub
|
| 51 |
-
image_generation_tool = load_tool(
|
|
|
|
| 52 |
|
| 53 |
with open("prompts.yaml", 'r') as stream:
|
| 54 |
prompt_templates = yaml.safe_load(stream)
|
| 55 |
-
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[final_answer],
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
@@ -66,4 +161,4 @@ agent = CodeAgent(
|
|
| 66 |
)
|
| 67 |
|
| 68 |
|
| 69 |
-
GradioUI(agent).launch()
|
|
|
|
| 1 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
import os
|
| 8 |
+
from huggingface_hub import InferenceClient
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
+
from dotenv import load_dotenv
|
| 11 |
+
load_dotenv()
|
| 12 |
+
|
| 13 |
+
hf_token = os.getenv("HF_TOKEN")
|
| 14 |
|
| 15 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 16 |
+
|
| 17 |
+
|
| 18 |
@tool
|
| 19 |
+
# it's import to specify the return type
|
| 20 |
+
def my_custom_tool(arg1: str, arg2: int) -> str:
|
| 21 |
+
# Keep this format for the description / args / args description but feel free to modify the tool
|
| 22 |
"""A tool that does nothing yet
|
| 23 |
Args:
|
| 24 |
arg1: the first argument
|
|
|
|
| 26 |
"""
|
| 27 |
return "What magic will you build ?"
|
| 28 |
|
| 29 |
+
|
| 30 |
+
def get_weather_report_at_coordinates(coordinates, date_time):
|
| 31 |
+
# Dummy function, returns a list of [temperature in °C, risk of rain on a scale 0-1, wave height in m]
|
| 32 |
+
return [28.0, 0.35, 0.85]
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def convert_location_to_coordinates(location):
|
| 36 |
+
# Returns dummy coordinates
|
| 37 |
+
return [3.3, -42.0]
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
@tool
|
| 41 |
+
def get_weather_api(location: str, date_time: str) -> str:
|
| 42 |
+
"""
|
| 43 |
+
Returns the weather report.
|
| 44 |
+
|
| 45 |
+
Args:
|
| 46 |
+
location: the name of the place that you want the weather for.
|
| 47 |
+
date_time: the date and time for which you want the report.
|
| 48 |
+
"""
|
| 49 |
+
lon, lat = convert_location_to_coordinates(location)
|
| 50 |
+
date_time = datetime.strptime(date_time)
|
| 51 |
+
return str(get_weather_report_at_coordinates((lon, lat), date_time))
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
user_data = {}
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def update_personality(name: str, personality: str) -> str:
|
| 58 |
+
"""Asks the user about his personality before predicting his future
|
| 59 |
+
"""
|
| 60 |
+
user_data[name] = personality
|
| 61 |
+
return f"Great! Thanks {name} I ve updates your personality traits, now ask me about your future."
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
'''
|
| 65 |
+
I would like to use an AI model that takes the name and personality and predicts number of kids, career etc '''
|
| 66 |
+
|
| 67 |
+
client = InferenceClient(model="Qwen/Qwen2.5-Coder-32B-Instruct")
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
@tool
|
| 71 |
+
def predict_future_with_model(name: str, personality: str) -> str:
|
| 72 |
+
"""
|
| 73 |
+
|
| 74 |
+
Returns:
|
| 75 |
+
str: A fun and futuristic AI-generated prediction.
|
| 76 |
+
Args:
|
| 77 |
+
name: The user's name.
|
| 78 |
+
personality: A description of the user's personality traits.
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
"""
|
| 82 |
+
|
| 83 |
+
prompt = f"""
|
| 84 |
+
Given the name '{name}' and personality traits '{personality}', generate a fun, futuristic prediction for their life.
|
| 85 |
+
|
| 86 |
+
Your response should include:
|
| 87 |
+
- A career path
|
| 88 |
+
- A major life event
|
| 89 |
+
- The number of kids they might have
|
| 90 |
+
- A quirky or funny twist related to their personality
|
| 91 |
+
|
| 92 |
+
Keep it engaging, futuristic, and a little humorous!
|
| 93 |
+
"""
|
| 94 |
+
|
| 95 |
+
try:
|
| 96 |
+
response = client.text_generation(prompt, max_new_tokens=100)
|
| 97 |
+
return f"🔮 **Future Prediction for {name}:**\n{response}"
|
| 98 |
+
except Exception as e:
|
| 99 |
+
return f"Oops! I couldn't predict the future this time. Error: {str(e)}"
|
| 100 |
+
|
| 101 |
+
|
| 102 |
@tool
|
| 103 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 104 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 115 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 116 |
|
| 117 |
|
| 118 |
+
def tell_joke() -> str:
|
| 119 |
+
"""stored jokes.
|
| 120 |
+
"""
|
| 121 |
+
jokes = ["Why do we tell actors to 'break a leg?' Because every play has a cast.",
|
| 122 |
+
"I told my wife she should embrace her mistakes. She gave me a hug.",
|
| 123 |
+
"I'm reading a book on the history of glue. I just can't seem to put it down.",
|
| 124 |
+
"I would tell you a joke about an elevator, but it's an uplifting experience.",
|
| 125 |
+
"I told my computer I needed a break and now it won't stop sending me vacation ads.",
|
| 126 |
+
"I used to play piano by ear, but now I use my hands"]
|
| 127 |
+
return random.choice(jokes)
|
| 128 |
+
|
| 129 |
+
|
| 130 |
final_answer = FinalAnswerTool()
|
| 131 |
|
| 132 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
| 133 |
+
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
| 134 |
|
| 135 |
model = HfApiModel(
|
| 136 |
+
max_tokens=2096,
|
| 137 |
+
temperature=0.5,
|
| 138 |
+
# it is possible that this model may be overloaded
|
| 139 |
+
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
|
| 140 |
+
custom_role_conversions=None,
|
| 141 |
)
|
| 142 |
|
| 143 |
|
| 144 |
# Import tool from Hub
|
| 145 |
+
image_generation_tool = load_tool(
|
| 146 |
+
"agents-course/text-to-image", trust_remote_code=True)
|
| 147 |
|
| 148 |
with open("prompts.yaml", 'r') as stream:
|
| 149 |
prompt_templates = yaml.safe_load(stream)
|
| 150 |
+
|
| 151 |
agent = CodeAgent(
|
| 152 |
model=model,
|
| 153 |
+
tools=[final_answer], # add your tools here (don't remove final answer)
|
| 154 |
max_steps=6,
|
| 155 |
verbosity_level=1,
|
| 156 |
grammar=None,
|
|
|
|
| 161 |
)
|
| 162 |
|
| 163 |
|
| 164 |
+
GradioUI(agent).launch()
|
requirements.txt
CHANGED
|
@@ -3,3 +3,6 @@ smolagents
|
|
| 3 |
requests
|
| 4 |
duckduckgo_search
|
| 5 |
pandas
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
requests
|
| 4 |
duckduckgo_search
|
| 5 |
pandas
|
| 6 |
+
huggingface_hub
|
| 7 |
+
random
|
| 8 |
+
python-dotenv
|