✨🦙 Argilla's LlamaIndex Integration
Argilla integration into the LlamaIndex workflow
This integration allows the user to include the feedback loop that Argilla offers into the LlamaIndex ecosystem. It's based on a callback handler to be run within the LlamaIndex workflow.
Don't hesitate to check out both LlamaIndex and Argilla
Getting Started
You first need to install argilla and argilla-llama-index as follows:
pip install llama-index-callbacks-argilla
You will need to an Argilla Server running to monitor the LLM. You can either install the server locally or have it on HuggingFace Spaces. For a complete guide on how to install and initialize the server, you can refer to the Quickstart Guide.
Usage
It requires just a simple step to log your data into Argilla within your LlamaIndex workflow. We just need to call the handler before starting production with your LLM.
We will use GPT3.5 from OpenAI as our LLM. For this, you will need a valid API key from OpenAI. You can have more info and get one via this link.
After you get your API key, the easiest way to import it is through an environment variable, or via getpass().
import os
from getpass import getpass
openai_api_key = os.getenv("OPENAI_API_KEY", None) or getpass(
"Enter OpenAI API key:"
)
Let's now write all the necessary imports
from llama_index.core import (
VectorStoreIndex,
SimpleDirectoryReader,
set_global_handler,
)
from llama_index.llms.openai import OpenAI
What we need to do is to set Argilla as the global handler as below. Within the handler, we need to provide the dataset name that we will use. If the dataset does not exist, it will be created with the given name. You can also set the API KEY, API URL, and the Workspace name. You can learn more about the variables that controls Argilla initialization here
set_global_handler("argilla", dataset_name="query_model")
Let's now create the llm instance, using GPT-3.5 from OpenAI.
llm = OpenAI(
model="gpt-3.5-turbo", temperature=0.8, openai_api_key=openai_api_key
)
With the code snippet below, you can create a basic workflow with LlamaIndex. You will also need a txt file as the data source within a folder named "data". For a sample data file and more info regarding the use of Llama Index, you can refer to the Llama Index documentation.
docs = SimpleDirectoryReader("data").load_data()
index = VectorStoreIndex.from_documents(docs)
query_engine = index.as_query_engine()
Now, let's run the query_engine to have a response from the model.
response = query_engine.query("What did the author do growing up?")
response
The author worked on two main things outside of school before college: writing and programming. They wrote short stories and tried writing programs on an IBM 1401. They later got a microcomputer, built it themselves, and started programming on it.
The prompt given and the response obtained will be logged in to Argilla server.
Metadata
Release files for llama-index-callbacks-argilla 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llama_index_callbacks_argilla-0.6.0.tar.gz | 4.8 kB | Without provenance | Details for llama_index_callbacks_argilla-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llama_index_callbacks_argilla-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for llama_index_callbacks_argilla-0.6.0-py3-none-any.whl |
Total release size: 9.3 kB
Release files / llama_index_callbacks_argilla-0.6.0.tar.gz
| Download URL | llama_index_callbacks_argilla-0.6.0.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cce939f585564347e8e87788ecc22259cfca48b508e58c34e5dde8035ed704c0
|
|
BLAKE2b-256 checksum How to use checksums |
91ac2bd7612b99808d78fb17d8aa2137e81f89dde97df51b91ffe4afae559440
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / llama_index_callbacks_argilla-0.6.0-py3-none-any.whl
| Download URL | llama_index_callbacks_argilla-0.6.0-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
86e12d31c767430b813928bbcbf7721dbff71d6f2f24525d01d621126e53ef40
|
|
BLAKE2b-256 checksum How to use checksums |
b29200effcd9f4ba04603e3eb2183be93a5853b635850b8d60aade4c7196021c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for llama-index-callbacks-argilla 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.