-
Notifications
You must be signed in to change notification settings - Fork 1
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
Your Name
committed
Jun 23, 2024
1 parent
eb8e660
commit b2251fe
Showing
16 changed files
with
342 additions
and
336 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,46 +1,39 @@ | ||
import { | ||
BedrockRuntimeClient, | ||
ConverseCommand, | ||
} from "@aws-sdk/client-bedrock-runtime"; | ||
import dotenv from 'dotenv' | ||
dotenv.config() | ||
import { BedrockRuntimeClient, ConverseCommand } from "@aws-sdk/client-bedrock-runtime"; | ||
import { env } from "$env/dynamic/private"; | ||
|
||
const client = new BedrockRuntimeClient({ | ||
region: "us-east-1", | ||
credentials: { | ||
accessKeyId: process.env.AWS_BEDROCK_ACCESS_KEY_ID, | ||
secretAccessKey: process.env.AWS_BEDROCK_SECRET_ACCESS_KEY, | ||
}, | ||
region: "us-east-1", | ||
credentials: { | ||
accessKeyId: env.AWS_BEDROCK_ACCESS_KEY_ID, | ||
secretAccessKey: env.AWS_BEDROCK_SECRET_ACCESS_KEY, | ||
}, | ||
}); | ||
|
||
export default async function invokeModel(queryString) { | ||
// Prepare the request parameters | ||
const params = { | ||
modelId: "anthropic.claude-3-5-sonnet-20240620-v1:0", | ||
|
||
// Prepare the request parameters | ||
const params = { | ||
modelId: "anthropic.claude-3-5-sonnet-20240620-v1:0", | ||
|
||
"max_tokens": 1024, | ||
"messages": [ | ||
{ | ||
"role": "user", | ||
"content": [ | ||
|
||
{ | ||
"type": "text", | ||
"text": queryString | ||
} | ||
] | ||
} | ||
] | ||
}; | ||
max_tokens: 1024, | ||
messages: [ | ||
{ | ||
role: "user", | ||
content: [ | ||
{ | ||
type: "text", | ||
text: queryString, | ||
}, | ||
], | ||
}, | ||
], | ||
}; | ||
|
||
const command = new ConverseCommand(params); | ||
|
||
const command = new ConverseCommand(params); | ||
|
||
try { | ||
const data = await client.send(command); | ||
return data; | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
try { | ||
const data = await client.send(command); | ||
return data; | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} |
Oops, something went wrong.