mirror of
https://github.com/open-webui/pipelines.git
synced 2026-07-20 15:38:19 -04:00
Fixed: Anthropic API Integration Update for System Message Handling #64
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?
Originally created by @petunder on GitHub (Jun 26, 2024).
Issue:
The previous version of the code encountered a problem with handling system messages when using the Anthropic API. System messages were not being correctly passed in API requests, which could lead to improper functioning of chat models.
Solution:
The following key changes were made to address the issue:
stream_responseandget_completionmethods.Change Details
In both
stream_responseandget_completionmethods, extraction of system message content was added:In the
get_completionmethod, the way messages are formatted for the Anthropic API was changed:The Anthropic API call was updated in both methods. Now the system message is passed as a separate parameter:
Debug outputs were added to facilitate problem diagnosis:
More detailed handling of BadRequestError was added:
It works. I cannot edit https://github.com/open-webui/pipelines/blob/main/examples/pipelines/providers/anthropic_manifold_pipeline.py please change the code. Other users can update this pipe locally, here full new code (copy/paste):
(BUG FIX VERSION)
@justinh-rahb commented on GitHub (Jun 26, 2024):
Hi! Thanks for your efforts in fixing this. As it happens I've already been working on a port of this original code to the new function platform and resolved this issue. My backport is largely complete and my system message handling is similar to how you've done here, so I'll add you as a coauthor to the PR. The backport also will handle images for Claude 3.5 Sonnet.
@justinh-rahb commented on GitHub (Jun 26, 2024):
Fixed:
@petunder I'll need your email address to add you as a coauthor.
@petunder commented on GitHub (Jun 26, 2024):
Sorry, first version was a bug. This code works well with or without system prompt:
@petunder commented on GitHub (Jun 26, 2024):
petya.uz@tuta.io
Pls check new version. There is a bug fix
@justinh-rahb commented on GitHub (Jun 26, 2024):
@petunder afaik my current PR's code works, I don't think I'll be needing the above but feel free to open another PR after this is merged if you feel there's more improvements to make.