Spaces:
Sleeping
Sleeping
| from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool | |
| import datetime | |
| import requests | |
| import os | |
| import pytz # Had to give it permission in Code agent | |
| from agents.tools import tools | |
| from check_endpoint import is_huggingface_endpoint | |
| from agents.prompts import load_prompts | |
| from Gradio_UI import GradioUI | |
| my_id = os.getenv("QWEN_URI") | |
| # Test the endpoint | |
| if is_huggingface_endpoint(my_id): | |
| print("This is a Hugging Face Inference Endpoint.") | |
| else: | |
| print("This is NOT a Hugging Face Inference Endpoint.") | |
| sys.exit(1) # Stop execution if the endpoint is not valid | |
| ''' | |
| model = HfApiModel( | |
| max_tokens=2096, | |
| temperature=0.5, | |
| model_id= my_id, | |
| custom_role_conversions=None, | |
| ) | |
| ''' | |
| ''' | |
| model = LiteLLMModel( | |
| model_id="gemini/gemini-2.0-flash-exp", | |
| max_tokens=2096, | |
| temperature=0.6, | |
| api_key=os.getenv("LITELLM_API_KEY") | |
| ) | |
| ''' | |
| ''' | |
| # Load prompts | |
| combined_prompts = load_prompts() | |
| agent = CodeAgent( | |
| model=model, | |
| tools=[final_answer, polite_guard, web_search, get_the_current_time_in_timezone ], ## add your tools here (don't remove final answer) | |
| max_steps=6, | |
| verbosity_level=3, | |
| grammar=None, | |
| planning_interval=None, | |
| name="Content Agent", | |
| description="Evaluates whether text is polite or impolite. ", | |
| prompt_templates=combined_prompts, | |
| additional_authorized_imports=["pytz"] | |
| ) | |
| GradioUI(agent).launch() | |
| ''' |