From 6a8a189203d87eb032547e9d0ba600c1287cd13a Mon Sep 17 00:00:00 2001 From: Vineeth Voruganti <13438633+VVoruganti@users.noreply.github.com> Date: Wed, 16 Oct 2024 12:03:10 -0400 Subject: [PATCH] fix(agent) migrate from azure to base openai --- agent/agent/chain.py | 18 +++++++----------- api/.env.template | 7 ++----- bot/.env.template | 7 ++----- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/agent/agent/chain.py b/agent/agent/chain.py index d30901c..6c328af 100644 --- a/agent/agent/chain.py +++ b/agent/agent/chain.py @@ -1,7 +1,7 @@ from os import getenv from typing import List -from openai import AzureOpenAI, completions +from openai import OpenAI from dotenv import load_dotenv from honcho import Honcho @@ -30,13 +30,9 @@ def __init__( model_config = ConfigDict(arbitrary_types_allowed=True) - openai = AzureOpenAI( - api_key=getenv("AZURE_OPENAI_API_KEY", "placeholder"), - azure_endpoint=getenv("AZURE_OPENAI_ENDPOINT", "placeholder"), - api_version=getenv("AZURE_OPENAI_API_VERSION", "2024-02-01"), - ) + openai = OpenAI() - model = getenv("AZURE_OPENAI_DEPLOYMENT", "placeholder") + model = "gpt-4o" class ThinkCall(HonchoCall): @@ -84,14 +80,14 @@ def history(self) -> str: def call(self): response = self.openai.chat.completions.create( - model=getenv("AZURE_OPENAI_DEPLOYMENT", "placeholder"), + model=self.model, messages=[self.template(), {"role": "user", "content": self.user_input}], ) return response.choices[0].message def stream(self): completion = self.openai.chat.completions.create( - model=getenv("AZURE_OPENAI_DEPLOYMENT", "placeholder"), + model=self.model, messages=[self.template(), {"role": "user", "content": self.user_input}], stream=True, ) @@ -136,14 +132,14 @@ def history(self) -> List[dict]: def call(self): response = self.openai.chat.completions.create( - model=getenv("AZURE_OPENAI_DEPLOYMENT", "placeholder"), + model=self.model, messages=self.template(), ) return response.choices[0].message def stream(self): completion = self.openai.chat.completions.create( - model=getenv("AZURE_OPENAI_DEPLOYMENT", "placeholder"), + model=self.model, messages=self.template(), stream=True, ) diff --git a/api/.env.template b/api/.env.template index 8cad23a..ac79b78 100644 --- a/api/.env.template +++ b/api/.env.template @@ -1,8 +1,5 @@ -# Azure Mirascope Keys -AZURE_OPENAI_ENDPOINT= -AZURE_OPENAI_API_KEY= -AZURE_OPENAI_API_VERSION= -AZURE_OPENAI_DEPLOYMENT= +# OpenAI Keys +OPENAI_API_KEY= # NextJS & fastAPI URL=http://localhost:3000 diff --git a/bot/.env.template b/bot/.env.template index 5b3103f..fdfea59 100644 --- a/bot/.env.template +++ b/bot/.env.template @@ -1,8 +1,5 @@ -# Azure Mirascope Keys -AZURE_OPENAI_ENDPOINT= -AZURE_OPENAI_API_KEY= -AZURE_OPENAI_API_VERSION= -AZURE_OPENAI_DEPLOYMENT= +# OpenAI Keys +OPENAI_API_KEY= # Discord Settings BOT_TOKEN=