lcapriles commited on
Commit
57ae792
·
verified ·
1 Parent(s): 81917a3

Initial commit

Browse files
Files changed (1) hide show
  1. app.py +24 -2
app.py CHANGED
@@ -4,6 +4,11 @@ import requests
4
  import inspect
5
  import pandas as pd
6
 
 
 
 
 
 
7
  # (Keep Constants as is)
8
  # --- Constants ---
9
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
@@ -12,12 +17,29 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
12
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
13
  class BasicAgent:
14
  def __init__(self):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  print("BasicAgent initialized.")
 
16
  def __call__(self, question: str) -> str:
17
  print(f"Agent received question (first 50 chars): {question[:50]}...")
18
  fixed_answer = "This is a default answer."
19
- print(f"Agent returning fixed answer: {fixed_answer}")
20
- return fixed_answer
 
21
 
22
  def run_and_submit_all( profile: gr.OAuthProfile | None):
23
  """
 
4
  import inspect
5
  import pandas as pd
6
 
7
+ from PIL import Image
8
+ from typing import Optional, Tuple
9
+ from smolagents import CodeAgent,DuckDuckGoSearchTool,InferenceClientModel,VisitWebpageTool,tool,AzureOpenAIServerModel
10
+
11
+
12
  # (Keep Constants as is)
13
  # --- Constants ---
14
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
 
17
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
18
  class BasicAgent:
19
  def __init__(self):
20
+ print("BasicAgent initializing...")
21
+ prompt= ()
22
+ model = AzureOpenAIServerModel(
23
+ azure_endpoint=os.environ.get("AZendpoint"),
24
+ api_version=os.environ.get("api_version"),
25
+ api_key=os.environ.get("api_key"),
26
+ model_id=os.environ.get("model")
27
+ )
28
+ agent = CodeAgent(
29
+ model=model,
30
+ system_prompt = """ be rude""",
31
+ tools=[DuckDuckGoSearchTool(), VisitWebpageTool()],
32
+ additional_authorized_imports=["pandas"],
33
+ max_steps=20,
34
+ )
35
  print("BasicAgent initialized.")
36
+
37
  def __call__(self, question: str) -> str:
38
  print(f"Agent received question (first 50 chars): {question[:50]}...")
39
  fixed_answer = "This is a default answer."
40
+ answer = agent.run(question)
41
+ print(f"Agent returning answer: {answer}")
42
+ return answer
43
 
44
  def run_and_submit_all( profile: gr.OAuthProfile | None):
45
  """