Skip to content

Commit

Permalink
fix: confilict
Browse files Browse the repository at this point in the history
  • Loading branch information
yuukiok committed Dec 12, 2024
2 parents 185d98b + 146c8a1 commit 550f8fd
Show file tree
Hide file tree
Showing 29 changed files with 419 additions and 268 deletions.
7 changes: 3 additions & 4 deletions browser-extension/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export VITE_APP_AGENT_ENABLED=<Bedrock Agent Flag>
export VITE_APP_SELF_SIGN_UP_ENABLED=<Self Signup Flag>
export VITE_APP_MODEL_REGION=<Bedrock/SageMakerモデルのリージョン>
export VITE_APP_MODEL_IDS=<Bedrock モデルの JSON Array>
export VITE_APP_MULTI_MODAL_MODEL_IDS=<Bedrock モデルの JSON Array>
export VITE_APP_IMAGE_MODEL_IDS=<Bedrock 画像生成モデルの JSON Array>
export VITE_APP_ENDPOINT_NAMES=<SageMaker モデルの JSON Array>
export VITE_APP_SAMLAUTH_ENABLED=<SAML 認証 Flag>
Expand All @@ -67,7 +66,6 @@ export VITE_APP_AGENT_ENABLED=true
export VITE_APP_SELF_SIGN_UP_ENABLED=true
export VITE_APP_MODEL_REGION=us-west-2
export VITE_APP_MODEL_IDS=["anthropic.claude-instant-v1","anthropic.claude-v2"]
export VITE_APP_MULTI_MODAL_MODEL_IDS=["anthropic.claude-3-sonnet-20240229-v1:0"]
export VITE_APP_IMAGE_MODEL_IDS=["stability.stable-diffusion-xl-v1","amazon.titan-image-generator-v1"]
export VITE_APP_ENDPOINT_NAMES=[]
export VITE_APP_SAMLAUTH_ENABLED=true
Expand Down
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 2 additions & 81 deletions packages/cdk/lib/construct/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
HttpMethods,
} from 'aws-cdk-lib/aws-s3';
import { Agent, AgentMap } from 'generative-ai-use-cases-jp';
import { modelFeatureFlags } from '@generative-ai-use-cases-jp/common';

