Build LLM
Applications with
LangChain
hossam-eldin @codewello
What is LangChain
LangChain is an open-source
framework , it has easy-to-use
tools (APIs) for developers to
add language skills to their
apps without starting from
scratch. It makes creating
language apps simpler for
developers of all levels.
hossam-eldin @codewello
Setup
Installing LangChain in Python
is pretty straightforward.
create open ai key because we
will need it and store as var
hossam-eldin @codewello
Test code
let’s run small test to see if it
worked
output
Why do bees have sticky hair?
Because they always use
honeycombs!
hossam-eldin @codewello
No Open ai ? No Problem
If, for any reason, you don't
want to use OpenAI, you can
utilize other models by simply
chaining one line.
hossam-eldin @codewello
Prompt Template
In LangChain, you can use
templating to generate a prompt.
hossam-eldin @codewello
Prompt Template
Output:
1. Climb the Eiffel Tower and take in the
breathtaking views of the city
2. Enjoy a romantic cruise along the River Seine
and admire the beautiful architecture along the
riverbanks
3. Explore the Louvre and admire the world-
renowned works of art on display
hossam-eldin @codewello
Multi-Step Workflows
LangChain context is integrating LLMs
with other elements to create
applications, with examples like :
. Combining LLMs sequentially.
. Integrating with templates.
. Merging with external data.
. Incorporating long-term memory.
hossam-eldin @codewello
Multi-Step Workflows
First step
hossam-eldin @codewello
Multi-Step Workflows
Second step
Combine both steps
hossam-eldin @codewello
Output
In this example, we build a two-
part chain:
one identifies the most popular
city for a given country, and the
other highlights the top three
tourist activities in that city.
hossam-eldin @codewello
Thanks !!
if you enjoyed this, please:
Follow me for more badass conten
Share this post so others can learn as wel
Hit the notification so you don’t miss a thing
And most importantly...
Keep on learning
Happy Coding