Omnitopia commited on
Commit
11db231
·
verified ·
1 Parent(s): 482d749

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -11,17 +11,21 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
11
  # --- Basic Agent Definition ---
12
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
13
 
14
- from smolagents import CodeAgent
15
- from smolagents.models import OpenAIChat
16
- from my_tools import my_tool_list # 你需要新建/补全这个模块和列表
17
 
18
  class BasicAgent:
19
  def __init__(self):
20
  api_key = os.getenv("OPENAI_API_KEY") # ← 这里自动读取环境变量
21
  if not api_key:
22
  raise ValueError("OPENAI_API_KEY not set in environment variables!")
23
- self.model = OpenAIChat(model="gpt-4o", api_key=api_key)
24
- self.agent = CodeAgent(model=self.model, tools=my_tool_list, max_steps=6)
 
 
 
 
 
25
 
26
 
27
  def __call__(self, question: str) -> str:
 
11
  # --- Basic Agent Definition ---
12
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
13
 
14
+ from smolagents import CodeAgent, LiteLLMModel
15
+ from my_tools import my_tool_list
 
16
 
17
  class BasicAgent:
18
  def __init__(self):
19
  api_key = os.getenv("OPENAI_API_KEY") # ← 这里自动读取环境变量
20
  if not api_key:
21
  raise ValueError("OPENAI_API_KEY not set in environment variables!")
22
+ model = LiteLLMModel(
23
+ model_id="gpt-4o",
24
+ api_key=api_key
25
+ )
26
+
27
+ self.agent = CodeAgent(model=model, tools=my_tool_list, max_steps=6)
28
+
29
 
30
 
31
  def __call__(self, question: str) -> str: