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

Model Provider add Google Gemini failed! #4571

Closed
4 tasks done
betashepherd opened this issue May 22, 2024 · 4 comments
Closed
4 tasks done

Model Provider add Google Gemini failed! #4571

betashepherd opened this issue May 22, 2024 · 4 comments
Labels
🐞 bug Something isn't working

Comments

@betashepherd
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

  1. Settings
  2. Model Provider
  3. Google Gemini setup
  4. Enter API key for Google Gemini and click Save.
docker-nginx-1       | 172.24.0.1 - - [22/May/2024:03:52:05 +0000] "POST /console/api/workspaces/current/model-providers/google HTTP/1.1" 400 77 "http://localhost/app/32d0e4f1-3b5b-4954-96be-b46df7db943a/configuration" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36" "-"

✔️ Expected Behavior

save Google Gemini success

❌ Actual Behavior

save Google Gemini failed

Copy link

dosubot bot commented May 22, 2024

To resolve the issue of receiving a 400 error when trying to add Google Gemini as a Model Provider in your self-hosted Dify instance (version 0.6.8, running on Docker), follow these steps:

  1. Verify API Key Configuration:
    Ensure that you have correctly configured the API key in the google.yaml file. The configuration should include the google_api_key as shown below:

    provider: google
    label:
      en_US: Google
    description:
      en_US: Google's Gemini model.
      zh_Hans: 谷歌提供的 Gemini 模型.
    icon_small:
      en_US: icon_s_en.svg
    icon_large:
      en_US: icon_l_en.svg
    background: "#FCFDFF"
    help:
      title:
        en_US: Get your API Key from Google
        zh_Hans: 从 Google 获取 API Key
      url:
        en_US: https://ai.google.dev/
    supported_model_types:
      - llm
    configurate_methods:
      - predefined-model
    provider_credential_schema:
      credential_form_schemas:
        - variable: google_api_key
          label:
            en_US: API Key
          type: secret-input
          required: true
          placeholder:
            zh_Hans: 在此输入您的 API Key
            en_US: Enter your API Key
  2. Check API Key Validity:
    Make sure that the API key you are using is valid and has the necessary permissions. If the API key is incorrect or missing, it could result in a 400 error.

  3. Enable Debug Mode for More Information:
    To get more detailed logs and understand why the setup is failing, you can enable debug mode in your Docker setup. Here are the steps to enable debug mode:

    • Locate the docker-compose.yaml file.

    • Modify the LOG_LEVEL, DEBUG, and FLASK_DEBUG environment variables for the api service:

      version: '3'
      services:
        api:
          image: langgenius/dify-api:0.6.8
          restart: always
          environment:
            LOG_LEVEL: DEBUG
            DEBUG: true
            FLASK_DEBUG: true
            # other environment variables...
    • Save the changes and restart the Docker services:

      docker-compose down
      docker-compose up -d
  4. Review Specific Error Messages:
    The specific error messages or codes that can be returned by the Google Gemini setup API endpoint in Dify include:

    • app_unavailable - "App unavailable, please check your app configurations." (Code: 400)
    • not_completion_app - "Please check if your Completion app mode matches the right API route." (Code: 400)
    • not_chat_app - "Please check if your app mode matches the right API route." (Code: 400)
    • not_workflow_app - "Please check if your Workflow app mode matches the right API route." (Code: 400)
    • provider_not_initialize - "No valid model provider credentials found. Please go to Settings -> Model Provider to complete your provider credentials." (Code: 400)
    • provider_quota_exceeded - "Your quota for Dify Hosted Model Provider has been exhausted. Please go to Settings -> Model Provider to complete your own provider credentials." (Code: 400)
    • model_currently_not_support - "Dify Hosted OpenAI trial currently not support the GPT-4 model." (Code: 400)
    • completion_request_error - "Completion request failed." (Code: 400)

    These error messages can help you pinpoint the exact issue.

By following these steps, you should be able to resolve the 400 error and successfully add Google Gemini as a Model Provider in your Dify instance. If the issue persists, please provide more details from the debug logs for further assistance.

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 22, 2024
@crazywoola
Copy link
Member

You need to ensure you computer can access google gemini service as expected, typically it should behind a proxy.

@betashepherd
Copy link
Author

Yes, I can use Gemini no trouble with network, I am using an openwrt wifi router.
For https://gemini.google.com/app works.

@betashepherd
Copy link
Author

thks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants