Skip to content

Conversation

kristapratico
Copy link
Owner

Example:

TODO we probably don't want people importing from lib. Ideally we could import from openai.types.azure...

import openai
from openai.types.chat import ChatCompletionSystemMessageParam, ChatCompletionUserMessageParam
from openai.lib.azure_types import (
    AzureCognitiveSearchChatExtensionConfiguration,
    AzureCognitiveSearchChatExtensionParameters,
    OnYourDataConnectionStringAuthenticationOptions
)


client = openai.AzureOpenAI()

messages = [
    ChatCompletionSystemMessageParam(role="system", content="You are a helpful assistant."),
    ChatCompletionUserMessageParam(role="user", content="How is Azure machine learning different than Azure OpenAI?")
]

response = client.chat.completions.create(
    model="gpt-4",
    messages=messages,
    extra_body={
        "data_sources": [
            AzureCognitiveSearchChatExtensionConfiguration(
                type="AzureCognitiveSearch",
                parameters=AzureCognitiveSearchChatExtensionParameters(
                    index_name="index-name",
                    endpoint="endpoint",
                    authentication=OnYourDataConnectionStringAuthenticationOptions(
                        type="ConnectionString",
                        connection_string="connection-string"
                    )
                )
            )
        ],
    }
)

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.

1 participant