AstrBot icon indicating copy to clipboard operation
AstrBot copied to clipboard

[Bug]AstrBot使用RagFlow作为服务提供商失败

Open qedight opened this issue 1 year ago • 2 comments

发生了什么

我在Linux上部署了AstrBot,想要使用RagFlow作为服务提供商,使用知识库为QQ机器人提供服务,我在查找issues里的解决方案时,看到了使用openai兼容来连接RagFlow的,但是只提到了修改API Base URL,当保存后,提示提供商适配器失败:报api_key的错误。 这里还需要写OpenAI的key吗?如果写了,那么调用RagFlow是将对话的结果再用open处理一遍吗?

如何复现?

  1. 选择左侧服务提供商-->新增服务提供商-->第一个OpenAI-->根据RagFlow填写API Base URL。然后保存,提示api_key的错误。

Image

AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

AstrBot版本:v3.5.5 部署方式:Linux docker 提供商:OpenAI格式,API Base URL改为RagFlow相关的,其他没动。 消息平台适配器:napcat

操作系统

Linux

报错日志

[09:19:32] [Core] [ERRO] [provider.manager:296]: 实例化 openai_chat_completion(openai) 提供商适配器失败:The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable [09:22:18] [Core] [INFO] [provider.manager:141]: 载入 openai_chat_completion(openai) 服务提供商 ... [09:22:18] [Core] [ERRO] [provider.manager:295]: Traceback (most recent call last): File "/AstrBot/astrbot/core/provider/manager.py", line 270, in load_provider inst = provider_metadata.cls_type( File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 63, in init self.client = AsyncOpenAI( File "/usr/local/lib/python3.10/site-packages/openai/_client.py", line 349, in init raise OpenAIError( openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable

[09:22:18] [Core] [ERRO] [provider.manager:296]: 实例化 openai_chat_completion(openai) 提供商适配器失败:The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable

你愿意提交 PR 吗?

  • [x] 是的,我愿意提交 PR!

Code of Conduct

  • [x] 我已阅读并同意遵守该项目的 行为准则。

qedight avatar Apr 30 '25 01:04 qedight

Image

参照RAGFlow官方文档,是需要key的

推荐阅读: https://ragflow.io/docs/dev/acquire_ragflow_api_key

Raven95676 avatar May 10 '25 09:05 Raven95676

Image

参照RAGFlow官方文档,是需要key的

推荐阅读: https://ragflow.io/docs/dev/acquire_ragflow_api_key

谢谢啦,刚配置成功,之前对ragflow不是很了解,所以这个key没发现

qedight avatar Jun 03 '25 03:06 qedight