Skip to content

Conversation

@xhr15
Copy link
Member

@xhr15 xhr15 commented Mar 12, 2025

See A RAG Library for Elixir

We want to turn chatbot_ex into a RAG system that answers question about (ecto)[https://hex.pm/packages/ecto]. Out of the box, chatbot_ex knows nothing about ecto

To do this, we first add rag as dependency and run mix deps.get.

  defp deps do
    [
      ...
      {:rag, "~> 0.2.0"},
      ...
    ]
  end

This gives us four additional mix tasks:

mix rag.gen_eval        # Generates an evaluation script
mix rag.gen_rag_module  # Generates a module containing RAG related code
mix rag.gen_servings    # Generates `Nx.Serving`s to run an embedding model and an LLM
mix rag.install         # Installs the rag library

Let's try the installer! As the chatbot_ex project already has a postgres database, we go with the pgvector
as vector store.

mix rag.install --vector-store pgvector

This will generate a bunch of files into your project and update others. This PR shows the generated files. It's only to be used with the blog post :)

@xhr15 xhr15 added BLOG POST EXAMPLE see [A RAG Library for Elixir](https://bitcrowd.dev/a-rag-library-for-elixir#build-your-rag-system) do not merge labels Mar 12, 2025
@xhr15 xhr15 changed the base branch from main to other/rag March 12, 2025 11:15
@xhr15 xhr15 changed the base branch from other/rag to main March 12, 2025 11:16
xhr15 added 6 commits March 12, 2025 12:16
The assistant gets a bit to funny in it’s answers 😄 

https://bitcrowd.atlassian.net/browse/INTERNAL-499
LLM frequently use Markdown to structure their output. sth like \

    # lib/chatbot_web/live/chat_live.ex
    # (..)
      markdown_html =
          String.trim(assigns.content)
          |> Earmark.as_html!()
          |> Phoenix.HTML.raw()

        assigns =
          assigns
          |> assign(:class, "u-max-width-75 u-bg-white " <> justify_self)
          |> assign(:markdown, markdown_html)

        ~H"""
        <.ui_card id={@id} class={@Class}>
          <%= @markdown %>

https://bitcrowd.atlassian.net/browse/INTERNAL-500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BLOG POST EXAMPLE see [A RAG Library for Elixir](https://bitcrowd.dev/a-rag-library-for-elixir#build-your-rag-system) do not merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants