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

set openai key failed #2619

Closed
3 tasks done
LinightKira opened this issue Feb 29, 2024 · 4 comments
Closed
3 tasks done

set openai key failed #2619

LinightKira opened this issue Feb 29, 2024 · 4 comments
Labels
🐞 bug Something isn't working 🤔 cant-reproduce This issue can not be reproduced

Comments

@LinightKira
Copy link

Self Checks

  • 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).
  • Pleas do not modify this template :) and fill in all the required fields.

Dify version

0.5.7

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

微信图片_20240229104016 报错地址: post:http://localhost/console/api/workspaces/current/model-providers/openai 无法设置openai key ,返回400 连接错误

✔️ Expected Behavior

set sucess

❌ Actual Behavior

400 ,connection error

@LinightKira LinightKira added the 🐞 bug Something isn't working label Feb 29, 2024
Copy link

dosubot bot commented Feb 29, 2024

🤖

Hey @LinightKira! Long time no see, hope you've been well. Let's dive into this issue you're facing.

Based on the information you've provided and the similar issues I found in the repository, it seems like the error you're encountering might be due to a misconfiguration or a connectivity issue.

Here are some steps you can follow to troubleshoot this issue:

  1. Ensure that all services the API depends on are running correctly. You can check this by using docker ps.
  2. Verify that all necessary environment variables are correctly set in the docker-compose.yaml file.
  3. Check if the database and Redis are correctly set up and accessible with the provided credentials.
  4. Ensure that both the API and worker services are running correctly and using the same configurations.
  5. If accessing the API from outside Docker, ensure the API's port is exposed in the docker-compose.yaml file.
  6. Provide the OpenAI key in the openai_api_key field in the provider_credential_schema or model_credential_schema section of the openai.yaml file, replacing the placeholder with the actual key.

You can refer to this issue for more details.

Additionally, check the connectivity to api.openai.com and try performing the same action at https://cloud.dify.ai, which is the cloud version with the latest code.

If the problem persists, could you please provide more details about the exact error message returned with the 400 status code when trying to set the OpenAI key? This could help in identifying the root cause of the issue.

Regarding your question about the exact endpoint in the codebase that handles the request to set the OpenAI key, the OpenAI key is utilized within the _invocation_params property of the EnhanceOpenAI class. This property constructs a dictionary that includes the "api_key" field, which is set to self.openai_api_key. This indicates that the OpenAI key is expected to be a property of the EnhanceOpenAI instance, likely set during its initialization or through environment variables. The class itself does not contain a specific endpoint or method solely for setting the OpenAI key. You can refer to this code for more details.

I hope this helps! If you have any other questions or need further clarification, feel free to ask.

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.

If you want to continue the conversation, start your reply with @dosu-bot.

@crazywoola crazywoola added the 🤔 cant-reproduce This issue can not be reproduced label Feb 29, 2024
@crazywoola
Copy link
Member

Connection error means you need to have access api.openai.com

@LinightKira
Copy link
Author

Connection error means you need to have access api.openai.com

电脑开了全局代理,访问openai 很通畅

@151819880412
Copy link

@LinightKira 我也遇到这个问题,使用阿里的到通义千问正常

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 🤔 cant-reproduce This issue can not be reproduced
Projects
None yet
Development

No branches or pull requests

3 participants