peterdamn's picture
add azureopenai option
5b7c4fe
raw
history blame contribute delete
745 Bytes
import os
from dotenv import load_dotenv
from smolagents import CodeAgent, DuckDuckGoSearchTool
from smolagents.models import AzureOpenAIServerModel
load_dotenv()
if __name__ == "__main__":
# model = HfApiModel()
model = AzureOpenAIServerModel(
model_id="gpt-4o",
api_key=os.environ.get("AZURE_OPENAI_API_KEY"),
api_version=os.environ.get("OPENAI_API_VERSION"),
azure_endpoint=os.environ.get("AZURE_OPENAI_API_ENDPOINT"),
# custom_role_conversions={"system": "assistant", "tool-call": "assistant", "tool-response": "user"}
)
agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=model, add_base_tools=True)
agent.run("Could you give me the 118th number in the Fibonacci sequence?")