WaelDahech commited on
Commit
f10af38
·
1 Parent(s): 315ec07

add openai req

Browse files
Files changed (1) hide show
  1. app.py +10 -35
app.py CHANGED
@@ -54,59 +54,34 @@ openai_api_key = os.getenv("OPENAI_API_KEY")
54
  # 3) build the Smolagents model
55
  from smolagents import OpenAIServerModel
56
 
 
57
  model = OpenAIServerModel(
58
  model_id="gpt-4o", # or "gpt-3.5-turbo", etc.
59
  api_base="https://api.openai.com/v1", # OpenAI’s standard endpoint
60
  api_key=openai_api_key # your secret key
61
  ) # :contentReference[oaicite:1]{index=1}
62
 
 
63
  # 4) create a CodeAgent powered by that model
64
  from smolagents import CodeAgent, DuckDuckGoSearchTool, FinalAnswerTool
65
 
66
  OpenAIAgent = CodeAgent(
67
  tools=[ wikipedia_search],
68
  model=model,
69
- max_steps=6,
70
- verbosity_level=1,
71
- grammar=None,
72
- planning_interval=None,
73
- name=None,
74
- description=None,
75
- prompt_templates=None
76
  )
77
  # you can allow extra imports if needed:
78
  # additional_authorized_imports=["requests", "bs4"],
79
 
80
- MyAgent = CodeAgent(
81
- model= InferenceClientModel(model_id="Qwen/Qwen2.5-Coder-32B-Instruct"),
82
- tools=[],
83
- max_steps=6,
84
- verbosity_level=1,
85
- grammar=None,
86
- planning_interval=None,
87
- name=None,
88
- description=None,
89
- prompt_templates=None
90
- )
91
-
92
- class BasicAgent:
93
- def __init__(self):
94
- print("BasicAgent initialized.")
95
- def __call__(self, question: str) -> str:
96
- print(f"Agent received question (first 50 chars): {question[:50]}...")
97
- fixed_answer = "This is a default answer."
98
- print(f"Agent returning fixed answer: {fixed_answer}")
99
- return fixed_answer
100
 
101
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
102
- class BasicAgent:
103
- def __init__(self):
104
- print("BasicAgent initialized.")
105
- def __call__(self, question: str) -> str:
106
- print(f"Agent received question (first 50 chars): {question[:50]}...")
107
- fixed_answer = "This is a default answer."
108
- print(f"Agent returning fixed answer: {fixed_answer}")
109
- return fixed_answer
110
 
111
  def run_and_submit_all( profile: gr.OAuthProfile | None):
112
  """
 
54
  # 3) build the Smolagents model
55
  from smolagents import OpenAIServerModel
56
 
57
+
58
  model = OpenAIServerModel(
59
  model_id="gpt-4o", # or "gpt-3.5-turbo", etc.
60
  api_base="https://api.openai.com/v1", # OpenAI’s standard endpoint
61
  api_key=openai_api_key # your secret key
62
  ) # :contentReference[oaicite:1]{index=1}
63
 
64
+ print("model loaded")
65
  # 4) create a CodeAgent powered by that model
66
  from smolagents import CodeAgent, DuckDuckGoSearchTool, FinalAnswerTool
67
 
68
  OpenAIAgent = CodeAgent(
69
  tools=[ wikipedia_search],
70
  model=model,
71
+ # max_steps=6,
72
+ # verbosity_level=1,
73
+ # grammar=None,
74
+ # planning_interval=None,
75
+ # name=None,
76
+ # description=None,
77
+ # prompt_templates=None
78
  )
79
  # you can allow extra imports if needed:
80
  # additional_authorized_imports=["requests", "bs4"],
81
 
82
+ print("agent loaded")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
 
 
 
 
 
 
 
 
85
 
86
  def run_and_submit_all( profile: gr.OAuthProfile | None):
87
  """