AI explained: LangChain — Creating AI mini apps

Maarten Ectors
2 min readOct 24, 2024

--

LangChain allows different AI blocks to be chained together. Anything from querying outside systems, executing tools, routing based on the type of questions,… can all be combined into mini AI apps.

This is a second post which reuses some of the RAG solutions which were explained previously.

Given that Rust is only 3% slower and memory safe compared to C and Python is 75x slower, let’s use LangChain-Rust. You can create your own custom tools. So let’s create a weather tool:

So what the above code does is to provide the weather in a specific location, with temperature, wind, humidity, pressure,…

Using the tool is quite straightforward. You need to get a WEATHERAPI_KEY from weatherapi.com and put this as an environment variable. Afterwards you can call the code like this:

Now let’s use the weather tool as one route:

How to use LangChain-Rust with multiple tools and routing

LangChain allows us to chain together different solutions or make decisions based on previous answers. OpenAI calls them GPTs and via LangChain you would be able to create mini AI apps and integrate them into a bigger solution. Think about exposing internal APIs to customers via a chat interface as an example. Or allowing customer support queries to go to different tools based on the type of customer request, e.g. a billing question might need a request to the billing system, whereas a product question might result in configuring a specific product for a customer.

This blog post is part of a series of short AI explainers. Be sure to also check out:

If your business needs help with AI, why don’t we connect?

--

--

Maarten Ectors
Maarten Ectors

Written by Maarten Ectors

Maarten leads Profit Growing Innovator. The focus is on helping businesses strategically transform through innovation and outrun disruption.

No responses yet