continue icon indicating copy to clipboard operation
continue copied to clipboard

Chat responses containing LaTeX are occasionally truncated

Open steventsvetkov opened this issue 1 year ago • 1 comments

Before submitting your bug report

Relevant environment info

- OS: Pop!_OS 22.04 LTS x86_64
- Continue: v0.9.184 (pre-release)
- IDE: VSCode 1.91.0
- Model: GPT-4o
- config.json:
  
{
  "models": [
    {
      "apiKey": "",
      "completionOptions": {
        "temperature": 0,
        "maxTokens": 4092
      },
      "contextLength": 128000,
      "model": "gpt-4o",
      "provider": "openai",
      "systemMessage": "You give helpful and concise responses about math and machine learning. You are an AI language model that always uses LaTeX for mathematical expressions. Whenever you include equations or variables, ensure they are enclosed in $ signs. For example, f = wx + b should be written as $f = wx + b$ and \\mathbf{y} should be written as $\\mathbf{y}$. Prefer shorter responses and explain any technical jargon you use. Explain the concepts in simple words, while also additionally providing the technical jargon.",
      "title": "GPT-4o Math"
    }
  ]
}

Description

Chat responses are occasionally cut off. I've noticed this happening when the response contains LaTeX expressions, wrapped in $ for proper rendering.

This happens around one in very 15 responses with math expressions and I can't see a pattern as to why it sometimes works and other times it doesn't. The cutoff point can be right before $ or $$ characters but it can also happen in the middle of a normal sentence. There is nothing being logged in the console or devtools when this happens.

I can still get the full chat response by using the copy button or in the output log, it seems to be a rendering issue.

Screenshot from 2024-07-17 00-37-33

To reproduce

  1. Set a system prompt instructing the model to produce LaTeX expressions and warp them in $ for proper rendering.
  2. Ask the model to explain something math related.
  3. Most of the time it will work, but occasionally the responses get cut off in the UI

Log output

==========================================================================
==========================================================================
Settings:
contextLength: 128000
temperature: 0
maxTokens: 4092
model: gpt-4o
log: undefined

############################################

<system>
You give helpful and concise responses about math and machine learning. You are an AI language model that always uses KaTeX for mathematical expressions. Whenever you include equations or variables, ensure they are enclosed in $ signs. For example, f = wx + b should be written as $f = wx + b$ and \mathbf{y} should be written as $\mathbf{y}$. Prefer shorter responses and explain any technical jargon you use. Explain the concepts in simple words, while also additionally providing the technical jargon.

<user>
What are the roots of unity?

==========================================================================
==========================================================================
Completion:

The roots of unity are special complex numbers that, when raised to a certain positive integer power, equal 1. 

In technical terms, the $n$-th roots of unity are the solutions to the equation $z^n = 1$, where $z$ is a complex number and $n$ is a positive integer.

These roots can be expressed as:
$$
z_k = e^{2\pi i k / n} \quad \text{for} \quad k = 0, 1, 2, \ldots, n-1
$$

Here, $e$ is the base of the natural logarithm, $\pi$ is the mathematical constant Pi, and $i$ is the imaginary unit with $i^2 = -1$. The term $2\pi i k / n$ represents the angle in radians.

In simpler terms, the $n$-th roots of unity are points on the complex plane that are evenly spaced around the unit circle.

steventsvetkov avatar Jul 16 '24 21:07 steventsvetkov