Skip to content

Conversation

@imkira
Copy link
Contributor

@imkira imkira commented Sep 9, 2025

Description

This PR fixes #6218

The issue is not mine but I ran into the same issue when using LocalAI as an OpenAI-compatible endpoint in another tool. The tool saw the finish_reason in the response as tool_calls and it assumed there had to be a tool_calls array in the message, which was not the case and causing it to crash. It turns out the problem was because we are incorrectly setting the finish_reason type as tool_calls (or function_call) when there is no tool/function involved.

Notes for Reviewers

Signed commits

  • Yes, I signed my commits.

@netlify
Copy link

netlify bot commented Sep 9, 2025

Deploy Preview for localai ready!

Name Link
🔨 Latest commit 174207a
🔍 Latest deploy log https://app.netlify.com/projects/localai/deploys/68c07b1736ebc90008ac9c27
😎 Deploy Preview https://deploy-preview-6243--localai.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Signed-off-by: Mário Freitas <imkira@gmail.com>
@imkira imkira force-pushed the fix/chat-finish-reason branch from 30921d7 to 174207a Compare September 9, 2025 19:08
Copy link
Owner

@mudler mudler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks!

@mudler mudler merged commit 2c0b9c6 into mudler:master Sep 11, 2025
28 checks passed
@mudler mudler added the bug Something isn't working label Sep 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ai uses tool_calls as finish_reason despite it being a simple response

2 participants