🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.

Project 29: E-commerce Support Bot

AI Engineer
Current Task

Objective

Review day: combine retrieval and agents — days 12 and 13 — so a cart assistant can look up product info and act on it.

Task: define a check_stock tool and invoke a retrieval chain for a product question, printing both results.

index.py
from langchain_core.tools import tool from langchain.chains import create_retrieval_chain @tool def check_stock(product_id: str) -> str: """Check current stock for a product id.""" return "12 in stock" retrieval_chain = create_retrieval_chain(retriever, question_answer_chain) response = retrieval_chain.invoke({"input": "What material is the tote bag made of?"}) print(check_stock.name) print(response["answer"])

* Hint: Correct characters turn green, incorrect ones turn red.

Live Preview
🖼️

Verify your code to see the preview