Spaces:
Runtime error
Runtime error
Commit ·
8140fce
1
Parent(s): 81917a3
Minimal working version
Browse filesFiles changed (3)
- .gitignoreAdded+1
- app.py+30-7
- requirements.txt+5-2
1.env12344567891011121314151617181920212211122324252627181920282930313233343536373839404142434445461 unmodified line4849502851525354import osimport gradio as grimport requestsimport inspectimport pandas as pd
import osimport dotenv
dotenv.load_dotenv()from smolagents import CodeAgent, DuckDuckGoSearchTool, VisitWebpageTool, AzureOpenAIServerModel
MODEL = AzureOpenAIServerModel( model_id=os.environ.get("AZURE_OPENAI_DEPLOYMENT"), azure_endpoint=os.environ.get("AZURE_OPENAI_ENDPOINT"), api_key=os.environ.get("AZURE_OPENAI_KEY"), api_version=os.environ.get("AZURE_OPENAI_VERSION"))
# (Keep Constants as is)# --- Constants ---DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
# --- Basic Agent Definition ---# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------class BasicAgent: def __init__(self): print("BasicAgent initialized.") def __call__(self, question: str) -> str: print(f"Agent received question (first 50 chars): {question[:50]}...") fixed_answer = "This is a default answer." print(f"Agent returning fixed answer: {fixed_answer}") return fixed_answer
# Initialize the search tool search_tool = DuckDuckGoSearchTool(max_results=20) web_tool = VisitWebpageTool()
agent = CodeAgent( model=MODEL, tools=[search_tool, web_tool] )
response = agent.run( question )
print(f"Agent returning fixed answer: {response}") return response
def run_and_submit_all( profile: gr.OAuthProfile | None): """1 unmodified line and displays the results. """ # --- Determine HF Space Runtime URL and Repo URL --- space_id = os.getenv("SPACE_ID") # Get the SPACE_ID for sending link to the code space_id = os.getenv("SPACE_ID", "maxim-saplin/HF_Agent_Course_Final_Assignment") # Get the SPACE_ID for sending link to the code
if profile: username= f"{profile.username}"1212345gradiorequestsgradio[oauth]requestssmolagents[openai]duckduckgo-searchmarkdownify.gitignoreAdded+1
app.py+30-7
requirements.txt+5-2