-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
5,097 additions
and
4,670 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,34 @@ | ||
import { openai } from '@ai-sdk/openai'; | ||
import { experimental_wrapLanguageModel as wrapLanguageModel } from 'ai'; | ||
import { openai } from "@ai-sdk/openai"; | ||
import { experimental_wrapLanguageModel as wrapLanguageModel } from "ai"; | ||
import { createAmazonBedrock } from "@ai-sdk/amazon-bedrock"; | ||
import { customMiddleware } from "./custom-middleware"; | ||
import { NodeHttpHandler } from "@smithy/node-http-handler"; | ||
import https from "https"; | ||
|
||
import { customMiddleware } from './custom-middleware'; | ||
export function createCustomBedrock() { | ||
const bedrock = createAmazonBedrock({ | ||
bedrockOptions: { | ||
requestHandler: new NodeHttpHandler({ | ||
httpsAgent: new https.Agent({ | ||
keepAlive: true, | ||
maxSockets: 200, // default is 50 per client. | ||
}), | ||
|
||
// time limit (ms) for receiving response. | ||
requestTimeout: 60_000_000, | ||
|
||
// time limit (ms) for establishing connection. | ||
connectionTimeout: 60_000_000, | ||
}), | ||
}, | ||
}); | ||
return bedrock; | ||
} | ||
|
||
export const customModel = (apiIdentifier: string) => { | ||
const bedrock = createCustomBedrock(); | ||
return wrapLanguageModel({ | ||
model: openai(apiIdentifier), | ||
model: bedrock("us.anthropic.claude-3-5-sonnet-20240620-v1:0"), | ||
middleware: customMiddleware, | ||
}); | ||
}; |
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.