Loading video player...
Hello everyone, welcome back.
As you have seen in previous video
regarding the reflection architecture
pattern.
Today we're going to look into a
reflection Jupyter notebook code. How to
implement within a simple example.
As I stated previously,
reflection is like an human reviews and
refine their work. as a AI agent can be
designed to critique its own work and
output
and makes an implement
as you can see here previous uh
architecture pattern we discussed and
this also I provided YouTube link here
within the notebook and I'll share the
source code information as part of uh
YouTube content
So as regular my other code walkthroughs
you can see here my initial setup has
been done and running my LLM inference
on my local
and the first step here I'm validating
my service is up and running can see the
output and this is where I'm defining my
uh chain of components the initial setup
you can see Here I'm setting a
description of the product and it's
going to be looking into a generation of
a chain
as I stated here it's a simple it's
write a short story uh and it's going to
be going to explore more critic and I
defined a critic chain here uh and you
can see this the entire code base
and I have a refinement chain based on
my critic and in my original prompt
and this is where I'm defining my full
reflection chain as you can see here I
have a generation chain critic chain and
refinement chain my column
and this is where I'm running my chain
and to add stuff the full reflection
chain invoke and I define my product
detail there some text and which is sent
to my final
or full reflection chain to invoke with
the details. So this chain full
reflection chain invokes my three of
prompts chains. You can see here as I
defined
generation a chain which generating a
story and then I'm defining a a critic
here then refinement. So once all these
three are executed
and the output is defined here. I'm just
printing my finetuned
the chain response.
So if you want to explore this part uh
see
just comment a line where I defined a
critic and run it and see how the
response is going to be.
As we stated in the architecture
diagram, if I go back here, you can see
here I have a agent
and I have a reflection. It's running
within my entire full chain. And then
that's where it's going to give me an
output.
As it stated previously, the reflection
creates a feedback loop and generate,
critic, and refine,
right? as it aligns with an
architectural best practice balancing
quality, reliability and customer trust.
This is how earn trust while delivering
the results.
The reflection pattern makes EI more
fast responder. It makes it thoughtful
one by reviewing and improving its own
work.
I hope this is uh you found helpful.
Don't forget to like, subscribe, and
share. And join me next time as we
continue exploring the building blocks
of intelligent, reliable AI systems.
Agentic Pattern - Reflection notebook code source: https://github.com/krishnamanchikalapudi/examples.ipynb/blob/develop/LLM/Agentic%20Patterns/Reflection.ipynb #ai #routing #aireflection #agentic #agenticai #designpatterns #reflection #agenticpattern #agenticdesignpattern #machinelearning #llm #decisionmaking #aiworkflow AI Routing Pattern, Agentic AI, LangChain Routing, Business AI Workflows, AI Decision MakingSmarter AI Decisions, How Routing Makes AI Agents Smarter, The Secret to Adaptive AI Workflows