ajac-zero commited on
Commit
2ad644d
·
1 Parent(s): 1f5f5e1

add azure openai

Browse files
Files changed (2) hide show
  1. app.py +14 -2
  2. requirements.txt +2 -1
app.py CHANGED
@@ -2,7 +2,7 @@ import os
2
  import gradio as gr
3
  import requests
4
  import pandas as pd
5
- from smolagents import CodeAgent, InferenceClientModel, DuckDuckGoSearchTool
6
 
7
  # (Keep Constants as is)
8
  # --- Constants ---
@@ -10,10 +10,22 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
10
 
11
  # --- Basic Agent Definition ---
12
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  class BasicAgent:
15
  def __init__(self):
16
- model = InferenceClientModel("deepseek-ai/DeepSeek-V3")
17
  search_tool = DuckDuckGoSearchTool()
18
 
19
  self.agent = CodeAgent(
 
2
  import gradio as gr
3
  import requests
4
  import pandas as pd
5
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, OpenAIServerModel
6
 
7
  # (Keep Constants as is)
8
  # --- Constants ---
 
10
 
11
  # --- Basic Agent Definition ---
12
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
13
+ #
14
+ class AzureOpenAIServerModel(OpenAIServerModel):
15
+ def __init__(self, model_id: str):
16
+ super().__init__(model_id=model_id)
17
+ # if we've reached this point, it means the openai package is available (baseclass check) so go ahead and import it
18
+ import openai
19
+
20
+ self.client = openai.AzureOpenAI(
21
+ api_key=os.environ["OPENAI_API_KEY"],
22
+ api_version=os.environ["OPENAI_API_VERSION"],
23
+ azure_endpoint=os.environ["AZURE_ENDPOINT"]
24
+ )
25
 
26
  class BasicAgent:
27
  def __init__(self):
28
+ model = AzureOpenAIServerModel("deepseek-ai/DeepSeek-V3")
29
  search_tool = DuckDuckGoSearchTool()
30
 
31
  self.agent = CodeAgent(
requirements.txt CHANGED
@@ -1,4 +1,5 @@
1
  gradio
2
  requests
3
  smolagents
4
- duckduckgo-search
 
 
1
  gradio
2
  requests
3
  smolagents
4
+ duckduckgo-search
5
+ openai