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

Does dify now support azure openai gpt 4o? #4609

Closed
4 tasks done
lx1054331851 opened this issue May 23, 2024 · 2 comments
Closed
4 tasks done

Does dify now support azure openai gpt 4o? #4609

lx1054331851 opened this issue May 23, 2024 · 2 comments

Comments

@lx1054331851
Copy link

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.8

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

I can not add azure openai gpt 4o model.

✔️ Expected Behavior

No response

❌ Actual Behavior

No response

Copy link

dosubot bot commented May 23, 2024

Yes, Dify version 0.6.8, self-hosted with Docker, supports the Azure OpenAI GPT-4o model.

To add the Azure OpenAI GPT-4o model, follow these steps:

  1. Obtain the API Key: Get the API key from the Azure OpenAI Service.

  2. Configure Dify:

    • Go to Settings > Model Provider in the Dify interface.
    • Select Azure OpenAI Service and enter the API key.

This will integrate the Azure OpenAI GPT-4o model into your Dify setup. The model supports various features such as agent thought, vision, multi-tool call, and stream tool call, and allows for customizable parameters like temperature, top_p, presence_penalty, frequency_penalty, and max_tokens.

Additionally, you can validate the credentials and invoke the model using the following Python code snippet:

import os
from core.model_runtime.model_providers.azure_openai.llm.llm import AzureOpenAILargeLanguageModel

model = AzureOpenAILargeLanguageModel()

# Validate credentials
model.validate_credentials(
    model='gpt-4o',
    credentials={
        'openai_api_base': os.environ.get('AZURE_OPENAI_API_BASE'),
        'openai_api_key': os.environ.get('AZURE_OPENAI_API_KEY'),
        'base_model_name': 'gpt-4o'
    }
)

# Invoke the model
result = model.invoke(
    model='gpt-4o',
    credentials={
        'openai_api_base': os.environ.get('AZURE_OPENAI_API_BASE'),
        'openai_api_key': os.environ.get('AZURE_OPENAI_API_KEY'),
        'base_model_name': 'gpt-4o'
    },
    prompt_messages=[
        UserPromptMessage(
            content='Hello World!'
        )
    ],
    model_parameters={
        'temperature': 0.0,
        'max_tokens': 100
    },
    stream=False,
    user="abc-123"
)

assert isinstance(result, LLMResult)
assert len(result.message.content) > 0

This code snippet demonstrates how to validate the credentials and invoke the Azure OpenAI GPT-4o model within Dify. For more detailed information, you can refer to the Dify documentation and the relevant Dify repository files.

Details

Sources


About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

@dosubot dosubot bot added the 🐞 bug Something isn't working label May 23, 2024
@brightwang-igg
Copy link

d5a33a0
Pull the new code from the main branch to support Azure GPT-4o."

@crazywoola crazywoola removed the 🐞 bug Something isn't working label May 23, 2024
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

No branches or pull requests

3 participants