9jini commited on
Commit
34d075e
·
verified ·
1 Parent(s): bb786a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -16,18 +16,17 @@ class BasicAgent:
16
  def __init__(self):
17
  print("BasicAgent initialized.")
18
 
19
- # 初始化 OpenAIServerModel 实例,用于与 DeepSeek 的语言模型交互
20
  model = OpenAIServerModel(
21
- model_id="deepseek-chat", # 使用 DeepSeek 的聊天模型
22
  api_key="sk-04da63f756c9468182d278f52e33ad15",
23
- api_base="https://api.deepseek.com", # 传入 API 密钥进行认证
24
  )
25
- # 初始化搜索工具,允许 Agent 执行网络搜索来查找信息
26
  search_tool = DuckDuckGoSearchTool()
27
- # 初始化 CodeAgent 实例,这是执行代码理解和生成任务的主要代理
28
  self.agent = CodeAgent(
29
- model = model, # 指定使用的语言模型
30
- tools=[search_tool] # 为代理提供搜索工具,增强其获取信息的能力
31
  )
32
  def __call__(self, question: str) -> str:
33
  """
@@ -39,10 +38,10 @@ class BasicAgent:
39
  Returns:
40
  str: Agent 生成的回答
41
  """
42
- print(f"Agent received question (first 50 chars): {question[:50]}...") # 打印接收到的问题(前50个字符)用于调试
43
- fixed_answer = self.agent.run(question) # 调用 CodeAgent 的 run 方法处理问题并生成回答
44
- print(f"Agent returning fixed answer: {fixed_answer}") # 打印生成的回答用于调试
45
- return fixed_answer # 返回 CodeAgent 生成的回答
46
 
47
  def run_and_submit_all( profile: gr.OAuthProfile | None):
48
  """
 
16
  def __init__(self):
17
  print("BasicAgent initialized.")
18
 
 
19
  model = OpenAIServerModel(
20
+ model_id="deepseek-chat",
21
  api_key="sk-04da63f756c9468182d278f52e33ad15",
22
+ api_base="https://api.deepseek.com",
23
  )
24
+
25
  search_tool = DuckDuckGoSearchTool()
26
+
27
  self.agent = CodeAgent(
28
+ model = model,
29
+ tools=[search_tool]
30
  )
31
  def __call__(self, question: str) -> str:
32
  """
 
38
  Returns:
39
  str: Agent 生成的回答
40
  """
41
+ print(f"Agent received question (first 50 chars): {question[:50]}...")
42
+ fixed_answer = self.agent.run(question)
43
+ print(f"Agent returning fixed answer: {fixed_answer}")
44
+ return fixed_answer
45
 
46
  def run_and_submit_all( profile: gr.OAuthProfile | None):
47
  """