langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
51.18k stars 7.37k forks source link

openai 自定义模型无法通过 #3332

Closed bincooo closed 7 months ago

bincooo commented 7 months ago

Self Checks

Dify version

0.6.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

RT

API Base 填写了中转地址,并且该中转地址的 /v1/models 也有自定义model的返回; 但是在添加模型时报错:Base model coze not found

Screenshot 2024-04-11 at 00 45 54 Screenshot 2024-04-11 at 00 47 53

✔️ Expected Behavior

No response

❌ Actual Behavior

No response

dosubot[bot] commented 7 months ago

Hey @bincooo, great to see you diving into the world of AI with Dify again! Running into a bit of a puzzle, I see? Let's tackle this together.

To address the "Base model coze not found" error when adding a custom model in Dify v0.6.1 with a self-hosted Docker setup, ensure the following:

  1. Proxy Configuration: Confirm your proxy correctly routes requests to OpenAI's API and lists your custom model at the /v1/models endpoint. This step is crucial for Dify to recognize your model.

  2. API Base URL Update: In api/config.py, ensure HOSTED_OPENAI_API_BASE points to your proxy. If necessary, directly set it in the code:

    self.HOSTED_OPENAI_API_BASE = 'https://your-proxy-address.com'
  3. Custom Model in Environment Variables: If your model is a paid one, add it to HOSTED_OPENAI_PAID_MODELS:

    HOSTED_OPENAI_PAID_MODELS=gpt-4,gpt-4-turbo-preview,custom-coze
  4. Restart Dify: After updates, restart Dify to apply changes.

  5. Debugging: If issues persist, check proxy logs for errors related to API requests.

For detailed configurations, refer to the api/config.py and openai_api_compatible.yaml files in the Dify codebase. These documents outline how to configure Dify for custom OpenAI models, including API keys, endpoint URLs, and model parameters.

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.
bincooo commented 7 months ago

在docker-compose.yaml中配置HOSTED_OPENAI_API_BASE是否有效?

bincooo commented 7 months ago

? 咋关了

JokerQyou commented 6 months ago

? 咋关了

用英文,你提交issue的时候模板里面已经写了"I confirm that I am using English to submit this report",非英文的issue会直接关闭。

qianfeiqianlan commented 5 months ago

可以直接修改源码里面 OpenAI client 初始化的地方跳过证书校验,可能是代理的证书生成的有问题

https://stackoverflow.com/questions/72858917/python-requests-throws-sslcertverificationerror-with-lets-encrypt-certificates

https://github.com/langgenius/dify/discussions/4600