100% found this document useful (4 votes)
994 views

Create LLM Application Using Langchain With Ease

LangChain is an open-source framework that makes it easy for developers to add natural language skills to their applications without building from scratch. It provides APIs that can be used to chain multiple language models together to create multi-step workflows. For example, one model could identify a city based on a country, and another could then list popular tourist activities in that city. Templating is also supported to generate customized prompts and outputs.

Uploaded by

abdullah.mansoor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (4 votes)
994 views

Create LLM Application Using Langchain With Ease

LangChain is an open-source framework that makes it easy for developers to add natural language skills to their applications without building from scratch. It provides APIs that can be used to chain multiple language models together to create multi-step workflows. For example, one model could identify a city based on a country, and another could then list popular tourist activities in that city. Templating is also supported to generate customized prompts and outputs.

Uploaded by

abdullah.mansoor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

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

You might also like