DEV Community

Mạnh Vũ
Mạnh Vũ

Posted on

App power by LLM and Tools in Elixir

Intro

Recently, I wrote an example for my friend can see and understand how to apply AI to web application. He have used ChatGPT and think AI still unstable & not good enough result.

Actually, He just use chat mode and provides some basic guides for tasks. He doesn't how to declare rules & guide for AI can understand more about task.

To help him to understand how AI can process data in an application, I wrote an example by Elixir.

For save time, I used Phoenix + Ash(with AshAi) + Reactor.

Concept of application

I made an Elixir application to help process estimate tour cost from raw data.

I used local LLM & Google Gemini 2.5 Pro for developing.

For integrating AI with application, I write 2 flows.

The first one is using AI for extracting data from raw request (text) and get necessary information for later task. After that application have enough information for collecting suppliers then estimate cost for tour. In this flow, data can be processed without any action from user. AI cost for this flow can be optimized easily.

Some photo from screen of app:

flow 1, 1

flow 1, 2

The second one is using chat flow for interactive with user for ask requirement and get supported from tools to query local data. This flow is flexible but take time & cost more than the first one.

Some photo from screen of app:

flow 2, 1

flow 2, 2

How I integrate AI with Elixir application

I used Ash framework with AshAi extension & Reactor for fast developing application. This cost 3-4 days for integrating AI (my first app that included AI) and 2 days for declarative domain (database schemas) by Ash and UI for show and input data.

Ash framework is powerful framework if you want to save time and build extensible things.
Recently, I use Ash framework for almost task with database. I don't want to work with database & query too much!

When making this application, I explored Reactor is very nice thing when work with flow of actions. Reactor help me easily define complex flow that can rollback, retry and compose with other flows.

For AshAi, I think is nice but need to improve documents and give community more examples. Don't see any way for export directly tools for using directly in LangChain.

An other library that I tried is Jido, I like style of Jido than AshAi and Reactor but this lib still so young and need to improve for support LangChain better.

Conclusion

Integration AI to Elixir application is simple. For me, I just need to understand how tools are called in LangChain and how to write right guides to help AI can understand task and tools.

Elixir is grown fast and has a lot of nice libraries and frameworks from community.

Top comments (0)