This repository has been archived by the owner on Aug 25, 2024. It is now read-only.
forked from LangStream/langstream
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make service gateway response configurable (#121)
* Now when the agent fails by default sets a new header "langstream-error-type" which has two possible values: INTERNAL_ERROR or INVALID_RECORD. The default is INTERNAL_ERROR. * When the service gateway gets the message it looks for this header and decide the status code (INVALID_RECORD -> 400, INTERNAL_ERROR -> 500). **This is a breaking change** since before that it was always returning 200. It also looks the following header until one it's not blank: langstream-error-message, langstream-error-cause-message, langstream-error-root-cause-message. * These new headers are sent to the deadletter along with the existing headers: error-msg, cause-msg, root-cause-msg (note that those headers are still present to not break compatibility but they're not checked by the gateway) * From the agent perspective, to set an error as INVALID_RECORD it can be done in this way: 1. In Java agents, you can emit the result with appropriate type 2. In Python you can raise an Exception in the sink or processor ``` def process(self, record): logging.info("Processing record" + str(record)) from langstream import InvalidRecordError raise InvalidRecordError("record was not ok:" + str(record)) ``` Any other exception will treat the error as INTERNAL_ERROR
- Loading branch information
1 parent
ac5aeaf
commit 8f151de
Showing
51 changed files
with
1,338 additions
and
360 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.