Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Use of LLM's Deployed in Azure Open AI #20

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion promptimize/prompt_cases.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from typing import Any, Callable, List, Optional, Union

from langchain.llms import OpenAI
from langchain.llms import OpenAI, AzureOpenAI
from langchain.callbacks import get_openai_callback

from box import Box
Expand Down Expand Up @@ -69,6 +69,15 @@ def get_prompt_executor(self):
model_name = os.environ.get("OPENAI_MODEL") or "text-davinci-003"
openai_api_key = os.environ.get("OPENAI_API_KEY")
self.prompt_executor_kwargs = {"model_name": model_name}
if os.environ.get("OPENAI_API_TYPE") == "azure":
if not os.environ.get("AZURE_DEPLOYMENT_NAME"):
raise Exception(
"Environment variable with key name 'AZURE_DEPLOYMENT_NAME'"
"is required when OPEN_API_TYPE=='azure'."
)
return AzureOpenAI(
model_name=model_name, deployment_name=os.environ.get("AZURE_DEPLOYMENT_NAME")
)
return OpenAI(model_name=model_name, openai_api_key=openai_api_key)

def execute_prompt(self, prompt_str):
Expand Down