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

最近通过lss233/chatgpt-mirai-qq-bot项目使用API时出现了empty text parameter #83

Closed
HoshinoDesu opened this issue Nov 3, 2024 · 10 comments · Fixed by #86
Closed
Assignees

Comments

@HoshinoDesu
Copy link

这可能是什么问题导致的?是近一段时间突然出现的,在这之前调用完全正常
[GoogleGenerativeAI Error]: Error fetching from google -> [400 Bad Request] Unable to submit request because it has an empty text parameter. Add a value to the parameter and try again. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/gemini

@HoshinoDesu HoshinoDesu changed the title 最近通过lss233/chatgpt-mirai-qq-bot项目使用API时出现了以下报错 最近通过lss233/chatgpt-mirai-qq-bot项目使用API时出现了empty text parameter Nov 3, 2024
@zuisong
Copy link
Owner

zuisong commented Nov 3, 2024

可以附上请求参数吗?

@zuisong zuisong self-assigned this Nov 3, 2024
@HoshinoDesu
Copy link
Author

可以附上请求参数吗?

我不太熟悉这个项目,不是很清楚请求参数之类的,但是可能是和上下文有关,因为第一句可以正常回答,只要再继续问问题就报这个错误了,只能重置会话来让他可以再次回答问题
这里是这个项目的请求部分python源码,不知道这对你是否有用
https://github.com/lss233/chatgpt-mirai-qq-bot/blob/browser-version/adapter/chatgpt/api.py

@ybhgl
Copy link

ybhgl commented Nov 24, 2024

可以附上请求参数吗?

同样的报错
{"model":"gpt-4o","temperature":0.5,"messages":[{"role":"system","content":"你是一个默认专业翻译引擎,把下面内容翻译成简体中文,结果只输出翻译的文字,不要增加多余内容。"},{"role":"user","content":"翻译以下内容:\ntest successful."}],"stream":false}

@zuisong
Copy link
Owner

zuisong commented Nov 25, 2024

我已经发布了一个修复版本
感谢 @ybhgl 提供的复现示例

image

@HoshinoDesu
Copy link
Author

问题还是存在,继续使用对话的时候还是会报同样的错误,这些可能是你要的请求参数?

class OpenAIChatbot:
    def __init__(self, api_info: OpenAIAPIKey):
        self.api_key = api_info.api_key
        self.proxy = api_info.proxy
        self.presence_penalty = config.openai.gpt_params.presence_penalty
        self.frequency_penalty = config.openai.gpt_params.frequency_penalty
        self.top_p = config.openai.gpt_params.top_p
        self.temperature = config.openai.gpt_params.temperature
        self.max_tokens = config.openai.gpt_params.max_tokens
        self.engine = api_info.model or DEFAULT_ENGINE
        self.timeout = config.response.max_timeout
        self.conversation: dict[str, list[dict]] = {
            "default": [
                {
                    "role": "system",
                    "content": "You are ChatGPT, a large language model trained by OpenAI.\nCurrent date:[current date]",
                },
            ],
        }
if self.bot.count_tokens(session_id) > config.openai.gpt_params.compressed_tokens:
            logger.debug('开始进行会话压缩')

            filtered_data = [entry for entry in self.bot.conversation[session_id] if entry['role'] != 'system']
            self.bot.conversation[session_id] = [entry for entry in self.bot.conversation[session_id] if
                                                 entry['role'] not in ['assistant', 'user']]

            filtered_data.append(({"role": "system",
                                   "content": "Summarize the discussion briefly in 200 words or less to use as a prompt for future context."}))

@zuisong
Copy link
Owner

zuisong commented Nov 29, 2024

@HoshinoDesu 我已经提交了一个修复版本了,现在还有这个问题吗?

@HoshinoDesu
Copy link
Author

@HoshinoDesu 我已经提交了一个修复版本了,现在还有这个问题吗?

有,使用了你四天前提交的修复版本后还是同样的问题,没有解决

@zuisong
Copy link
Owner

zuisong commented Nov 29, 2024

@HoshinoDesu
你可以试一下两天前的修复版本吗? 我没有发布新版本,直接使用 main 分支的代码呢

@zuisong
Copy link
Owner

zuisong commented Nov 29, 2024

应该是 gemini api 最近有变化, api 之前是不允许连续出现两个 user 类型的消息的, 所以之前代理的时候插入了空消息, 我刚刚测试了一下,这些限制现在取消了,同时禁止发送空消息给gemini了, 所以最近报错了

@HoshinoDesu
Copy link
Author

应该是 gemini api 最近有变化, api 之前是不允许连续出现两个 user 类型的消息的, 所以之前代理的时候插入了空消息, 我刚刚测试了一下,这些限制现在取消了,同时禁止发送空消息给gemini了, 所以最近报错了

两天前的版本已经可以正常使用了,非常感谢!
辛苦了~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants