-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added support for Claude 3+ Chat API in Bedrock (#2870)
- Loading branch information
Showing
17 changed files
with
413 additions
and
101 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2024 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
'use strict' | ||
|
||
/** | ||
* | ||
* @param {object[]} chunks - The "chunks" that make up a single conceptual message. In a multi-modal scenario, a single message | ||
* might have a number of different-typed chunks interspersed | ||
* @returns {string} - A stringified version of the message. We make a best-effort effort attempt to represent non-text chunks. In the future | ||
* we may want to extend the agent to support these non-text chunks in a richer way. Placeholders are represented in an XML-like format but | ||
* are NOT intended to be parsed as valid XML | ||
*/ | ||
function stringifyClaudeChunkedMessage(chunks) { | ||
const stringifiedChunks = chunks.map((msgContent) => { | ||
switch (msgContent.type) { | ||
case 'text': | ||
return msgContent.text | ||
case 'image': | ||
return '<image>' | ||
case 'tool_use': | ||
return `<tool_use>${msgContent.name}</tool_use>` | ||
case 'tool_result': | ||
return `<tool_result>${msgContent.content}</tool_result>` | ||
default: | ||
return '<unknown_chunk>' | ||
} | ||
}) | ||
return stringifiedChunks.join('\n\n') | ||
} | ||
|
||
module.exports = { | ||
stringifyClaudeChunkedMessage | ||
} |
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.