AI explained: LangChain — Creating AI mini apps
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:
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:
- RAG: Using private information to answer AI questions
- LangChain: Using different tools, e.g. weather API, to answer AI questions.
- Computer Vision: How to see what is in a image.
- LLMs for content classification: How to let LLMs classify content in different categories.
- LLM Performance: How to get the best performance from LLMs.
If your business needs help with AI, why don’t we connect?