Skip to content

Conversation

@jackmpcollins
Copy link
Owner

Builds on PR #64 from @kaaloo

I add api_type to the magentic settings so that it can be set globally and also on individual prompts. Also added a note to the README.

@kaaloo Could you test that this branch works for your use case please? You should be able to set env var MAGENTIC_OPENAI_API_TYPE="azure" or set this in code with

@prompt(
    "This is a test",
    model=OpenaiChatModel("gpt-4", api_type="azure")
)
def do_test() -> str:
    ...

From https://github.com/openai/openai-python/tree/9f828cb1ea7c22a6388fcd71b5de1a0dde3a9a9f#microsoft-azure-openai I see there's also an azure_endpoint parameter which it might also make sense to add.

@jackmpcollins jackmpcollins self-assigned this Nov 24, 2023
@kaaloo
Copy link

kaaloo commented Nov 24, 2023

Hi @jackmpcollins , I like the way you solved this and it works great but like you say it could maybe be improved. There are a couple of environment variables I had to setup for this to work. Being able to pass these values in the prompt parameters could be more readable.

os.environ["AZURE_OPENAI_API_KEY"] = "*****"
os.environ["AZURE_OPENAI_ENDPOINT"] = "*****"
# may change in the future
# https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#rest-api-versioning
os.environ["OPENAI_API_VERSION"] = "2023-09-01-preview"

@jackmpcollins
Copy link
Owner Author

Thanks! I'll release this now so you are unblocked.

Re the other variables, do you need to change these per prompt? If not then I think it's fine to leave them set at the very top-level as env vars.

@kaaloo
Copy link

kaaloo commented Nov 27, 2023

Thanks so much @jackmpcollins ! I updated to 0.11.1 and everything's working well. 👏🏼 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants