Project 11: FAQ Answer Bot
AI Engineer
Builds on these lessons
Current Task
Objective
RecursiveCharacterTextSplitter breaks long text into overlapping chunks small enough to fit an LLM's context window or an embedding model's input limit.
Task: split a long FAQ answer into chunks of 50 characters and print how many chunks it produced.
index.py
from langchain_text_splitters import RecursiveCharacterTextSplitter
splitter = RecursiveCharacterTextSplitter(chunk_size=50, chunk_overlap=10)
answer = "Our return policy allows returns within 30 days of purchase, provided the item is unused and in its original packaging."
chunks = splitter.split_text(answer)
print(len(chunks))
* Hint: Correct characters turn green, incorrect ones turn red.
Live Preview
🖼️
Verify your code to see the preview