DEV Community

Cover image for Reconquer your documents with Ragna
raphiki for Technology at Worldline

Posted on • Updated on

Reconquer your documents with Ragna

Ragna, a very young project announced at the end of October 2023, demonstrates its power and user-friendly nature in this brief tutorial.

Ragna Logo

It draws from the expertise of professionals experienced in LLM projects and RAG applications. Unlike generic frameworks like LangChain or LlamaIndex, Ragna involves less abstraction, facilitating faster prototyping with CLI tools for easier configuration, while maintaining a scalable architecture.

Ragna Architecture

In the diagram from Ragna's official website, we see various components connected through an API, utilizing concepts of queues and workers to enhance scalability.

Ragna is developed in Python and is distributed under a BSD-3-Clause license.

Install

For local installation, follow these steps, elaborated further than the official documentation:

  • Install Ragna and its dependencies:
pip install 'ragna[all]'
Enter fullscreen mode Exit fullscreen mode
  • Address any dependency issues, such as with jinja2:
pip install jinja2==3.1.2
Enter fullscreen mode Exit fullscreen mode
  • Initialize the configuration file using the ragna init CLI:
$ ragna init
                Welcome to the Ragna config creation wizard!

I'll help you create a configuration file to use with ragna.
Due to the large amount of parameters, I unfortunately can't cover everything. If you want to customize
everything, please have a look at the documentation instead.

? Which of the following statements describes best what you want to do? I want to try Ragna and its builtin source storages and assistants, which potentially require additional dependencies or setup.

ragna has the following components builtin. Select the ones that you want to use. If the requirements of a
selected component are not met, I'll show you instructions how to meet them later.

? Which source storages do you want to use? [Chroma]

? Which assistants do you want to use? [OpenAI/gpt-4]

The output path /home/raph/Dev/ragna/ragna.toml already exists and you didn't pass the --force flag to
overwrite it.

? What do you want to do? Overwrite the existing file.

And with that we are done ๐ŸŽ‰ I'm writing the configuration file to /home/raph/Dev/ragna/ragna.toml.
Enter fullscreen mode Exit fullscreen mode

You can choose different options or directly edit the ragna.toml file. For using the GPT-4 model, provide your OpenAI API key:

export OPENAI_API_KEY="sk-<the-rest-of-the-key>"
Enter fullscreen mode Exit fullscreen mode

Verify Ragna's configuration with the ragna check command:

$ ragna check
                       source storages
โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ    โ”ƒ name   โ”ƒ environment variables โ”ƒ packages            โ”ƒ
โ”กโ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ โœ… โ”‚ Chroma โ”‚                       โ”‚ โœ… chromadb>=0.4.13 โ”‚
โ”‚    โ”‚        โ”‚                       โ”‚ โœ… tiktoken         โ”‚
โ””โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       assistants
โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ    โ”ƒ name         โ”ƒ environment variables โ”ƒ packages โ”ƒ
โ”กโ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ โœ… โ”‚ OpenAI/gpt-4 โ”‚ โœ… OPENAI_API_KEY     โ”‚          โ”‚
โ””โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
Enter fullscreen mode Exit fullscreen mode

Use

To start using Ragna:

  • Start the API component:
$ ragna api
INFO:   RagnaDemoAuthentication: You can log in with any username and a matching password.
INFO:     Started server process [4016]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:31476 (Press CTRL+C to quit)
Enter fullscreen mode Exit fullscreen mode

Ragna's REST API is detailed in the OpenAPI format. The project also offers a Python API.

  • Use the built-in Web UI:
$ ragna ui
Launching server at http://localhost:31477
Enter fullscreen mode Exit fullscreen mode

You can now log in and start chats by uploading documents:

Upload Document

And querying their content:

Chat with Document

Extend

Ragna's architecture facilitates easy extension. Its dynamic community is likely to soon offer new features, vectorstores, and models.

Inspired by an article, I was able to easily add basic Azure OpenAI support:

Azure OpenAI Support

And to connect Ragna to my company instance:

Chat with Azure OpenAI


In conclusion, Ragna stands out as a robust and versatile tool for RAG orchestration, offering ease of use and extensibility, which positions it as a promising asset for AI-enhanced document management.

Top comments (3)

Collapse
 
pavithraes profile image
Pavithra Eswaramoorthy

Hi, I'm a part of the Ragna development team. Thank you for checking out Ragna, and writing a clear and complete tutorial!

One small clarification, cloning the repository is not required for installation, it's only needed if we want to extend or contribute to Ragna. Running pip install 'ragna[all]' should be enough because Ragna is available on PyPI.

Also, could you please elaborate on the dependency issues? Ragna doesn't actually use jinja2, so I'm curious about any errors that you encountered. More details will help us track down the issue and improve the project. :)

Thanks again for the article! ๐ŸŒป

Collapse
 
raphiki profile image
raphiki

Thanks Pavithra for the clarification, I updated the article.
Regarding jinja2 I will try and reproduce the problem and log an issue in the GitHub project.

Collapse
 
glntn101 profile image
Luke

Great article, thanks!