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

fix: responses from /chat/completions endpoint contain a leading space in the content #488

Merged
merged 4 commits into from
Apr 12, 2024

Conversation

vansangpfiev
Copy link
Contributor

@vansangpfiev vansangpfiev commented Apr 9, 2024

Issue link: janhq/jan#2548

  • Add google test with sample
  • Trim the leading space if not in stream mode or it is the first token in stream mode

@vansangpfiev vansangpfiev self-assigned this Apr 9, 2024
@vansangpfiev vansangpfiev changed the title bugfix: responses from /chat/completions endpoint contain a leading space in the content fix: responses from /chat/completions endpoint contain a leading space in the content Apr 11, 2024
@vansangpfiev
Copy link
Contributor Author

Nitro logs:
Call:

POST http://127.0.0.1:3928/v1/chat/completions
**headers**
content-type: application/json
**body**
{
    {
      "content": "Hello!",
      "role": "user"
    }
  ],
  "model": "mistral-7b-instruct-v0.1.Q5_0",
  "stream": true,
  "max_tokens": 4096,
  "stop": [
    "</s>"
  ],
  "frequency_penalty": 0,
  "presence_penalty": 0,
  "temperature": 0.7,
  "top_p": 0.95
}

Response:

data: {"choices":[{"delta":{"content":"I"},"finish_reason":null,"index":0}],"created":1712803949,"id":"KqHSWp7mbWJpCveUZhve","model":"_","object":"chat.completion.chunk"}
data: {"choices":[{"delta":{"content":"'"},"finish_reason":null,"index":0}],"created":1712803950,"id":"kmChXtpgvhb8AEVIIDQ1","model":"_","object":"chat.completion.chunk"}
data: {"choices":[{"delta":{"content":"m"},"finish_reason":null,"index":0}],"created":1712803951,"id":"bA3EIN56gaTXLLoFnLpv","model":"_","object":"chat.completion.chunk"}
data: {"choices":[{"delta":{"content":" just"},"finish_reason":null,"index":0}],"created":1712803951,"id":"uQ5lSv9u2E4GUCdUejk7","model":"_","object":"chat.completion.chunk"}
data: {"choices":[{"delta":{"content":" a"},"finish_reason":null,"index":0}],"created":1712803952,"id":"WhCvljFp5UFk1qjDgwmZ","model":"_","object":"chat.completion.chunk"}
...

@vansangpfiev vansangpfiev merged commit f64a90f into main Apr 12, 2024
24 checks passed
@vansangpfiev vansangpfiev deleted the feat-google-test branch July 8, 2024 05:40
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 this pull request may close these issues.

4 participants