-
Notifications
You must be signed in to change notification settings - Fork 8
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
Not able to connect with Azure OpenAI #1
Comments
Sorry for making you wait. I do not have access to the Azure OpenAI service, still tried to implement a fix, though. Can you confirm whether updating the package and passing in the |
Hey I was able to get this to work but with one catch. openai.api_type = "azure"
openai.api_key = "..."
openai.api_base = "https://blabla.openai.azure.com"
openai.api_version = "2023-07-01-preview"
engine = "blabla"
conversation = openai_functions.Conversation(model="gpt-4", engine=engine) There was an issue with Azure OpenAI implementation not returning the content field in messages. I had to make the below modification. Let me know if I'm using it wrong or should I open a PR for this. # openai_types.py
class Message:
# more stuff
def __init__(
self,
message: MessageType | str,
role: Literal["system", "user", "assistant"] = "user",
):
if isinstance(message, str):
if role == "assistant": # We have to split this up because of mypy
self.message: MessageType = {"role": role, "content": message}
else:
self.message = {
"role": role,
"content": message,
}
else:
# NEW CODE
if "content" not in message:
message["content"] = None
# END NEW CODE
self.message = message Sorry for sharing code in this barbaric manner I'm super busy at the moment. |
Thanks a lot for your time! I've just published this fix, it should be working out of the box. |
I am trying to utilize this library using Azure OpenAI. Here I am not directly connecting to OpenAI; here I have created a deployment in Azure, and with the help of that, I am connecting to OpenAI. Whenever i am connecting through Azure, I need to provide details like "openai.api_key", "openai.api_base", "openai.api_type," and engine/deployment_id, which were created in Azure Openai, to be passed to the "openai.ChatCompletion.create() method.
"Conversation" model asking for "model_id", Here I am trying to pass Azure "deployment_id" or "engine" but it's not working. I have passed "model_name" as well, but still it's showing me an error as "InvalidRequestError: Must provide an 'engine' or 'deployment_id' parameter to create a ." I have attached the error screenshot.
Could you please make it work for the Azure OpenAI engine as well?
The text was updated successfully, but these errors were encountered: