Spaces:
Sleeping
Sleeping
native azure model
Browse files
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, DuckDuckGoSearchTool,
|
| 6 |
|
| 7 |
# (Keep Constants as is)
|
| 8 |
# --- Constants ---
|
|
@@ -11,21 +11,15 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 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(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
search_tool = DuckDuckGoSearchTool()
|
| 30 |
visit_page_tool = VisitWebpageTool()
|
| 31 |
interpreter_tool = PythonInterpreterTool()
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
import requests
|
| 4 |
import pandas as pd
|
| 5 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, AzureOpenAIServerModel, VisitWebpageTool, PythonInterpreterTool, FinalAnswerTool
|
| 6 |
|
| 7 |
# (Keep Constants as is)
|
| 8 |
# --- Constants ---
|
|
|
|
| 11 |
# --- Basic Agent Definition ---
|
| 12 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 13 |
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
class BasicAgent:
|
| 16 |
def __init__(self):
|
| 17 |
+
model = AzureOpenAIServerModel(
|
| 18 |
+
"gpt-4o",
|
| 19 |
+
azure_endpoint=os.environ["AZURE_ENDPOINT"],
|
| 20 |
+
api_version=os.environ["OPENAI_API_VERSION"],
|
| 21 |
+
api_key=os.environ["OPENAI_API_KEY"]
|
| 22 |
+
)
|
| 23 |
search_tool = DuckDuckGoSearchTool()
|
| 24 |
visit_page_tool = VisitWebpageTool()
|
| 25 |
interpreter_tool = PythonInterpreterTool()
|