Yago Bolivar commited on
Commit
43a0598
·
1 Parent(s): 640d1fd

feat: switch to OpenAIServerModel for improved API integration

Browse files
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -1,4 +1,5 @@
1
- from smolagents import CodeAgent, HfApiModel
 
2
  from Gradio_UI import GradioUI
3
  import yaml
4
  import os
@@ -25,13 +26,20 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
25
 
26
  # --- Basic Agent Definition ---
27
 
28
- # Configure the Language Model
29
- model = HfApiModel(
30
- max_tokens=2096,
31
- temperature=0.5,
32
- # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud',
33
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
34
- custom_role_conversions=None,
 
 
 
 
 
 
 
35
  )
36
 
37
  # Instantiate Tools
 
1
+ from smolagents import CodeAgent, HfApiModel, OpenAIServerModel
2
+
3
  from Gradio_UI import GradioUI
4
  import yaml
5
  import os
 
26
 
27
  # --- Basic Agent Definition ---
28
 
29
+ # # Configure the Language Model. Overloaded or not available
30
+ # model = HfApiModel(
31
+ # max_tokens=2096,
32
+ # temperature=0.5,
33
+ # # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud/', # nope
34
+ # # model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
35
+ # custom_role_conversions=None,
36
+ # )
37
+
38
+ # Try to use OpenAI API
39
+ model = OpenAIServerModel(
40
+ model_id="gpt-4o",
41
+ api_base="https://api.openai.com/v1",
42
+ api_key=os.environ["OPENAI_API_KEY"],
43
  )
44
 
45
  # Instantiate Tools