Omnitopia commited on
Commit
867682a
·
verified ·
1 Parent(s): ee1cea4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -17,8 +17,12 @@ from my_tools import my_tool_list # 你需要新建/补全这个模块和列表
17
 
18
  class BasicAgent:
19
  def __init__(self):
20
- model = OpenAIChat(model="gpt-4.1")
21
- self.agent = CodeAgent(model=model, tools=my_tool_list, max_steps=6)
 
 
 
 
22
 
23
  def __call__(self, question: str) -> str:
24
  print(f"Agent received question: {question[:80]}...")
 
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:
28
  print(f"Agent received question: {question[:80]}...")