Skip to content

[Enhancement] Add buffer to increase possible response tokens #1003

@kuangxiaoye

Description

@kuangxiaoye

Contact Details

[email protected]

What happened?

The problem of stopping without any error report in a conversation with chatgpt.The strange thing is that after stopping, clicking continue will continue the conversation normally.After this problem occurs, I switch the model to gpt-3.5, the conversation can still continue, and then switch back to gpt-4, and the above problem will be repeated.

Steps to Reproduce

  1. This problem does not appear in the new conversation, but in situations where the conversation has already been made many times
  2. I checked the message method and printed each return value to see why this happened.Please see the relevant log output section
  3. After working hard on debug, I didn't find any problems related to" finish_reason:length". I hope I can get your help.

What browsers are you seeing the problem on?

No response

Relevant log output

I debug the getCompletion file, and I find that the output of the onmessage method has the following problems when it is finally interrupted:

## Gpt-3.5 's conversation log (normal Q & A):

ask log
{
  text: '', // This is the content of my question. I deleted it manually for the sake of appearance.
  conversationId: 'c2e62814-f690-4ecf-931d-97ce6214dec3',
  endpointOption: {
    endpoint: 'openAI',
    chatGptLabel: '充值',
    promptPrefix: '你是一个nodejs架构师,你精通express框架,并且在web编写方面非常在行。你需要与我一起完成一个充值界面的编写工作,为我的代码做出改正或提出建议',
    modelOptions: {
      model: 'gpt-3.5-turbo-0613',
      temperature: 1,
      top_p: 1,
      presence_penalty: 0,
      frequency_penalty: 0
    }
  }
}
{
  '5ee067fa-45a4-4e7a-96ae-a5163c7b0d17': 189,
  '626fb256-9ed6-4db2-aaa9-aa43e4739517': 26,
  '6f3e61ff-3d37-471c-b8de-99c8a2518713': 442,
  'fce4bd31-c2fc-43f5-9f00-ef992506eb8d': 1925,
  instructions: 73
}
userMessage.tokenCount 1925
userMessage {
  messageId: 'fce4bd31-c2fc-43f5-9f00-ef992506eb8d',
  parentMessageId: '6f3e61ff-3d37-471c-b8de-99c8a2518713',
  conversationId: 'c2e62814-f690-4ecf-931d-97ce6214dec3',
  sender: 'User',
  text: '', // This is the content of my question. I deleted it manually for the sake of appearance.
   isCreatedByUser: true,
  tokenCount: 1925
}
promptTokens, completionTokens: 2655 1445

## Gpt-4 's conversation log (Be interrupted - finish_reason:length)

ask log
{
  text: '‘, //// This is the content of my question. I deleted it manually for the sake of appearance.
  conversationId: 'c2e62814-f690-4ecf-931d-97ce6214dec3',
  endpointOption: {
    endpoint: 'openAI',
    chatGptLabel: '充值',
    promptPrefix: '你是一个nodejs架构师,你精通express框架,并且在web编写方面非常在行。你需要与我一起完成一个充值界面的编写工作,为我的代码做出改正或提出建议',
    modelOptions: {
      model: 'gpt-4-0613',
      temperature: 1,
      top_p: 1,
      presence_penalty: 0,
      frequency_penalty: 0
    }
  }
}
promptTokens, completionTokens: 8143 51
New value for sk-w5vaqiu5v6sxSPKqgoye6zBAPzuJZcwiMIxkc3F2NTrWEbzQ is 4089
{
  'e9335f1f-e566-4779-a80a-37d0d777f1ff': 758,
  '4480269c-7a50-4e1e-a224-70dac54c4245': 457,
  '1c457e26-ed2e-4a72-8d90-f59063d290db': 1689,
  '2b195c4b-8918-4b95-af8d-89cb836928fa': 724,
  '515ede24-7348-4fd0-a126-92eac12ff70a': 1860,
  '5ee067fa-45a4-4e7a-96ae-a5163c7b0d17': 189,
  '626fb256-9ed6-4db2-aaa9-aa43e4739517': 26,
  '6f3e61ff-3d37-471c-b8de-99c8a2518713': 442,
  'fce4bd31-c2fc-43f5-9f00-ef992506eb8d': 1924,
  instructions: 74
}
userMessage.tokenCount 1924
userMessage {
  messageId: 'fce4bd31-c2fc-43f5-9f00-ef992506eb8d',
  parentMessageId: '6f3e61ff-3d37-471c-b8de-99c8a2518713',
  conversationId: 'c2e62814-f690-4ecf-931d-97ce6214dec3',
  sender: 'User',
  text: '', // This is the content of my question. I deleted it manually for the sake of appearance.
  isCreatedByUser: true,
  tokenCount: 1924
}
promptTokens, completionTokens: 8143 51



### Screenshots

<img width="820" alt="image" src="https://github.com/danny-avila/LibreChat/assets/43713316/12fd44ac-a8bd-484b-9638-56722a005d21">


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions