Skip to content

[BUG] in check_consensus function (OpenRouter) #19

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

Open
wow-hub opened this issue Apr 28, 2025 · 2 comments
Open

[BUG] in check_consensus function (OpenRouter) #19

wow-hub opened this issue Apr 28, 2025 · 2 comments
Labels
bug: API Issues related to API connections. API连接相关问题 bug: fixed Bug fixed in latest update. 此错误已在最新更新中解决 bug: R Issues in the R package. R包中的错误或问题

Comments

@wow-hub
Copy link

wow-hub commented Apr 28, 2025

你好,我是一名中国的用户,我在=== Starting check_consensus function ===环节反复遇到错误。

1、我使用OpenRouter 作为统一接入点;

2、这是我的原始代码:
consensus_results <- interactive_consensus_annotation(
input = scRNA_harmony_marker2,
tissue_name = "human osteosarcoma tissues", # 直接提供组织的自然语言描述
models = c(
"anthropic/claude-3-7-sonnet-20250219",
"meta-llama/llama-3-70b-instruct",
"google/gemini-2.5-pro-preview-03-25"
),
api_keys = list(
openrouter = "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"
),
top_gene_count = 10,
controversy_threshold = 0.7,
entropy_threshold = 1,
max_discussion_rounds = 1,
consensus_check_model = "anthropic/claude-3-7-sonnet-20250219",
cache_dir = cache_dir
)

3、我的问题在于每次都存在共识检查失败:
(1)报错如下:
[2025-04-28 14:22:18] Trying model qwen-max-2025-01-25 for consensus check
[2025-04-28 14:22:18] No API key available for qwen-max-2025-01-25, skipping
[2025-04-28 14:22:18] Trying model claude-3-5-sonnet-latest for consensus check
[2025-04-28 14:22:18] No API key available for claude-3-5-sonnet-latest, skipping
[2025-04-28 14:22:18] Trying model gpt-4o for consensus check
[2025-04-28 14:22:18] Attempt 1 of 3 with model gpt-4o
[2025-04-28 14:22:18] Starting OpenAI API request with model: gpt-4o
[2025-04-28 14:22:18] Using model: gpt-4o
[2025-04-28 14:22:18] Processing 1 chunks of input
[2025-04-28 14:22:18] Processing chunk 1 of 1
[2025-04-28 14:22:18] Sending API request...
[2025-04-28 14:22:19] ERROR: OpenAI API request failed: You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.
[2025-04-28 14:22:19] ERROR on gpt-4o attempt 1: OpenAI API request failed: You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.
[2025-04-28 14:22:19] Waiting for 5 seconds before next attempt...
[2025-04-28 14:22:24] Attempt 2 of 3 with model gpt-4o
[2025-04-28 14:22:24] Starting OpenAI API request with model: gpt-4o
[2025-04-28 14:22:24] Using model: gpt-4o
[2025-04-28 14:22:24] Processing 1 chunks of input
[2025-04-28 14:22:24] Processing chunk 1 of 1
[2025-04-28 14:22:24] Sending API request...
[2025-04-28 14:22:25] ERROR: OpenAI API request failed: You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.

(2)然而我明明设置了 consensus_check_model = "anthropic/claude-3-7-sonnet-20250219",为什么无法按照我设置的模型进行共识检查呢?已经更换多种模型依然无法有效解决。

似乎,程序总是按照GPT 4o作为共识检查模型。你明白的,这在中国大陆不是很容易。而且OpenRouter用一条api集成多种模型,对中国大陆的用户非常方便。

所以您能解决这一问题吗?或者您还需要我提供更多详细信息吗?谢谢您!

@wow-hub wow-hub changed the title [BUG] [BUG] in check_consensus function (OpenRouter) Apr 28, 2025
@cafferychen777
Copy link
Owner

问题已解决 / Problem Solved

中文回复

非常感谢您报告这个问题!我们已经修复了 OpenRouter 模型在共识检查阶段的处理问题,修复已经合并到 dev 分支。

问题原因
check_consensus 函数中,当使用 OpenRouter 模型(如 "anthropic/claude-3-7-sonnet-20250219")作为 consensus_check_model 时,系统无法正确识别它是 OpenRouter 模型,而是尝试将其解析为原生提供商模型。例如,对于 "anthropic/claude-3-7-sonnet-20250219",系统会尝试将其识别为 Anthropic 提供商的模型,而不是 OpenRouter 提供商的模型。

解决方案

  1. 修改了 get_provider.R 函数,使其能够正确识别带有斜杠("/")的 OpenRouter 模型名称
  2. 增强了 check_consensus.R 函数,使其能够正确处理带有提供商前缀的 OpenRouter 模型
  3. 更新了 facilitate_cluster_discussion.Rconsensus_annotation.R 文件,确保 consensus_check_model 参数在所有相关函数调用中正确传递

我的错误
我必须承认,这个问题是由于我在开发过程中主要混合使用 OpenRouter 和其他原生提供商(如直接使用 OpenAI、Anthropic 等),而没有测试全部使用 OpenRouter 作为统一接入点的情况。这导致我在测试中没有发现这个问题。对此我深表歉意,感谢您的报告帮助我们改进了代码。

现在,您应该可以正常使用 OpenRouter 模型进行共识检查了。如果您仍然遇到任何问题,请随时告诉我们。

English Reply

Thank you very much for reporting this issue! We have fixed the problem with OpenRouter model handling during the consensus check phase, and the fix has been merged into the dev branch.

Root Cause:
In the check_consensus function, when using an OpenRouter model (such as "anthropic/claude-3-7-sonnet-20250219") as the consensus_check_model, the system failed to correctly identify it as an OpenRouter model. Instead, it tried to parse it as a native provider model. For example, for "anthropic/claude-3-7-sonnet-20250219", the system would try to identify it as an Anthropic provider model, not an OpenRouter provider model.

Solution:

  1. Modified the get_provider.R function to correctly identify OpenRouter models by detecting the "/" character in model names
  2. Enhanced the check_consensus.R function to properly handle OpenRouter models with provider prefixes
  3. Updated the facilitate_cluster_discussion.R and consensus_annotation.R files to ensure the consensus_check_model parameter is properly passed through all relevant function calls

My Mistake:
I must admit that this issue occurred because during development, I primarily used a mix of OpenRouter and other native providers (like direct OpenAI, Anthropic, etc.), and didn't test the scenario where OpenRouter is used exclusively as a unified access point. This prevented me from discovering this issue during testing. I sincerely apologize for this oversight, and thank you for your report which helped us improve the code.

Now, you should be able to use OpenRouter models for consensus checking without issues. If you still encounter any problems, please don't hesitate to let us know.

@cafferychen777 cafferychen777 added bug: R Issues in the R package. R包中的错误或问题 bug: API Issues related to API connections. API连接相关问题 bug: fixed Bug fixed in latest update. 此错误已在最新更新中解决 labels Apr 28, 2025
@wow-hub
Copy link
Author

wow-hub commented Apr 28, 2025

非常感谢您,问题已经完美地解决了,为您杰出的工作点赞!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: API Issues related to API connections. API连接相关问题 bug: fixed Bug fixed in latest update. 此错误已在最新更新中解决 bug: R Issues in the R package. R包中的错误或问题
Projects
None yet
Development

No branches or pull requests

2 participants