Git Product home page Git Product logo

aws-samples / generative-ai-use-cases-jp Goto Github PK

View Code? Open in Web Editor NEW
336.0 11.0 68.0 49.16 MB

すぐに業務活用できるビジネスユースケース集付きの安全な生成AIアプリ実装

License: MIT No Attribution

JavaScript 1.16% TypeScript 97.73% HTML 0.14% CSS 0.13% Shell 0.39% Dockerfile 0.11% Python 0.34%
aws bedrock generative-ai chatbot image-generation llm rag sagemaker lambda react

generative-ai-use-cases-jp's Issues

Feedback の送信

bad を送るときに正しい文言を入力したいという要望もあるが、一旦は bad のみを送るようにする

新規会話開始時にDrawerの会話履歴を選択状態にする

新規会話を開始して会話履歴に会話が追加されたら、その新規追加された会話を選択状態にする
現在は、PathParamsと一致しているかで選択状態を判断しているため、そこの実装を変える必要がある

  • 選択状態を保持するStateを別途用意する
  • 新規会話を登録して、ChatIDが取得できたタイミングでリダイレクトする(画面ちらつきの原因になりそうなのでできればやりたくない)

CodeBuildでビルドエラー発生

CDK Deployした際にCodeBuildで以下の通りエラーが発生しました。

> [email protected] build
--
238 | > tsc && vite build
239 |  
240 | src/components/ChatMessage.tsx(33,24): error TS18048: 'chatContent' is possibly 'undefined'.
241 | npm ERR! Lifecycle script `build` failed with error:
242 | npm ERR! Error: command failed
243 | npm ERR!   in workspace: [email protected]
244 | npm ERR!   at location: /codebuild/output/src2456308977/packages/web
245 |  
246 | [Container] 2023/09/11 15:48:41 Command did not exit successfully eval "$buildCommands" exit status 1
247 | [Container] 2023/09/11 15:48:41 Phase complete: BUILD State: FAILED
248 | [Container] 2023/09/11 15:48:41 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: eval "$buildCommands". Reason: exit status 1
249 | [Container] 2023/09/11 15:48:41 Entering phase POST_BUILD
250 | [Container] 2023/09/11 15:48:41 Running command echo Build completed on `date`
251 | Build completed on Mon Sep 11 15:48:41 UTC 2023

環境は以下の通りです。
マシン:Amazon EC2 (Amazon Linux 2023)
Node.js:v18.17.1
CDK:2.95.1 (build ae455d8)
ローカルのMacでも同様の症状が起きます。240行目にあるように型不一致が起きているようです。
ご確認の程よろしくお願いいたします。

新規会話 => 履歴に登録されたらそちらに切り替え => そちらで発言

概要

  • タイトル場合、当然会話履歴の方には発言が反映されるが、新規会話の方には反映されていない。(つまり同じ Chat を 2 つ開いている状態で片方で発言するともう片方で反映されない)

解決案

  • 会話履歴をクリックした段階で、今のチャットとユースケースと同じ chatId を持っているか state を確認する (画面が重複していないか確認する)
  • 重複している場合、新規チャット or ユースケースの方の state を全削除する

補足

  • 重複している場合に、片方で発言したらもう片方にも反映する、という実装自体は可能ではあるが、複雑性が増すため、一旦ユースケースの方を削除とした方がシンプル

FAQ自動生成機能

FAQを作る条件を設定して、マニュアルを読み込ませると、LLMが自動でFAQを作成してくれる機能

CI/CDの整備

以下をGitHubActionsで整備する

  • フロントエンドのビルドエラー確認
  • CDKのSynthエラー確認

プロンプトを編集可能にする

プロンプトをユーザが書き換えられるようにする。
以下対応案

  • プロンプトをJSONファイル化
    • TSファイルの書き換えは、非開発者にとってハードルが高いためJSONファイルにする
  • プロンプト編集画面を追加する
    • プロンプトはDDBに保存する?

画像生成機能のユースケース

BedrockでStable Diffusionを実行することができるので、それを使ったユースケース。
TranslateかLLMをかませる形にして、日本語でプロンプトを入力できる形にする。

README.md の手順修正

npx -w packages/cdk cdk bootstrap

コマンドが cdk.json の openai の secrets manager の arn を参照しているため、以下エラーが発生してしまう。
手順を変更する。

再現手順は、新アカウントで Cloud9 で実行する。

aws configure # region の設定だけ
npm ci
npx -w packages/cdk cdk bootstrap

発生エラー

Error: `secretCompleteArn` does not appear to be complete; missing 6-character suffix
    at Function.fromSecretAttributes (/home/ec2-user/environment/generative-ai-use-cases-jp/node_modules/aws-cdk-lib/aws-secretsmanager/lib/secret.js:1:7009)
    at Function.fromSecretCompleteArn (/home/ec2-user/environment/generative-ai-use-cases-jp/node_modules/aws-cdk-lib/aws-secretsmanager/lib/secret.js:1:5197)
    at new Api (/home/ec2-user/environment/generative-ai-use-cases-jp/packages/cdk/lib/construct/api.ts:28:27)
    at new GenerativeAiUseCasesStack (/home/ec2-user/environment/generative-ai-use-cases-jp/packages/cdk/lib/generative-ai-use-cases-stack.ts:12:17)
    at Object.<anonymous> (/home/ec2-user/environment/generative-ai-use-cases-jp/packages/cdk/bin/generative-ai-use-cases.ts:8:1)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Module.m._compile (/home/ec2-user/environment/generative-ai-use-cases-jp/node_modules/ts-node/src/index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at Object.require.extensions.<computed> [as .ts] (/home/ec2-user/environment/generative-ai-use-cases-jp/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1076:32)
****************************************************
*** Newer version of CDK is available [2.92.0]   ***
*** Upgrade recommended (npm install -g aws-cdk) ***
****************************************************

Subprocess exited with error 1

useChat 初期化時に Chat を fetch するように変更

今は以下のように、初期化時に chatId だけを入れているが
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/main/packages/web/src/hooks/useChat.ts#L244-L251
これだと今後描写に必要な情報などが取れない可能性が高い。

例1: 今はタイトルの自動設定の判定を messages.length <= 3 で行なっているが、本当は title === '' で判定したい
例2: 会話履歴をクリックしたら上部にタイトルを出したい

そこで、以下のような実装により、useChat 初期化時に Chat を取るようにする。

  1. GET chat/:chatId で Chat を返すようにして、初期化時にそれを呼ぶ
  2. Chat 一覧ですでに Chat を取得しているので、それを useChat で使えるようにする

AWS Interpreter 対応

ただの思いつきですが、チャット(既存のチャットとは別画面)から、

「echo する lambda 関数を作ってください」

と言ったら作ってくれると AWS っぽさが出る気がしました。

狭い画面のDrawerを閉じやすくする

狭い画面のDrawerについて、現在は「X」ボタンでしか閉じることができないが、グレーアウト部分のどこをクリックしても閉じられるようにする。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.