Skip to content

fix: migrate cookiefactoryv3 assistant to chainlit 2.x / langchain 2.x#164

Open
m4minidesk-sys wants to merge 4 commits intoaws-samples:mainfrom
m4minidesk-sys:feat/assistant-chainlit2-langchain2
Open

fix: migrate cookiefactoryv3 assistant to chainlit 2.x / langchain 2.x#164
m4minidesk-sys wants to merge 4 commits intoaws-samples:mainfrom
m4minidesk-sys:feat/assistant-chainlit2-langchain2

Conversation

@m4minidesk-sys
Copy link
Copy Markdown

Summary

Migrate the CookieFactoryV3 assistant app from deprecated chainlit 1.x and langchain 1.x APIs to current versions.

Changes

chainlit 1.x → 2.x (bedrock.py)

  • cl.Action(value=..., description=...)cl.Action(payload=..., tooltip=...)
  • action.valueaction.payload.get('value')

langchain 1.x → 2.x (8 lib files)

  • from langchain import PromptTemplatefrom langchain_classic import PromptTemplate
  • from langchain.chains import *from langchain_classic.chains import *
  • from langchain.vectorstores import Chromafrom langchain_community.vectorstores import Chroma
  • from langchain.text_splitter import *from langchain_text_splitters import *
  • from langchain.schema import BaseMemoryfrom langchain_classic.schema import BaseMemory

requirements.txt

  • Add chainlit>=2.0.0, langchain-classic, langchain-text-splitters

.gitignore

  • Add .chainlit/ and package-lock.json to prevent auto-generated files from being tracked

Testing

Verified: chainlit run app/bedrock.py starts successfully

  • Python 3.12 + chainlit 2.9.6 + langchain-aws 1.3.1
  • Vector DB initialization with Titan Embed ✅
  • App available at http://localhost:8000

Files Changed

11 files, 54 insertions, 54 deletions (under 200 line limit ✅)

- chainlit Action API: value/description → payload/tooltip (bedrock.py)
- langchain imports: langchain.* → langchain_classic.* / langchain_text_splitters / langchain_community.vectorstores
- requirements.txt: add chainlit>=2.0.0, langchain-classic, langchain-text-splitters

Tested: chainlit run app/bedrock.py starts successfully with
  Python 3.12 + chainlit 2.9.6 + langchain-aws 1.3.1
…uirements.txt

These packages are required for the langchain 2.x migration but were
missing from requirements.txt. langchain-classic is a PyPI package (v1.0.1)
that provides backward-compatible LLMChain, PromptTemplate, etc.
lazify 0.4.0 + chainlit 2.x causes ChainlitContextException when
pydantic builds Chain subclasses at module load time. Moving the
chainlit.context import inside the point_camera_to_entity() function
prevents the eager evaluation and resolves the import-time error.

Closes: ChainlitContextException on module import
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.

1 participant