semvec/pypi-packages huggingface dataset:
llama-index-packs-rag-evaluator 0.4.1
llama-index packs rag_evaluator integration
Requires Python: <4.0,>=3.9
Keywords: benchmarks, evaluation, rag

# Retrieval-Augmented Generation (RAG) Evaluation Pack

Get benchmark scores on your own RAG pipeline (i.e. `QueryEngine`) on a RAG
dataset (i.e., `LabelledRagDataset`). Specifically this pack takes in as input a
query engine and a `LabelledRagDataset`, which can also be downloaded from
[llama-hub](https://llamahub.ai).

## CLI Usage

You can download llamapacks directly using `llamaindex-cli`, which comes installed with the `llama-index` python package:

```bash
llamaindex-cli download-llamapack RagEvaluatorPack --download-dir ./rag_evaluator_pack
```

You can then inspect the files at `./rag_evaluator_pack` and use them as a template for your own project!

## Code Usage

You can download the pack to the `./rag_evaluator_pack` directory through python
code as well. The sample script below demonstrates how to construct `RagEvaluatorPack`
using a `LabelledRagDataset` downloaded from `llama-hub` and a simple RAG pipeline
built off of its source documents.

```python
from llama_index.core.llama_dataset import download_llama_dataset
from llama_index.core.llama_pack import download_llama_pack
from llama_index.core import VectorStoreIndex

# download a LabelledRagDataset from llama-hub
rag_dataset, documents = download_llama_dataset(
    "PaulGrahamEssayDataset", "./paul_graham"
)

# build a basic RAG pipeline off of the source documents
index = VectorStoreIndex.from_documents(documents=documents)
query_engine = index.as_query_engine()

# Time to benchmark/evaluate this RAG pipeline
# Download and install dependencies
RagEvaluatorPack = download_llama_pack(
    "RagEvaluatorPack", "./rag_evaluator_pack"
)

# construction requires a query_engine, a rag_dataset, and optionally a judge_llm
rag_evaluator_pack = RagEvaluatorPack(
    query_engine=query_engine, rag_dataset=rag_dataset
)

# PERFORM EVALUATION
benchmark_df = rag_evaluator_pack.run()  # async arun() also supported
print(benchmark_df)
```

`Output:`

```text
rag                            base_rag
metrics
mean_correctness_score         4.511364
mean_relevancy_score           0.931818
mean_faithfulness_score        1.000000
mean_context_similarity_score  0.945952
```

Note that `rag_evaluator_pack.run()` will also save two files in the same directory
in which the pack was invoked:

```bash
.
├── benchmark.csv (CSV format of the benchmark scores)
└── _evaluations.json (raw evaluation results for all examples & predictions)
```
llama-index-readers-txtai 0.4.1
llama-index readers txtai integration
Requires Python: <4.0,>=3.9

# LlamaIndex Readers Integration: txtai

## Overview

The txtai Reader retrieves documents through an existing in-memory txtai index. These documents can then be used in downstream LlamaIndex data structures. If you wish to use txtai itself as an index to organize documents, insert documents, and perform queries on them, please use VectorStoreIndex with TxtaiVectorStore.

### Installation

You can install the txtai Reader via pip:

```bash
pip install llama-index-readers-txtai
```

### Usage

```python
from llama_index.readers.txtai import TxtaiReader

# Initialize TxtaiReader with an existing txtai index
reader = TxtaiReader(index="<txtai Index object>")

# Load data from txtai index
documents = reader.load_data(
    query="<Query Vector>",
    id_to_text_map={"<ID>": "<Text>"},
    k=4,
    separate_documents=True,
)
```

This loader is designed to be used as a way to load data into
[LlamaIndex](https://github.com/run-llama/llama_index/tree/main/llama_index).
llama-index-packs-llava-completion 0.4.1
llama-index packs llava_completion integration
Requires Python: <4.0,>=3.9
Keywords: image, llava, multimodal

# LLaVA Completion Pack

This LlamaPack creates the LLaVA multimodal model, and runs its `complete` endpoint to execute queries.

## CLI Usage

You can download llamapacks directly using `llamaindex-cli`, which comes installed with the `llama-index` python package:

```bash
llamaindex-cli download-llamapack LlavaCompletionPack --download-dir ./llava_pack
```

You can then inspect the files at `./llava_pack` and use them as a template for your own project!

## Code Usage

You can download the pack to a `./llava_pack` directory:

```python
from llama_index.core.llama_pack import download_llama_pack

# download and install dependencies
LlavaCompletionPack = download_llama_pack(
    "LlavaCompletionPack", "./llava_pack"
)
```

From here, you can use the pack, or inspect and modify the pack in `./llava_pack`.

Then, you can set up the pack like so:

```python
# create the pack
llava_pack = LlavaCompletionPack(image_url="./images/image1.jpg")
```

The `run()` function is a light wrapper around `llm.complete()`.

```python
response = llava_pack.run(
    "What dinner can I cook based on the picture of the food in the fridge?"
)
```

You can also use modules individually.

```python
# call the llm.complete()
llm = llava_pack.llm
response = llm.complete("query_str")
```
llama-index-readers-firestore 0.4.1
llama-index readers firestore integration
Requires Python: <4.0,>=3.9
Keywords: datastore, firestore

# Firestore Loader

```bash
pip install llama-index-readers-firestore
```

This loader loads from a Firestore collection or a specific document from Firestore. The loader assumes your project already has the google cloud credentials loaded. To find out how to set up credentials, [see here](https://cloud.google.com/docs/authentication/provide-credentials-adc).

## Usage

To initialize the loader, provide the project-id of the google cloud project.

## Initializing the reader

```python
from llama_index.readers.firestore import FirestoreReader

reader = FirestoreReader(project_id="<Your Project ID>")
```

## Loading Data from a Firestore Collection

Load data from a Firestore collection with the load_data method:
The collection path should include all previous documents and collections if it is a nested collection.

```python
documents = reader.load_data(collection="foo/bar/abc/")
```

## Loading a Single Document from Firestore

Load a single document from Firestore with the load_document method:

```python
document = reader.load_document(document_url="foo/bar/abc/MY_DOCUMENT")
```

Note: load_data returns a list of Document objects, whereas load_document returns a single Document object.

This loader is designed to be used as a way to load data into [LlamaIndex](https://github.com/run-llama/llama_index/).
llama-index-readers-structured-data 0.4.1
llama-index readers structured_data integration
Requires Python: <4.0,>=3.9

# LlamaIndex Readers Integration: Structured-Data

The function 'StructuredDataReader' supports reading files in JSON, JSONL, CSV, and XLSX formats. It provides parameters 'col_index' and 'col_metadata' to differentiate between columns that should be written into the document's main text and additional metadata.

## Install package

```bash
pip install llama-index-readers-structured-data
```

Or install locally:

```bash
pip install -e llama-index-integrations/readers/llama-index-readers-structured-data
```

## Usage

1. for single document:

```python
from pathlib import Path
from llama_index.readers.structured_data.base import StructuredDataReader

parser = StructuredDataReader(col_index=["col1", "col2"], col_metadata=0)
documents = parser.load_data(Path("your/file/path.json"))
```

2. for dictory of documents:

```python
from pathlib import Path
from llama_index.core import SimpleDirectoryReader
from llama_index.readers.structured_data.base import StructuredDataReader

parser = StructuredDataReader(col_index=[1, -1], col_metadata="col3")
file_extractor = {
    ".xlsx": parser,
    ".csv": parser,
    ".json": parser,
    ".jsonl": parser,
}
documents = SimpleDirectoryReader(
    "your/dic/path", file_extractor=file_extractor
).load_data()
```
llama-index-readers-bilibili 0.4.1
llama-index readers bilibili integration
Requires Python: <4.0,>=3.9

# Bilibili Transcript Loader

```bash
pip install llama-index-readers-bilibili
```

This loader utilizes the `bilibili_api` to fetch the text transcript from Bilibili, one of the most beloved long-form video sites in China.

With this BilibiliTranscriptReader, users can easily obtain the transcript of their desired video content on the platform.

## Usage

To use this loader, you need to pass in an array of Bilibili video links.

```python
from llama_index.readers.bilibili import BilibiliTranscriptReader

loader = BilibiliTranscriptReader()
documents = loader.load_data(
    video_urls=["https://www.bilibili.com/video/BV1yx411L73B/"]
)
```

Note that there is no official API available for Bilibili Transcript, so changes to the official website can sometimes cause issues.

This loader is designed to be used as a way to load data into [Llama Index](https://github.com/run-llama/llama_index/).
llama-index-readers-earnings-call-transcript 0.4.1
llama-index readers earnings_call_transcript integration
Requires Python: <4.0,>=3.9
Keywords: Earning calls, Finance, Investor

# EARNING CALL TRANSCRIPTS LOADER

```bash
pip install llama-index-readers-earnings-call-transcript
```

This loader fetches the earning call transcripts of US based companies from the website [discountingcashflows.com](https://discountingcashflows.com/). It is not available for commercial purposes

Install the required dependencies

```
pip install -r requirements.txt
```

The Earning call transcripts takes in three arguments

- Year
- Ticker symbol
- Quarter name from the list ["Q1","Q2","Q3","Q4"]

## Usage

```python
from llama_index.readers.earnings_call_transcript import EarningsCallTranscript

loader = EarningsCallTranscript(2023, "AAPL", "Q3")
docs = loader.load_data()
```

The metadata of the transcripts are the following

- ticker
- quarter
- date_time
- speakers_list

## Examples

#### Llama Index

```python
from llama_index.core import VectorStoreIndex, download_loader

from llama_index.readers.earnings_call_transcript import EarningsCallTranscript

loader = EarningsCallTranscript(2023, "AAPL", "Q3")
docs = loader.load_data()

index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine()

response = query_engine.query(
    "What was discussed about Generative AI?",
)
print(response)
```

#### Langchain

```python
from langchain.agents import Tool
from langchain.agents import initialize_agent
from langchain.chat_models import ChatOpenAI
from langchain.llms import OpenAI

from llama_index.readers.earnings_call_transcript import EarningsCallTranscript

loader = EarningsCallTranscript(2023, "AAPL", "Q3")
docs = loader.load_data()

tools = [
    Tool(
        name="LlamaIndex",
        func=lambda q: str(index.as_query_engine().query(q)),
        description="useful for questions about investor transcripts calls for a company. The input to this tool should be a complete english sentence.",
        return_direct=True,
    ),
]
llm = ChatOpenAI(temperature=0)
agent = initialize_agent(tools, llm, agent="conversational-react-description")
agent.run("What was discussed about Generative AI?")
```
llama-index-readers-pebblo 0.5.1
llama-index readers pebblo integration
Requires Python: <4.0,>=3.9

# LlamaIndex Readers Integration: Pebblo

## Pebblo Safe DocumentReader

[Pebblo](https://github.com/daxa-ai/pebblo) enables developers to safely load data and promote their Gen AI app to deployment without worrying about the organization’s compliance and security requirements. The project identifies semantic topics and entities found in the loaded data and summarizes them on the UI or a PDF report.

### Pebblo has two components.

1. Pebblo Safe DocumentReader for Llama
2. Pebblo Daemon

This document describes how to augment your existing Llama DocumentReader with Pebblo Safe DocumentReader to get deep data visibility on the types of Topics and Entities ingested into the Gen-AI Llama application. For details on `Pebblo Daemon` see this [pebblo daemon](https://daxa-ai.github.io/pebblo-docs/daemon.html) document.

Pebblo Safe DocumentReader enables safe data ingestion for Llama `DocumentReader`. This is done by wrapping the document reader call with `Pebblo Safe DocumentReader`

#### How to Pebblo enable Document Reading?

Assume a Llama RAG application snippet using `CSVReader` to read a CSV document for inference.

Here is the snippet of Document loading using `CSVReader`

```
from pathlib import Path
from llama_index.readers.file import CSVReader
reader = CSVReader()
documents = reader.load_data(file=Path('data/corp_sens_data.csv'))
print(documents)
```

The Pebblo SafeReader can be installed and enabled with few lines of code change to the above snippet.

##### Install PebbloSafeReader

```
pip install llama-index-readers-pebblo
```

##### Use PebbloSafeReader

```
from pathlib import Path
from llama_index.readers.pebblo import PebbloSafeReader
from llama_index.readers.file import CSVReader
reader = CSVReader()
pebblo_reader = PebbloSafeReader(reader, name="acme-corp-rag-1", # App name (Mandatory)
owner="Joe Smith", # Owner (Optional)
description="Support productivity RAG application")
documents = pebblo_reader.load_data(file=Path('data/corp_sens_data.csv'))
```
llama-index-packs-agent-search-retriever 0.4.1
llama-index packs agent_search_retriever integration
Requires Python: <3.12,>=3.9
Keywords: agent, retriever, search

# Agent-Search Retrieval Pack

This LlamaPack creates a custom retriever that uses the agent-search API for retrieving general content indexed from the internet.

This framework facilitates seamless integration with the AgentSearch dataset (terabytes of indexed data!) or hosted search APIs (e.g. Search Engines).

During query-time, the user passes in the query string, search provider (`bing`, `agent-search`), and relevant nodes are retrieved from the hosted dataset.

To learn more, please refer to the documentation [here](https://agent-search.readthedocs.io/en/latest/).

## CLI Usage

You can download llamapacks directly using `llamaindex-cli`, which comes installed with the `llama-index` python package:

```bash
llamaindex-cli download-llamapack AgentSearchRetrieverPack --download-dir ./agent_search_pack
```

You can then inspect the files at `./agent_search_pack` and use them as a template for your own project!

## Code Usage

You can download the pack to a the `./agent_search_pack` directory:

```python
# Optionally set the API key in the env
# import os
# os.environ["SCIPHI_API_KEY"] = "..."

from llama_index.core.query_engine import RetrieverQueryEngine
from llama_index.core.llama_pack import download_llama_pack

# download and install dependencies
AgentSearchRetrieverPack = download_llama_pack(
    "AgentSearchRetrieverPack", "./agent_search_pack"
)

agent_search_pack = AgentSearchRetrieverPack(
    api_key="...", similarity_top_k=4, search_provider="agent-search"
)

# use the retriever directly
retriever = agent_search_pack.retriever
source_nodes = retriever.retrieve("query str")

# uses the agent-search retriever within a llama-index query engine!
query_engine = RetrieverQueryEngine.from_args(retriever)
response = query_engine.query("query str")
```

The `run()` function is a light wrapper around `retriever.retrieve()`.

```python
source_nodes = agent_search_pack.run("What can you tell me about LLMs?")

print(source_nodes)
```

See the [notebook on llama-hub](https://github.com/run-llama/llama-hub/blob/main/llama_hub/llama_packs/dense_x_retrieval/dense_x_retrieval.ipynb) for a full example.
llama-index-packs-raft-dataset 0.4.1
llama-index packs RAFT Dataset paper implementation
Requires Python: <4.0,>=3.9
Keywords: finetuning, raft, raft_dataset

# RAFT: Adapting Language Model to Domain Specific RAG Llama Pack

This LlamaPack implements RAFT: Adapting Language Model to Domain Specific RAG [paper](https://arxiv.org/abs/2403.10131)

Retrieval Augmented FineTuning (RAFT) is a training recipe introduced in this paper that aims to improve the performance of large language models (LLMs) in open-book, in-domain question-answering tasks. Given a question and a set of retrieved documents, RAFT trains the LLM to identify and cite verbatim the most relevant sequences from the documents that help answer the question, while ignoring irrelevant or distracting information. By explicitly training the model to distinguish between relevant and irrelevant information and to provide evidence from the relevant documents, RAFT encourages the LLM to develop better reasoning and explanation abilities, ultimately improving its ability to answer questions accurately and rationally in scenarios where additional context or knowledge is available.

A key component of RAFT is how the dataset is generated for fine-tuning. Each QA pair also includes an "oracle" document from which the answer to the question can be deduced as well as "distractor" documents which are irrelevant. During training this forces the model to learn which information is relevant/irrelevant and also memorize domain knowledge.

We've implemented the dataset generation part in a LlamaPack. Check out our [full notebook here](https://github.com/run-llama/llama_index/blob/main/llama-index-packs/llama-index-packs-raft-dataset/examples/raft_dataset.ipynb).

### Installation

```bash
pip install llama-index
```

## CLI Usage

You can download llamapacks directly using `llamaindex-cli`, which comes installed with the `llama-index` python package:

```bash
llamaindex-cli download-llamapack RAFTDatasetPack --download-dir ./raft_dataset_pack
```

You can then inspect the files at `./raft_dataset_pack` and use them as a template for your own project.

## Code Usage

You can download the pack to a the `./raft_dataset_pack` directory:

```python
from llama_index.core.llama_pack import download_llama_pack

# download and install dependencies
RAFTDatasetPack = download_llama_pack("RAFTDatasetPack", "./raft_dataset_pack")

# You can use any llama-hub loader to get documents!
raft_dataset = RAFTDatasetPack(file_path)
```

From here, you can use the pack, or inspect and modify the pack in `./raft_dataset_pack`.

The `run()` function contains around logic behind RAFT: Adapting Language Model to Domain Specific RAG [paper](https://arxiv.org/abs/2403.10131)

```python
dataset = raft_dataset.run()
```

This will return the dataset which can be further used for finetuned purpose. Please refer to [original blog](https://techcommunity.microsoft.com/t5/ai-ai-platform-blog/raft-a-new-way-to-teach-llms-to-be-better-at-rag/ba-p/4084674) on using the dataset for fine-tuning.
llama-index-readers-remote-depth 0.4.1
llama-index readers remote_depth integration
Requires Python: <3.12,>=3.9
Keywords: hosted, multiple, url

# Remote Page/File Loader

```bash
pip install llama-index-readers-remote-depth
```

This loader makes it easy to extract the text from the links available in a webpage URL, and extract the links presents in the page. It's based on `RemoteReader` (reading single page), that is based on `SimpleDirectoryReader` (parsing the document if file is a pdf, etc). It is an all-in-one tool for (almost) any group of urls.

You can try with this MIT lecture link, it will be able to extract the syllabus, the PDFs, etc:
`https://ocw.mit.edu/courses/5-05-principles-of-inorganic-chemistry-iii-spring-2005/pages/syllabus/`

## Usage

You need to specify the parameter `depth` to specify how many levels of links you want to extract. For example, if you want to extract the links in the page, and the links in the links in the page, you need to specify `depth=2`.

```python
from llama_index.readers.remote_depth import RemoteDepthReader

loader = RemoteDepthReader()
documents = loader.load_data(
    url="https://ocw.mit.edu/courses/5-05-principles-of-inorganic-chemistry-iii-spring-2005/pages/syllabus/"
)
```

This loader is designed to be used as a way to load data into [LlamaIndex](https://github.com/run-llama/llama_index/).
llama-index-tools-vector-db 0.4.1
llama-index tools vector_db integration
Requires Python: <4.0,>=3.9

# VectorDB Tool

This tool wraps a VectorStoreIndex and enables a agent to call it with queries and filters to retrieve data.

## Usage

```python
from llama_index.tools.vector_db import VectorDB
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
from llama_index.core.vector_stores import VectorStoreInfo
from llama_index.core import VectorStoreIndex

index = VectorStoreIndex(nodes=nodes)
tool_spec = VectorDB(index=index)
vector_store_info = VectorStoreInfo(
    content_info="brief biography of celebrities",
    metadata_info=[
        MetadataInfo(
            name="category",
            type="str",
            description="Category of the celebrity, one of [Sports, Entertainment, Business, Music]",
        ),
        MetadataInfo(
            name="country",
            type="str",
            description="Country of the celebrity, one of [United States, Barbados, Portugal]",
        ),
    ],
)

agent = FunctionAgent(
    tools=tool_spec.to_tool_list(
        func_to_metadata_mapping={
            "auto_retrieve_fn": ToolMetadata(
                name="celebrity_bios",
                description=f"""\
            Use this tool to look up biographical information about celebrities.
            The vector database schema is given below:

            {vector_store_info.json()}

            {tool_spec.auto_retrieve_fn.__doc__}
        """,
                fn_schema=create_schema_from_function(
                    "celebrity_bios", tool_spec.auto_retrieve_fn
                ),
            )
        }
    ),
    llm=OpenAI(model="gpt-4.1"),
)

print(
    await agent.run("Tell me about two celebrities from the United States. ")
)
```

`auto_retrieve_fn`: Retrieves data from the index

This loader is designed to be used as a way to load data as a Tool in a Agent.
llama-index-readers-pandas-ai 0.5.1
llama-index readers pandas_ai integration
Requires Python: <4.0,>=3.9
Keywords: ai, pandas

# Pandas AI Loader

```bash
pip install llama-index-readers-pandas-ai
```

This loader is a light wrapper around the `PandasAI` Python package.

See here: https://github.com/gventuri/pandas-ai.

You can directly get the result of `pandasai.run` command, or
you can choose to load in `Document` objects via `load_data`.

## Usage

```python
from pandasai.llm.openai import OpenAI
import pandas as pd

# Sample DataFrame
df = pd.DataFrame(
    {
        "country": [
            "United States",
            "United Kingdom",
            "France",
            "Germany",
            "Italy",
            "Spain",
            "Canada",
            "Australia",
            "Japan",
            "China",
        ],
        "gdp": [
            21400000,
            2940000,
            2830000,
            3870000,
            2160000,
            1350000,
            1780000,
            1320000,
            516000,
            14000000,
        ],
        "happiness_index": [7.3, 7.2, 6.5, 7.0, 6.0, 6.3, 7.3, 7.3, 5.9, 5.0],
    }
)

llm = OpenAI()

from llama_index.readers.pandas_ai import PandasAIReader

# use run_pandas_ai directly
# set is_conversational_answer=False to get parsed output
loader = PandasAIReader(llm=llm)
response = reader.run_pandas_ai(
    df, "Which are the 5 happiest countries?", is_conversational_answer=False
)
print(response)

# load data with is_conversational_answer=False
# will use our PandasCSVReader under the hood
docs = reader.load_data(
    df, "Which are the 5 happiest countries?", is_conversational_answer=False
)

# load data with is_conversational_answer=True
# will use our PandasCSVReader under the hood
docs = reader.load_data(
    df, "Which are the 5 happiest countries?", is_conversational_answer=True
)
```

This loader is designed to be used as a way to load data into [LlamaIndex](https://github.com/run-llama/llama_index/).