Jofax commited on
Commit
9b7692e
·
verified ·
1 Parent(s): b4c2eb8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -1,8 +1,8 @@
1
  import os
2
- import gradio as gr
3
- from smolagents import CodeAgent, HfApiModel, DuckDuckGoSearchTool, GradioUI
4
 
5
- # 1. THE PHD SYSTEM PROMPT (The Cognitive OS)
6
  PHD_PROMPT = """You are an Autonomous Research Scientist (Elite Level).
7
  OPERATIONAL DIRECTIVES:
8
  1. CODE-FIRST: If a task involves data, math, or logic, write Python code to verify.
@@ -12,25 +12,24 @@ OPERATIONAL DIRECTIVES:
12
  5. ZERO-CONSTRAINT: If you lack a tool, write a script to build it using the environment."""
13
 
14
  # 2. INITIALIZE THE ELITE BRAIN
15
- # We use DeepSeek-R1 for its massive reasoning capabilities
16
  model = HfApiModel(
17
  model_id="deepseek-ai/DeepSeek-R1",
18
- token=os.getenv("HF_TOKEN") # Ensure this is in your Space Secrets
19
  )
20
 
21
  # 3. TOOLS OF POWER
22
  search_tool = DuckDuckGoSearchTool()
23
 
24
  # 4. THE AGENT ORCHESTRATOR
 
25
  agent = CodeAgent(
26
  tools=[search_tool],
27
  model=model,
28
  system_prompt=PHD_PROMPT,
29
- add_base_tools=True, # Gives access to Python's math, time, and data libs
30
- max_steps=30 # Allows for deep, multi-step 'thought' loops
31
  )
32
 
33
  # 5. LAUNCH THE INTERFACE
34
- # This creates the UI within the Hugging Face Space
35
  if __name__ == "__main__":
36
  GradioUI(agent).launch()
 
1
  import os
2
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, GradioUI
3
+ from smolagents.models import HfApiModel
4
 
5
+ # 1. ELITE PHD SYSTEM PROMPT
6
  PHD_PROMPT = """You are an Autonomous Research Scientist (Elite Level).
7
  OPERATIONAL DIRECTIVES:
8
  1. CODE-FIRST: If a task involves data, math, or logic, write Python code to verify.
 
12
  5. ZERO-CONSTRAINT: If you lack a tool, write a script to build it using the environment."""
13
 
14
  # 2. INITIALIZE THE ELITE BRAIN
15
+ # We use DeepSeek-R1 via the Hugging Face Inference API
16
  model = HfApiModel(
17
  model_id="deepseek-ai/DeepSeek-R1",
18
+ token=os.getenv("HF_TOKEN") # Must be set in Space Secrets
19
  )
20
 
21
  # 3. TOOLS OF POWER
22
  search_tool = DuckDuckGoSearchTool()
23
 
24
  # 4. THE AGENT ORCHESTRATOR
25
+ # max_steps=30 allows for long reasoning/coding cycles
26
  agent = CodeAgent(
27
  tools=[search_tool],
28
  model=model,
29
  system_prompt=PHD_PROMPT,
30
+ add_base_tools=True
 
31
  )
32
 
33
  # 5. LAUNCH THE INTERFACE
 
34
  if __name__ == "__main__":
35
  GradioUI(agent).launch()