Skip to content

Commit

Permalink
feat: added all the remaining models
Browse files Browse the repository at this point in the history
  • Loading branch information
xavidop committed Dec 28, 2024
1 parent 2df3ee5 commit 5c899a7
Show file tree
Hide file tree
Showing 3 changed files with 342 additions and 7 deletions.
54 changes: 53 additions & 1 deletion src/aws_bedrock_embedders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,68 @@ export const amazonTitanEmbedTextV2 = embedderRef({
name: "aws-bedrock/amazon.titan-embed-text-v2:0",
configSchema: TextEmbeddingConfigSchema,
info: {
dimensions: 512,
dimensions: 1024,
label: "Amazon - titan-embed-text-v2:0",
supports: {
input: ["text"],
},
},
});

export const amazonTitanEmbedMultimodalV2 = embedderRef({
name: "aws-bedrock/amazon.titan-embed-image-v1",
configSchema: TextEmbeddingConfigSchema,
info: {
dimensions: 1024,
label: "Amazon - titan-embed-multimodal-v2:0",
supports: {
input: ["text", "image"],
},
},
});

export const amazonTitanEmbedTextG1V1 = embedderRef({
name: "aws-bedrock/amazon.titan-embed-text-v1",
configSchema: TextEmbeddingConfigSchema,
info: {
dimensions: 1536,
label: "Amazon - titan-embed-text-v1",
supports: {
input: ["text"],
},
},
});

export const cohereEmbedEnglishV3 = embedderRef({
name: "aws-bedrock/cohere.embed-english-v3",
configSchema: TextEmbeddingConfigSchema,
info: {
dimensions: 1024,
label: "Cohere - embed-english-v3",
supports: {
input: ["text"],
},
},
});

export const cohereEmbedMultilingualV3 = embedderRef({
name: "aws-bedrock/cohere.embed-multilingual-v3",
configSchema: TextEmbeddingConfigSchema,
info: {
dimensions: 1024,
label: "Cohere - embed-multilingual-v3",
supports: {
input: ["text"],
},
},
});

export const SUPPORTED_EMBEDDING_MODELS: Record<string, any> = {
"amazon.titan-embed-text-v2:0": amazonTitanEmbedTextV2,
"amazon.titan-embed-image-v1": amazonTitanEmbedMultimodalV2,
"amazon.titan-embed-text-v1": amazonTitanEmbedTextG1V1,
"cohere.embed-english-v3": cohereEmbedEnglishV3,
"cohere.embed-multilingual-v3": cohereEmbedMultilingualV3,
};

export function awsBedrockEmbedder(
Expand Down
255 changes: 250 additions & 5 deletions src/aws_bedrock_llms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,6 @@ export const anthropicClaudeInstantV1 = (
});
};


