Skip to content

Azure Example #123

@kmaurinjones

Description

@kmaurinjones

Hi there, love the idea of the package! I'm looking to use my Azure instance to run this and I can't seem to find any examples of how to do it in the docs and haven't been able to get something working.

This is the starting point of my Azure-based LLM usage. How can I go from this to using this package with one of the models I have hosted there?

Thanks in advance.


from openai import AzureOpenAI
client = AzureOpenAI(
    azure_endpoint=my_endpoint,
    api_key=my_api_key,
    api_version=my_api_version
)

message_text = [{"role":"system","content":"You are an AI assistant that helps people find information."}]

completion = client.chat.completions.create(
    model="model_name",
    messages=message_text,
    ...
)

response_str = completion.choices[0].message.content.strip()

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions