GatinhoEducado commited on
Commit
33c68cc
·
verified ·
1 Parent(s): 81917a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -1
app.py CHANGED
@@ -3,6 +3,7 @@ import gradio as gr
3
  import requests
4
  import inspect
5
  import pandas as pd
 
6
 
7
  # (Keep Constants as is)
8
  # --- Constants ---
@@ -12,10 +13,47 @@ 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
 
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel, load_tool, tool
7
 
8
  # (Keep Constants as is)
9
  # --- Constants ---
 
13
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
14
  class BasicAgent:
15
  def __init__(self):
16
+
17
+ self.model = HfApiModel(
18
+ max_tokens=3000,
19
+ temperature=0.5,
20
+ model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
21
+ #model_id='deepseek-ai/DeepSeek-R1-Distill-Qwen-32B',
22
+ #model_id='mistralai/Mistral-7B-Instruct-v0.3',
23
+ #model_id='https://wxknx1kg971u7k1n.us-east-1.aws.endpoints.huggingface.cloud',
24
+ #model_id="google/gemma-2-9b-it",
25
+ custom_role_conversions=None,
26
+ token=os.getenv('hf_token'),
27
+ )
28
+
29
+ self.agent = CodeAgent(
30
+ model=self.model,
31
+ tools=[
32
+ final_answer,
33
+ #image_generation_tool,
34
+ #get_stock_data_baostock,
35
+ #weather_data_tool
36
+ ], ## add your tools here (don't remove final answer)
37
+ max_steps=4,
38
+ verbosity_level=1,
39
+ grammar=None,
40
+ planning_interval=3,
41
+ name=None,
42
+ description=None,
43
+ #prompt_templates=prompt_templates,
44
+ add_base_tools=True,
45
+ additional_authorized_imports=["time", "numpy", "pandas","datetime"],
46
+ )
47
+
48
  print("BasicAgent initialized.")
49
+
50
+
51
  def __call__(self, question: str) -> str:
52
  print(f"Agent received question (first 50 chars): {question[:50]}...")
53
+
54
+ fixed_answer = agent.run(question)
55
+
56
+ #fixed_answer = "This is a default answer."
57
  print(f"Agent returning fixed answer: {fixed_answer}")
58
  return fixed_answer
59