Spaces:
Sleeping
Sleeping
| import yaml | |
| import os | |
| from smolagents import GradioUI, CodeAgent, HfApiModel | |
| # Get current directory path | |
| CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) | |
| from tools.web_search import DuckDuckGoSearchTool as WebSearch | |
| from tools.visit_webpage import VisitWebpageTool as VisitWebpage | |
| from tools.suggest_exercise import SimpleTool as SuggestExercise | |
| from tools.plan_diet import SimpleTool as PlanDiet | |
| from tools.schedule_sleep import SimpleTool as ScheduleSleep | |
| from tools.calculate_hydration import SimpleTool as CalculateHydration | |
| from tools.plan_recovery import SimpleTool as PlanRecovery | |
| from tools.workout_suggestion import WorkoutSuggestionTool as WorkoutSuggestion | |
| from tools.final_answer import FinalAnswerTool as FinalAnswer | |
| model = HfApiModel( | |
| model_id='Qwen/Qwen2.5-Coder-32B-Instruct', | |
| provider=None, | |
| ) | |
| web_search = WebSearch() | |
| visit_webpage = VisitWebpage() | |
| suggest_exercise = SuggestExercise() | |
| plan_diet = PlanDiet() | |
| schedule_sleep = ScheduleSleep() | |
| calculate_hydration = CalculateHydration() | |
| plan_recovery = PlanRecovery() | |
| workout_suggestion = WorkoutSuggestion() | |
| final_answer = FinalAnswer() | |
| with open(os.path.join(CURRENT_DIR, "prompts.yaml"), 'r') as stream: | |
| prompt_templates = yaml.safe_load(stream) | |
| agent = CodeAgent( | |
| model=model, | |
| tools=[web_search, visit_webpage, suggest_exercise, plan_diet, schedule_sleep, calculate_hydration, plan_recovery, workout_suggestion], | |
| managed_agents=[], | |
| max_steps=10, | |
| verbosity_level=2, | |
| grammar=None, | |
| planning_interval=None, | |
| name=None, | |
| description=None, | |
| max_print_outputs_length=None, | |
| prompt_templates=prompt_templates | |
| ) | |
| if __name__ == "__main__": | |
| GradioUI(agent).launch() | |