export interface BackendApiProps {
userPool: UserPool;
Expand All @@ -38,7 +39,6 @@ export class Api extends Construct {
readonly optimizePromptFunction: NodejsFunction;
readonly modelRegion: string;
readonly modelIds: string[];
readonly multiModalModelIds: string[];
readonly imageGenerationModelIds: string[];
readonly endpointNames: string[];
readonly agentNames: string[];
Expand Down Expand Up @@ -71,85 +71,7 @@ export class Api extends Construct {
];

// Validate Model Names
const supportedModelIds = [
'anthropic.claude-3-5-sonnet-20241022-v2:0',
'anthropic.claude-3-5-haiku-20241022-v1:0',
'anthropic.claude-3-5-sonnet-20240620-v1:0',
'anthropic.claude-3-opus-20240229-v1:0',
'anthropic.claude-3-sonnet-20240229-v1:0',
'anthropic.claude-3-haiku-20240307-v1:0',
'us.anthropic.claude-3-5-sonnet-20241022-v2:0',
'us.anthropic.claude-3-5-haiku-20241022-v1:0',
'us.anthropic.claude-3-5-sonnet-20240620-v1:0',
'us.anthropic.claude-3-opus-20240229-v1:0',
'us.anthropic.claude-3-sonnet-20240229-v1:0',
'us.anthropic.claude-3-haiku-20240307-v1:0',
'eu.anthropic.claude-3-5-sonnet-20240620-v1:0',
'eu.anthropic.claude-3-sonnet-20240229-v1:0',
'eu.anthropic.claude-3-haiku-20240307-v1:0',
'apac.anthropic.claude-3-5-sonnet-20240620-v1:0',
'apac.anthropic.claude-3-sonnet-20240229-v1:0',
'apac.anthropic.claude-3-haiku-20240307-v1:0',
'anthropic.claude-v2:1',
'anthropic.claude-v2',
'anthropic.claude-instant-v1',
// Titan Express は日本語文字化けのため未対応
// 'amazon.titan-text-express-v1',
'amazon.titan-text-premier-v1:0',
'stability.stable-diffusion-xl-v1',
'stability.sd3-large-v1:0',
'stability.stable-image-core-v1:0',
'stability.stable-image-ultra-v1:0',
'amazon.titan-image-generator-v2:0',
'amazon.titan-image-generator-v1',
'amazon.nova-canvas-v1:0',
'meta.llama3-8b-instruct-v1:0',
'meta.llama3-70b-instruct-v1:0',
'meta.llama3-1-8b-instruct-v1:0',
'meta.llama3-1-70b-instruct-v1:0',
'meta.llama3-1-405b-instruct-v1:0',
'us.meta.llama3-2-1b-instruct-v1:0',
'us.meta.llama3-2-3b-instruct-v1:0',
'us.meta.llama3-2-11b-instruct-v1:0',
'us.meta.llama3-2-90b-instruct-v1:0',
'mistral.mistral-7b-instruct-v0:2',
'mistral.mixtral-8x7b-instruct-v0:1',
'mistral.mistral-small-2402-v1:0',
'mistral.mistral-large-2402-v1:0',
'mistral.mistral-large-2407-v1:0',
'cohere.command-r-v1:0',
'cohere.command-r-plus-v1:0',
'amazon.nova-pro-v1:0',
'amazon.nova-lite-v1:0',
'amazon.nova-micro-v1:0',
'us.amazon.nova-pro-v1:0',
'us.amazon.nova-lite-v1:0',
'us.amazon.nova-micro-v1:0',
];
const multiModalModelIds = [
'anthropic.claude-3-5-sonnet-20241022-v2:0',
'anthropic.claude-3-5-sonnet-20240620-v1:0',
'anthropic.claude-3-opus-20240229-v1:0',
'anthropic.claude-3-sonnet-20240229-v1:0',
'anthropic.claude-3-haiku-20240307-v1:0',
'us.anthropic.claude-3-5-sonnet-20241022-v2:0',
'us.anthropic.claude-3-5-sonnet-20240620-v1:0',
'us.anthropic.claude-3-opus-20240229-v1:0',
'us.anthropic.claude-3-sonnet-20240229-v1:0',
'us.anthropic.claude-3-haiku-20240307-v1:0',
'eu.anthropic.claude-3-5-sonnet-20240620-v1:0',
'eu.anthropic.claude-3-sonnet-20240229-v1:0',
'eu.anthropic.claude-3-haiku-20240307-v1:0',
'apac.anthropic.claude-3-5-sonnet-20240620-v1:0',
'apac.anthropic.claude-3-sonnet-20240229-v1:0',
'apac.anthropic.claude-3-haiku-20240307-v1:0',
'us.meta.llama3-2-11b-instruct-v1:0',
'us.meta.llama3-2-90b-instruct-v1:0',
'amazon.nova-pro-v1:0',
'amazon.nova-lite-v1:0',
'us.amazon.nova-pro-v1:0',
'us.amazon.nova-lite-v1:0',
];
const supportedModelIds = Object.keys(modelFeatureFlags);
for (const modelId of modelIds) {
if (!supportedModelIds.includes(modelId)) {
throw new Error(`Unsupported Model Name: ${modelId}`);
Expand Down Expand Up @@ -829,7 +751,6 @@ export class Api extends Construct {
this.optimizePromptFunction = optimizePromptFunction;
this.modelRegion = modelRegion;
this.modelIds = modelIds;
this.multiModalModelIds = multiModalModelIds;
this.imageGenerationModelIds = imageGenerationModelIds;
this.endpointNames = endpointNames;
this.agentNames = Object.keys(agentMap);
Expand Down
4 changes: 0 additions & 4 deletions packages/cdk/lib/construct/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export interface WebProps {
webAclId?: string;
modelRegion: string;
modelIds: string[];
multiModalModelIds: string[];
imageGenerationModelIds: string[];
endpointNames: string[];
samlAuthEnabled: boolean;
Expand Down Expand Up @@ -178,9 +177,6 @@ export class Web extends Construct {
VITE_APP_SELF_SIGN_UP_ENABLED: props.selfSignUpEnabled.toString(),
VITE_APP_MODEL_REGION: props.modelRegion,
VITE_APP_MODEL_IDS: JSON.stringify(props.modelIds),
VITE_APP_MULTI_MODAL_MODEL_IDS: JSON.stringify(
props.multiModalModelIds
),
VITE_APP_IMAGE_MODEL_IDS: JSON.stringify(props.imageGenerationModelIds),
VITE_APP_ENDPOINT_NAMES: JSON.stringify(props.endpointNames),
VITE_APP_SAMLAUTH_ENABLED: props.samlAuthEnabled.toString(),
Expand Down
5 changes: 0 additions & 5 deletions packages/cdk/lib/generative-ai-use-cases-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ export class GenerativeAiUseCasesStack extends Stack {
webAclId: props.webAclId,
modelRegion: api.modelRegion,
modelIds: api.modelIds,
multiModalModelIds: api.multiModalModelIds,
imageGenerationModelIds: api.imageGenerationModelIds,
endpointNames: api.endpointNames,
samlAuthEnabled,
Expand Down Expand Up @@ -277,10 +276,6 @@ export class GenerativeAiUseCasesStack extends Stack {
value: JSON.stringify(api.modelIds),
});

new CfnOutput(this, 'MultiModalModelIds', {
value: JSON.stringify(api.multiModalModelIds),
});

new CfnOutput(this, 'ImageGenerateModelIds', {
value: JSON.stringify(api.imageGenerationModelIds),
});
Expand Down
2 changes: 1 addition & 1 deletion packages/cdk/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"experimentalDecorators": true,
"strictPropertyInitialization": false,
"typeRoots": [
"./node_modules/@types"
"../../node_modules/@types"
],
"types": [
"node"
Expand Down
5 changes: 5 additions & 0 deletions packages/common/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "@generative-ai-use-cases-jp/common",
"private": true,
"main": "src/index.ts"
}
1 change: 1 addition & 0 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './model';
75 changes: 75 additions & 0 deletions packages/common/src/model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { FeatureFlags } from 'generative-ai-use-cases-jp';

// Manage Model Feature
// https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference-supported-models-features.html
const MODEL_FEATURE: Record<string, FeatureFlags> = {
TEXT_ONLY: { text: true, doc: false, image: false, video: false },
TEXT_DOC: { text: true, doc: true, image: false, video: false },
TEXT_DOC_IMAGE: { text: true, doc: true, image: true, video: false },
TEXT_DOC_IMAGE_VIDEO: { text: true, doc: true, image: true, video: true },
IMAGE_GEN: { image_gen: true },
VIDEO_GEN: { video_gen: true },
};
export const modelFeatureFlags: Record<string, FeatureFlags> = {
// Anthropic
'anthropic.claude-3-5-sonnet-20241022-v2:0': MODEL_FEATURE.TEXT_DOC_IMAGE,
'anthropic.claude-3-5-haiku-20241022-v1:0': MODEL_FEATURE.TEXT_DOC_IMAGE,
'anthropic.claude-3-5-sonnet-20240620-v1:0': MODEL_FEATURE.TEXT_DOC_IMAGE,
'anthropic.claude-3-opus-20240229-v1:0': MODEL_FEATURE.TEXT_DOC_IMAGE,
'anthropic.claude-3-sonnet-20240229-v1:0': MODEL_FEATURE.TEXT_DOC_IMAGE,
'anthropic.claude-3-haiku-20240307-v1:0': MODEL_FEATURE.TEXT_DOC_IMAGE,
'us.anthropic.claude-3-5-sonnet-20241022-v2:0': MODEL_FEATURE.TEXT_DOC_IMAGE,
'us.anthropic.claude-3-5-haiku-20241022-v1:0': MODEL_FEATURE.TEXT_DOC_IMAGE,
'us.anthropic.claude-3-5-sonnet-20240620-v1:0': MODEL_FEATURE.TEXT_DOC_IMAGE,
'us.anthropic.claude-3-opus-20240229-v1:0': MODEL_FEATURE.TEXT_DOC_IMAGE,
'us.anthropic.claude-3-sonnet-20240229-v1:0': MODEL_FEATURE.TEXT_DOC_IMAGE,
'us.anthropic.claude-3-haiku-20240307-v1:0': MODEL_FEATURE.TEXT_DOC_IMAGE,
'eu.anthropic.claude-3-5-sonnet-20240620-v1:0': MODEL_FEATURE.TEXT_DOC_IMAGE,
'eu.anthropic.claude-3-sonnet-20240229-v1:0': MODEL_FEATURE.TEXT_DOC_IMAGE,
'eu.anthropic.claude-3-haiku-20240307-v1:0': MODEL_FEATURE.TEXT_DOC_IMAGE,
'apac.anthropic.claude-3-5-sonnet-20240620-v1:0':
MODEL_FEATURE.TEXT_DOC_IMAGE,
'apac.anthropic.claude-3-sonnet-20240229-v1:0': MODEL_FEATURE.TEXT_DOC_IMAGE,
'apac.anthropic.claude-3-haiku-20240307-v1:0': MODEL_FEATURE.TEXT_DOC_IMAGE,
'anthropic.claude-v2:1': MODEL_FEATURE.TEXT_DOC,
'anthropic.claude-v2': MODEL_FEATURE.TEXT_DOC,
'anthropic.claude-instant-v1': MODEL_FEATURE.TEXT_DOC,
// Amazon Titan
'amazon.titan-text-express-v1': MODEL_FEATURE.TEXT_DOC,
'amazon.titan-text-premier-v1:0': MODEL_FEATURE.TEXT_ONLY,
// Meta
'meta.llama3-8b-instruct-v1:0': MODEL_FEATURE.TEXT_DOC,
'meta.llama3-70b-instruct-v1:0': MODEL_FEATURE.TEXT_DOC,
'meta.llama3-1-8b-instruct-v1:0': MODEL_FEATURE.TEXT_DOC,
'meta.llama3-1-70b-instruct-v1:0': MODEL_FEATURE.TEXT_DOC,
'meta.llama3-1-405b-instruct-v1:0': MODEL_FEATURE.TEXT_DOC,
'us.meta.llama3-2-1b-instruct-v1:0': MODEL_FEATURE.TEXT_DOC,
'us.meta.llama3-2-3b-instruct-v1:0': MODEL_FEATURE.TEXT_DOC,
'us.meta.llama3-2-11b-instruct-v1:0': MODEL_FEATURE.TEXT_DOC_IMAGE,
'us.meta.llama3-2-90b-instruct-v1:0': MODEL_FEATURE.TEXT_DOC_IMAGE,
// Mistral
'mistral.mistral-7b-instruct-v0:2': MODEL_FEATURE.TEXT_DOC,
'mistral.mixtral-8x7b-instruct-v0:1': MODEL_FEATURE.TEXT_DOC,
'mistral.mistral-small-2402-v1:0': MODEL_FEATURE.TEXT_ONLY,
'mistral.mistral-large-2402-v1:0': MODEL_FEATURE.TEXT_DOC,
'mistral.mistral-large-2407-v1:0': MODEL_FEATURE.TEXT_DOC,
// Cohere
'cohere.command-r-v1:0': MODEL_FEATURE.TEXT_DOC,
'cohere.command-r-plus-v1:0': MODEL_FEATURE.TEXT_DOC,
// Amazon Nova
'amazon.nova-pro-v1:0': MODEL_FEATURE.TEXT_DOC_IMAGE_VIDEO,
'amazon.nova-lite-v1:0': MODEL_FEATURE.TEXT_DOC_IMAGE_VIDEO,
'amazon.nova-micro-v1:0': MODEL_FEATURE.TEXT_ONLY,
'us.amazon.nova-pro-v1:0': MODEL_FEATURE.TEXT_DOC_IMAGE_VIDEO,
'us.amazon.nova-lite-v1:0': MODEL_FEATURE.TEXT_DOC_IMAGE_VIDEO,
'us.amazon.nova-micro-v1:0': MODEL_FEATURE.TEXT_ONLY,
// Stability AI Image Gen
'stability.stable-diffusion-xl-v1': MODEL_FEATURE.IMAGE_GEN,
'stability.sd3-large-v1:0': MODEL_FEATURE.IMAGE_GEN,
'stability.stable-image-core-v1:0': MODEL_FEATURE.IMAGE_GEN,
'stability.stable-image-ultra-v1:0': MODEL_FEATURE.IMAGE_GEN,
// Amazon Image Gen
'amazon.titan-image-generator-v2:0': MODEL_FEATURE.IMAGE_GEN,
'amazon.titan-image-generator-v1': MODEL_FEATURE.IMAGE_GEN,
'amazon.nova-canvas-v1:0': MODEL_FEATURE.IMAGE_GEN,
};
12 changes: 12 additions & 0 deletions packages/common/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"rootDir": "src",
"composite": true,
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"skipLibCheck": true
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
1 change: 1 addition & 0 deletions packages/types/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export * from './utils';
export * from './systemContext';
export * from './useCaseBuilder';
export * from './protocolUseCaseBuilder';
export * from './model';
7 changes: 6 additions & 1 deletion packages/types/src/message.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,15 @@ export type UploadedFileType = {
s3Url?: string;
uploading: boolean;
deleting?: boolean;
errorMessages: string[];
};

export type FileLimit = {
accept: string[];
accept: {
doc: string[];
image: string[];
video: string[];
};
maxFileCount: number;
maxFileSizeMB: number;
maxImageFileCount: number;
Expand Down
9 changes: 9 additions & 0 deletions packages/types/src/model.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Feature Flag の型を定義
export type FeatureFlags = {
text?: boolean;
doc?: boolean;
image?: boolean;
video?: boolean;
image_gen?: boolean;
video_gen?: boolean;
};
5 changes: 2 additions & 3 deletions packages/web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ const ragEnabled: boolean = import.meta.env.VITE_APP_RAG_ENABLED === 'true';
const ragKnowledgeBaseEnabled: boolean =
import.meta.env.VITE_APP_RAG_KNOWLEDGE_BASE_ENABLED === 'true';
const agentEnabled: boolean = import.meta.env.VITE_APP_AGENT_ENABLED === 'true';
const { multiModalModelIds } = MODELS;
const multiModalEnabled: boolean = multiModalModelIds.length > 0;
const { visionEnabled } = MODELS;
const getPromptFlows = () => {
try {
return JSON.parse(import.meta.env.VITE_APP_PROMPT_FLOWS);
Expand Down Expand Up @@ -137,7 +136,7 @@ const items: ItemProps[] = [
icon: <PiImages />,
display: 'usecase' as const,
},
multiModalEnabled
visionEnabled
? {
label: '映像分析',
to: '/video',
Expand Down
10 changes: 8 additions & 2 deletions packages/web/src/components/FileCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ type Props = BaseProps & {
filename?: string;
url?: string;
loading?: boolean;
deleting?: boolean;
size: 's' | 'm';
error?: boolean;
onDelete?: () => void;
};

Expand All @@ -16,15 +18,19 @@ const FileCard: React.FC<Props> = (props) => {
<div className={props.className}>
<div className="group relative cursor-pointer">
<div
className={`border-aws-squid-ink/50 max-w-36 break-all rounded border object-cover object-center p-1 ${props.size === 's' ? 'max-h-24' : 'max-h-32'}`}>
className={`${
props.error ? 'border-red-500' : 'border-aws-squid-ink/50'
} max-w-36 break-all rounded border object-cover object-center p-1 ${
props.size === 's' ? 'max-h-24' : 'max-h-32'
}`}>
<PiFile className="mb-1 mr-1 inline size-4" />
{props.url ? (
<a href={props.url}>{props.filename}</a>
) : (
props.filename
)}
</div>
{props.loading && (
{(props.loading || props.deleting) && (
<div className="bg-aws-squid-ink/20 absolute top-0 flex h-full w-full items-center justify-center rounded">
<PiSpinnerGap className="animate-spin text-4xl text-white" />
</div>
Expand Down
Loading

0 comments on commit 550f8fd

Please sign in to comment.