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

Project 6: Testimonial Formatter Bot

AI Engineer

Builds on these lessons

Current Task

Objective

LCEL composes steps with Python's | operator: prompt | model | parser reads left to right as a single runnable pipeline.

Task: build a Runnable pipeline with the pipe operator and invoke it on a testimonial string.

index.py
class Runnable: def __init__(self, func): self.func = func def __or__(self, other): return Runnable(lambda value: other.invoke(self.invoke(value))) def invoke(self, value): return self.func(value) trim = Runnable(lambda text: text.strip()) quote = Runnable(lambda text: f'"{text}"') pipeline = trim | quote print(pipeline.invoke(" best product ever "))

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

Live Preview
🖼️

Verify your code to see the preview