export const mistralLarge2402V1 = modelRef({
name: "aws-bedrock/mistral.mistral-large-2402-v1:0",
info: {
Expand Down Expand Up @@ -425,7 +424,7 @@ export const mistralSmall2402V1 = modelRef({
configSchema: GenerationCommonConfigSchema,
});

export const mistral7BInstructV02 = modelRef({
export const mistral7BInstructV02 = modelRef({
name: "aws-bedrock/mistral.mistral-7b-instruct-v0:2",
info: {
versions: ["mistral.mistral-7b-instruct-v0:2"],
Expand All @@ -441,7 +440,7 @@ export const mistral7BInstructV02 = modelRef({
configSchema: GenerationCommonConfigSchema,
});

export const mistral8x7BInstructV01 = modelRef({
export const mistral8x7BInstructV01 = modelRef({
name: "aws-bedrock/mistral.mixtral-8x7b-instruct-v0:1",
info: {
versions: ["mistral.mixtral-8x7b-instruct-v0:1"],
Expand All @@ -457,6 +456,230 @@ export const mistral8x7BInstructV01 = modelRef({
configSchema: GenerationCommonConfigSchema,
});

export const ai21Jamba15LargeV1 = modelRef({
name: "aws-bedrock/ai21.jamba-1-5-large-v1:0",
info: {
versions: ["ai21.jamba-1-5-large-v1:0"],
label: "AI21 - Jambda 1.5 Large",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: GenerationCommonConfigSchema,
});

export const ai21Jamba15MiniV1 = modelRef({
name: "aws-bedrock/ai21.jamba-1-5-mini-v1:0",
info: {
versions: ["ai21.jamba-1-5-mini-v1:0"],
label: "AI21 - Jambda 1.5 Mini",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: GenerationCommonConfigSchema,
});

export const ai21JambaInstructV1 = modelRef({
name: "aws-bedrock/ai21.jamba-instruct-v1:0",
info: {
versions: ["ai21.jamba-instruct-v1:0"],
label: "AI21 - Jambda Instruct",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: GenerationCommonConfigSchema,
});

export const ai21Jurassic2MidV1 = modelRef({
name: "aws-bedrock/ai21.j2-mid-v1",
info: {
versions: ["ai21.j2-mid-v1"],
label: "AI21 - Jurassic-2 Mid",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: GenerationCommonConfigSchema,
});

export const ai21Jurassic2UltraV1 = modelRef({
name: "aws-bedrock/ai21.j2-ultra-v1",
info: {
versions: ["ai21.j2-ultra-v1"],
label: "AI21 - Jurassic-2 Ultra",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: GenerationCommonConfigSchema,
});

export const metaLlama3370BInstruct = modelRef({
name: "aws-bedrock/meta.llama3-3-70b-instruct-v1:0",
info: {
versions: ["meta.llama3-3-70b-instruct-v1:0"],
label: "Meta - Llama 3.3 70b Instruct",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: GenerationCommonConfigSchema,
});

export const metaLlama3211BInstruct = modelRef({
name: "aws-bedrock/meta.llama3-2-11b-instruct-v1:0",
info: {
versions: ["meta.llama3-2-11b-instruct-v1:0"],
label: "Meta - Llama 3.2 11b Instruct",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: GenerationCommonConfigSchema,
});

export const metaLlama321BInstruct = modelRef({
name: "aws-bedrock/meta.llama3-2-1b-instruct-v1:0",
info: {
versions: ["meta.llama3-2-1b-instruct-v1:0"],
label: "Meta - Llama 3.2 1b Instruct",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: GenerationCommonConfigSchema,
});

export const metaLlama323BInstruct = modelRef({
name: "aws-bedrock/meta.llama3-2-3b-instruct-v1:0",
info: {
versions: ["meta.llama3-2-3b-instruct-v1:0"],
label: "Meta - Llama 3.2 3b Instruct",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: GenerationCommonConfigSchema,
});

export const metaLlama3290BInstruct = modelRef({
name: "aws-bedrock/meta.llama3-2-90b-instruct-v1:0",
info: {
versions: ["meta.llama3-2-90b-instruct-v1:0"],
label: "Meta - Llama 3.2 90b Instruct",
supports: {
multiturn: true,
tools: true,
media: true,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: GenerationCommonConfigSchema,
});

export const metaLlama3170BInstruct = modelRef({
name: "aws-bedrock/meta.llama3-1-70b-instruct-v1:0",
info: {
versions: ["meta.llama3-1-70b-instruct-v1:0"],
label: "Meta - Llama 3.1 70b Instruct",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: GenerationCommonConfigSchema,
});

export const metaLlama318BInstruct = modelRef({
name: "aws-bedrock/meta.llama3-1-8b-instruct-v1:0",
info: {
versions: ["meta.llama3-1-8b-instruct-v1:0"],
label: "Meta - Llama 3.1 8b Instruct",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: GenerationCommonConfigSchema,
});

export const metaLlama370BInstruct = modelRef({
name: "aws-bedrock/meta.llama3-70b-instruct-v1:0",
info: {
versions: ["meta.llama3-70b-instruct-v1:0"],
label: "Meta - Llama 3 70b Instruct",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: GenerationCommonConfigSchema,
});

export const metaLlama38BInstruct = modelRef({
name: "aws-bedrock/meta.llama3-8b-instruct-v1:0",
info: {
versions: ["meta.llama3-8b-instruct-v1:0"],
label: "Meta - Llama 3 8b Instruct",
supports: {
multiturn: true,
tools: true,
media: false,
systemRole: true,
output: ["text", "json"],
},
},
configSchema: GenerationCommonConfigSchema,
});

export const SUPPORTED_AWS_BEDROCK_MODELS = (
infrenceRegion: string = "us",
): Record<string, any> => {
Expand All @@ -475,6 +698,20 @@ export const SUPPORTED_AWS_BEDROCK_MODELS = (
"mistral.mistral-small-2402-v1:0": mistralSmall2402V1,
"mistral.mistral-7b-instruct-v0:2": mistral7BInstructV02,
"mistral.mixtral-8x7b-instruct-v0:1": mistral8x7BInstructV01,
"ai21.jamba-1-5-large-v1:0": ai21Jamba15LargeV1,
"ai21.jamba-1-5-mini-v1:0": ai21Jamba15MiniV1,
"ai21.jamba-instruct-v1:0": ai21JambaInstructV1,
"ai21.j2-mid-v1": ai21Jurassic2MidV1,
"ai21.j2-ultra-v1": ai21Jurassic2UltraV1,
"meta.llama3-3-70b-instruct-v1:0": metaLlama3370BInstruct,
"meta.llama3-2-11b-instruct-v1:0": metaLlama3211BInstruct,
"meta.llama3-2-1b-instruct-v1:0": metaLlama321BInstruct,
"meta.llama3-2-3b-instruct-v1:0": metaLlama323BInstruct,
"meta.llama3-2-90b-instruct-v1:0": metaLlama3290BInstruct,
"meta.llama3-1-70b-instruct-v1:0": metaLlama3170BInstruct,
"meta.llama3-1-8b-instruct-v1:0": metaLlama318BInstruct,
"meta.llama3-70b-instruct-v1:0": metaLlama370BInstruct,
"meta.llama3-8b-instruct-v1:0": metaLlama38BInstruct,
[`${infrenceRegion}.anthropic.claude-3-5-haiku-20241022-v1:0`]:
anthropicClaude35HaikuV1(infrenceRegion),
[`${infrenceRegion}.anthropic.claude-3-5-sonnet-20241022-v2:0`]:
Expand Down Expand Up @@ -767,15 +1004,23 @@ export function toAwsBedrockRequestBody(
: request.output?.contentType;
if (jsonMode && model.info.supports?.output?.includes("json")) {
awsBedrockMessages?.push({
content: [{ text: "You write JSON objects based on the given instructions. Please generate only the JSON output. DO NOT provide any preamble." }],
content: [
{
text: "You write JSON objects based on the given instructions. Please generate only the JSON output. DO NOT provide any preamble.",
},
],
role: "user",
});
} else if (
(textMode && model.info.supports?.output?.includes("text")) ||
model.info.supports?.output?.includes("text")
) {
awsBedrockMessages?.push({
content: [{ text: "You write objects in plain text. DO NOT provide any preamble." }],
content: [
{
text: "You write objects in plain text. DO NOT provide any preamble.",
},
],
role: "user",
});
} else {
Expand Down
Loading

0 comments on commit 5c899a7

Please sign in to comment.