Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix issue where cdk bootstrap failed and add response streaming feature (toggle off). Close #122 #134

Merged
merged 3 commits into from
May 29, 2024

Conversation

jessieweiyi
Copy link
Contributor

@jessieweiyi jessieweiyi commented May 27, 2024

Description

This PR includes @sperka PR #130. The PR has been tested on different use cases and fix a few issues:

  • Revert the UI tsconfig files change to address the runtime UI issues
  • ListChatMessages API failed due to validation when nextToken is null)

The PR also:

  • Tested with langchain version 0.1.36 (Upgraded in PR feat: support Claude v3 #131) - The issue where only one chunk returned cannot be identified
  • Allows users to config whether to stream response for Bedrock models

Issues found in the streaming feature, so add a feature flag on the feature to toggle it off:

  • When issue occurs, the button is loading forever
  • The second requests do not get the update

To toggle on: add ?features=streaming query string to the url

Pending To-do items:

  • With streaming, it should implement a progress bar in chat panel
  • upgrade lambda-powertools to v2

Here is a copied of original PR description:

This PR introduces streaming support and was also targeting a bit of a cleanup/refresh.

  • vscode settings update (use vscode v1.85+) - editor settings had breaking changes
  • adjust projenrc setup to conform aws-pdk update breaking changes
  • bump dependencies to latest or latest-that-doesn't-break-anything
  • replace discontinued @AWS-SDK packages with @smithy packages
  • fix for [BUG] CDK bootstrap - Command failed with error 127 #112
  • tsconfig settings update for apis and website
  • fix first-deployment issue for admin user/group dependency
  • add Websocket API from PDK's type-safe-api
  • add streaming support to RAG chain and split create-message handler to support REST and WS
  • add websocket connection management (via ddb persistance)
  • restructure infra nested stack setup to avoid circular dependencies
  • website updated to support websocket connections

There are a few things that should be added or changed (refer to // TODOs in the code):

  1. Website
    • make choice of streaming/rest call configurable
    • with streaming, it should implement a progress bar in chat panel
  2. SDK (RAG chain)
    • Currently langchain@0.0.194 version is used, there were huge improvements so updating to latest should be inevitable - however, this includes quite a bit of effort
    • Also, lambda-powertools v2 is out, but has breaking changes
    • qaChain definition and how streaming is handled, especially based on the models used. With the current generic approach, streaming is not happening, there is only one chunk returned (which is the actual result) instead of incremental answer (aka tokens). This may be an issue because of the langchain version, or something else. That part needs to be tested, both for bedrock LLMs and Sagemaker-hosted LLMs.
  3. Websocket communication structure
    • Current implementation is not as restrictive as it should be, operation value can be any string value which should be restricted to enum, and maybe other fields could be limited as well -- needs thorough review
  4. Add docs

Does this PR introduce a breaking change?
No breaking change. The streaming feature is under a feature toggle.

Related Issues/Discussion

How Has This Been Tested?

  • What environment was this tested on?

Screenshots (if appropriate)

PR Checklist

  • Have you added/updated documentation?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran build and tests with your changes locally?

IMPORTANT: Please review the CONTRIBUTING.md file for detailed contributing guidelines.

sperka and others added 2 commits May 27, 2024 09:35
* fix: vscode settings update (use v1.85+)

* fix(projenrc): configUpgradeDeps at postSynth to conform with pdk upgrade

* fix(api): use custom python dep to conform with pdk upgrade

* fix(galileo-cdk): bump jsii version and add pnpm-logger dep to conform pdk upgrade

* chore(deps): upgrade pdk@0.23.31, cdk@2.137.0 and fix projen dep

* chore(deps): remove sdk/smithy version pinning, replace discont'd aws-sdk packages

* fix(website): build fails in CI

* chore(ws-api): add ws-api bootstrap

* fix(cli): non-built project bootstrap fails
fixes aws-samples#112

* fix: adjust tsconfig for api and website

* fix(infra): admin user attachment depends on already created group and user

* feat(ws-api): rename to ws-api, add model and wire up with infra

* chore(deps): bump pdk to 0.23.33 and align tsconfigs for api and web

* feat(infra): wire up wsApi with lambdaAuthorizer and bump node runtime (20_x) for lambda handlers

* fix(website): popover dismissbutton and header must be present together

* feat(galileo-sdk): add streaming support to chain

* feat: dependency management and project wiring

* feat(infra): add ws connections table

* feat(infra): split inference engine handler rest/ws with shared logic

* feat(infra): merge inference and presentation stacks to avoid circular deps

* feat(ws-api): connection data persistence

* feat(website): switch to streaming respose in chat

* fix(api): poetry lockfile causes CI build error

* fix(ws-api): don't generate code for send-chat-message
@jessieweiyi jessieweiyi changed the title fix: and add response streaming feature(toggle off). Close #122 fix: fix issue where cdk bootstrap failed and add response streaming feature (toggle off). Close #122 May 27, 2024
@jessieweiyi jessieweiyi requested a review from chn217 May 27, 2024 00:23
Copy link
Contributor

@martenpayne martenpayne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple minor comments

demo/website/src/hooks/ws-chats.ts Outdated Show resolved Hide resolved
demo/infra/src/application/presentation/index.ts Outdated Show resolved Hide resolved
packages/galileo-sdk/src/chat/callback.ts Show resolved Hide resolved
packages/galileo-sdk/src/chat/engine.ts Outdated Show resolved Hide resolved
packages/galileo-sdk/src/chat/engine.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@chn217 chn217 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on this PR! 👏

Just a general comment: I noticed that there are a few TODOs included in this PR. It would be good to track these TODOs in separate issues in the backlog to ensure they don't get lost or forgotten.

The most important missing TODO seems to be related to documentation (DOC). We should create a separate issue for this and prioritize it accordingly.

@jessieweiyi jessieweiyi merged commit db8530b into aws-samples:mainline May 29, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants