@hashbrownai/bedrock
v0.7.0
Published
Amazon Bedrock provider for Hashbrown AI
Downloads
587
Readme
@hashbrownai/bedrock is the Node adapter for Amazon Bedrock. It maps an AG-UI run from Hashbrown's React or Angular packages to the Amazon Bedrock SDK and streams AG-UI events back. Your server keeps the API key.
Getting Started
npm install @hashbrownai/bedrock @aws-sdk/client-bedrock-runtime @ag-ui/core @ag-ui/encoder --saveDeploy an Express server with a /run endpoint to use Hashbrown with Amazon Bedrock.
import type { RunAgentInput } from '@ag-ui/core';
import { EventEncoder } from '@ag-ui/encoder';
import { HashbrownBedrock } from '@hashbrownai/bedrock';
app.post('/run', async (req, res) => {
const abortController = new AbortController();
req.once('aborted', () => abortController.abort());
res.once('close', () => abortController.abort());
const stream = HashbrownBedrock.stream.text({
clientOptions: { region: process.env.AWS_REGION ?? 'us-east-1' },
model: process.env.BEDROCK_MODEL_ID!,
input: req.body as RunAgentInput,
signal: abortController.signal,
});
const encoder = new EventEncoder();
res.header('Cache-Control', 'no-cache, no-store, must-revalidate');
res.header('Content-Type', encoder.getContentType());
res.header('Connection', 'keep-alive');
res.flushHeaders();
for await (const event of stream) {
res.write(encoder.encodeSSE(event));
}
if (!res.writableEnded) {
res.end();
}
});Docs
Read the docs for the Hashbrown Amazon Bedrock adapter.
Contributing
Hashbrown is a community-driven project. Read our contributing guidelines on how to get involved.
License
MIT © LiveLoveApp, LLC
