mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 14:39:31 -05:00
[PR #5777] [MERGED] Fix: sanitize function calling json #8549
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/5777
Author: @smonux
Created: 9/28/2024
Status: ✅ Merged
Merged: 9/28/2024
Merged by: @tjbck
Base:
dev← Head:dev📝 Commits (2)
d8f71e1Some models produce almost correct json during function calling, but with additional data before of after it. This solves it.e039b4eMerge branch 'open-webui:dev' into dev📊 Changes
1 file changed (+1 additions, -0 deletions)
View changed files
📝
backend/open_webui/main.py(+1 -0)📄 Description
Pull Request Checklist
Opened a discussion here:
https://github.com/open-webui/open-webui/discussions/5528
Before submitting, make sure you've checked the following:
devbranch.Changelog Entry
Description
Some "weaker" models with function support tend to generate "almost" correct json, only with additional characters before of after the valid code. Removing everything before the first "{" and last "}" solves it.
Other tools like instructor already do this:
c3ff3356cb/instructor/utils.py (L78)Before the fix:
After the fix:
Added
N/A
Changed
Deprecated
N/A
Removed
N/A
Fixed
Security
N/A
Breaking Changes
N/A
Additional Information
Other fix suggested here :
https://github.com/open-webui/open-webui/discussions/3522
Screenshots or Videos
N/A
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.