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

【错误】连续对话错误 #532

Closed
Yang2635 opened this issue May 11, 2024 · 0 comments · Fixed by #538
Closed

【错误】连续对话错误 #532

Yang2635 opened this issue May 11, 2024 · 0 comments · Fixed by #538

Comments

@Yang2635
Copy link

Yang2635 commented May 11, 2024

使用三方的chat2api服务,配置如下图:
image

在本项目网站使用Chat2API进行连续对话时会出现错误(不影响单次对话),错误如图:
image

在NextChat项目网站上进行同样的配置,可正常连续对话,如图:
image

根据docker容器日志内容输出,如下:

sendMessage (54 tokens) {
  max_tokens: 1024,
  model: 'gpt-3.5-turbo',
  temperature: 0.8,
  top_p: 1,
  presence_penalty: 1,
  messages: [
    {
      role: 'system',
      content: "You are a large language model. Follow the user's instructions carefully. Please respond in the Chinese language. Use native Markdown for responsiveness.\n" +
        'Latex inline: $x^2$\n' +
        'Latex block: $$e=mc^2$$.'
    },
    { role: 'user', content: '你好' }
  ],
  stream: true
}
sendMessage (86 tokens) {
  max_tokens: 1024,
  model: 'gpt-3.5-turbo',
  temperature: 0.8,
  top_p: 1,
  presence_penalty: 1,
  messages: [
    {
      role: 'system',
      content: "You are a large language model. Follow the user's instructions carefully. Please respond in the Chinese language. Use native Markdown for responsiveness.\n" +
        'Latex inline: $x^2$\n' +
        'Latex block: $$e=mc^2$$.'
    },
    { role: 'user', content: [ { type: 'text', text: '你好' } ] },
    { role: 'assistant', content: '你好!有什么可以帮助你的吗?' },
    { role: 'user', content: '自我介绍一下' }
  ],
  stream: true
}
ChatGPTError: ChatGPT error 400: {"error":{"message":"invalid paramters","type":"invalid_request_error","param":null,"code":null}}
    at fetchSSE (file:///app/node_modules/.pnpm/@[email protected]/node_modules/@chatgptweb/chatgpt-api/build/index.js:56:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  statusCode: 400,
  statusText: 'Bad Request',
  [cause]: Response {
    status: 400,
    statusText: 'Bad Request',
    headers: Headers {
      date: 'Sat, 11 May 2024 07:09:25 GMT',
      'content-type': 'text/plain; charset=utf-8',
      'content-length': '97',
      connection: 'keep-alive',
      'x-server': 'oaifree/0.0.2',
      'cf-cache-status': 'DYNAMIC',
      'report-to': '{"endpoints":[{"url":"https:\\/\\/a.nel.cloudflare.com\\/report\\/v4?s=fCp05aee6fpV9sSkA4RSfGT%2BQxXFKaOQprcOhnv5mGdFnjrkIWSMjNXbUnCBuw8OJkQj4aOSm0%2BopH1U9TYD8t%2FFH7DoJQLvwd0VrgtUL2CUkXjJcNPDX%2BMbp3R8Gyz%2FWRA%3D"}],"group":"cf-nel","max_age":604800}',
      nel: '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}',
      'strict-transport-security': 'max-age=15552000; includeSubDomains; preload',
      'expect-ct': 'max-age=86400, enforce',
      'referrer-policy': 'same-origin',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'SAMEORIGIN',
      'x-xss-protection': '1; mode=block',
      server: 'cloudflare',
      'cf-ray': '882057e56f83941e-LHR',
      'alt-svc': 'h3=":443"; ma=86400'
    },
    body: ReadableStream { locked: true, state: 'closed', supportsBYOB: true },
    bodyUsed: true,
    ok: false,
    redirected: false,
    type: 'basic',
    url: 'https://api.oaifree.com/v1/chat/completions'
  }
}

初步判断定位可能是在该处的问题导致:

……
    { role: 'user', content: [ { type: 'text', text: '你好' } ] }, <---此处
    { role: 'assistant', content: '你好!有什么可以帮助你的吗?' },
    { role: 'user', content: '自我介绍一下' }
……

上述content重新处理后,可正常连续对话:
image

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.

1 participant