Skip to content

Commit

Permalink
fix(agent) migrate from azure to base openai
Browse files Browse the repository at this point in the history
  • Loading branch information
VVoruganti committed Oct 16, 2024
1 parent 4f8be70 commit 6a8a189
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
18 changes: 7 additions & 11 deletions agent/agent/chain.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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,
)
Expand Down
7 changes: 2 additions & 5 deletions api/.env.template
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 2 additions & 5 deletions bot/.env.template
Original file line number Diff line number Diff line change
@@ -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=
Expand Down

0 comments on commit 6a8a189

Please sign in to comment.