semvec/pypi-packages huggingface dataset:
llama-index-readers-singlestore 0.4.1
llama-index readers singlestore integration
Requires Python: <4.0,>=3.9
Keywords: memsql, singlestore

# SingleStore Loader

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

The SingleStore Loader retrieves a set of documents from a specified table in a SingleStore database. The user initializes the loader with database information and then provides a search embedding for retrieving similar documents.

## Usage

Here's an example usage of the SingleStoreReader:

```python
from llama_index.readers.singlestore import SingleStoreReader

# Initialize the reader with your SingleStore database credentials and other relevant details
reader = SingleStoreReader(
    scheme="mysql",
    host="localhost",
    port="3306",
    user="username",
    password="password",
    dbname="database_name",
    table_name="table_name",
    content_field="text",
    vector_field="embedding",
)

# The search_embedding is an embedding representation of your query_vector.
# Example search_embedding:
#   search_embedding=[0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3]
search_embedding = [n1, n2, n3, ...]

# load_data fetches documents from your SingleStore database that are similar to the search_embedding.
# The top_k argument specifies the number of similar documents to fetch.
documents = reader.load_data(search_embedding=search_embedding, top_k=5)
```
llama-index-packs-deeplake-multimodal-retrieval 0.3.1
llama-index packs deeplake_multimodal_retrieval integration
Requires Python: <4.0,>=3.9
Keywords: deeplake, multimodal, retriever

# DeepLake DeepMemory Pack

This LlamaPack inserts your multimodal data (texts, images) into deeplake and instantiates an deeplake retriever, which will use clip for embedding images and GPT4-V during runtime.

## CLI Usage

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

```bash
llamaindex-cli download-llamapack DeepLakeMultimodalRetrieverPack --download-dir ./deeplake_multimodal_pack
```

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

## Code Usage

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

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

# download and install dependencies
DeepLakeMultimodalRetriever = download_llama_pack(
    "DeepLakeMultimodalRetrieverPack", "./deeplake_multimodal_pack"
)
```

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

Then, you can set up the pack like so:

```python
# setup pack arguments
from llama_index.core.vector_stores import MetadataInfo, VectorStoreInfo

# collection of image and text nodes
nodes = [...]

# create the pack
deeplake_pack = DeepLakeMultimodalRetriever(
    nodes=nodes, dataset_path="llama_index", overwrite=False
)
```

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

```python
response = deeplake_pack.run("Tell me a bout a Music celebrity.")
```

You can also use modules individually.

```python
# use the retriever
retriever = deeplake_pack.retriever
nodes = retriever.retrieve("query_str")

# use the query engine
query_engine = deeplake_pack.query_engine
response = query_engine.query("query_str")
```
llama-index-readers-pdf-marker 0.4.1
llama-index readers marker integration
Requires Python: <4.0,>=3.9

# LlamaIndex Readers Integration: Pdf-Marker

Uses the [pdf-marker](https://github.com/VikParuchuri/marker/) library to extract the content of a PDF file.

From the original README:

Marker converts PDF to markdown quickly and accurately.

- Supports a wide range of documents (optimized for books and scientific papers)
- Supports all languages
- Removes headers/footers/other artifacts
- Formats tables and code blocks
- Extracts and saves images along with the markdown
- Converts most equations to latex
- Works on GPU, CPU, or MPS

## Usage

Here's an example usage of the PDFMarkerReader.

```python
from llama_index.readers.pdf_marker import PDFMarkerReader
from pathlib import Path

path = Path("/path/to/pdf")
reader = PDFMarkerReader()
reader.load_data(path)
```

## License

The marker-pdf library is licensed under the GPL-3.0 license (see https://github.com/VikParuchuri/marker), meaning that you may copy, distribute and modify the software as long as you track changes/dates in source files.
Any modifications to or software including (via compiler) GPL-licensed code must also be made available under the GPL along with build & install instructions.

There is also commercial usage limitations (see https://github.com/VikParuchuri/marker?tab=readme-ov-file#commercial-usage).
llama-index-tools-exa 0.4.1
llama-index tools exa integration
Requires Python: <4.0,>=3.9

# LlamaIndex Tools Integration: Exa

This tool connects to [Exa](https://exa.ai/) to easily enable
your agent to search and get HTML content from the Internet.

To begin, you need to obtain an API key on the [Exa developer dashboard](https://dashboard.exa.ai).

## Usage

This tool has more a extensive example usage documented in a Jupyter notebook [here](https://github.com/run-llama/llama_index/blob/main/llama-index-integrations/tools/llama-index-tools-exa/examples/exa.ipynb)

Here's an example usage of the ExaToolSpec.

```python
# %pip install llama-index llama-index-core llama-index-tools-exa

from llama_index.tools.exa import ExaToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

exa_tool = ExaToolSpec(
    api_key=os.environ["EXA_API_KEY"],
)
agent = FunctionAgent(
    tools=exa_tool.to_tool_list(),
    llm=OpenAI(model="gpt-4.1"),
)

print(
    await agent.run(
        "Can you summarize the news published in the last month on superconductors"
    )
)
```

`search`: Search for a list of articles relating to a natural language query

`retrieve_documents`: Retrieve a list of documents returned from `exa_search`.

`search_and_retrieve_documents`: Combines search and retrieve_documents to directly return a list of documents related to a search

`find_similar`: Find similar documents to a given URL.

`current_date`: Utility for the Agent to get todays date

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

# LlamaIndex Readers Integration: Elasticsearch

## Overview

Elasticsearch (or Opensearch) Reader over REST API is a tool designed to read documents from an Elasticsearch or Opensearch index using the basic search API. These documents can then be utilized in downstream LlamaIndex data structures.

### Installation

You can install Elasticsearch (or Opensearch) Reader via pip:

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

## Usage

```python
from llama_index.core.schema import Document
from llama_index.readers.elasticsearch import ElasticsearchReader

# Initialize ElasticsearchReader
reader = ElasticsearchReader(
    endpoint="<Your Elasticsearch/Opensearch Endpoint>",
    index="<Index Name>",
    httpx_client_args={
        "timeout": 10
    },  # Optional additional arguments for the httpx.Client
)

# Load data from Elasticsearch
documents = reader.load_data(
    field="<Field Name>",  # Field in the document to retrieve text from
    query={"query": {"match_all": {}}},  # Elasticsearch JSON query DSL object
    embedding_field="<Embedding Field>",  # Field for embeddings (optional)
)
```

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) and/or subsequently
used as a Tool in a [LangChain](https://github.com/hwchase17/langchain) Agent.
llama-index-tools-openai-image-generation 0.5.1
llama-index tools openai_image_generation integration
Requires Python: <4.0,>=3.9
Keywords: cv, gpt-3, image, openai, vision

# OpenAI Image Generation Tool

This tool allows Agents to generate images using OpenAI's DALL-E model. To see more and get started, visit https://openai.com/blog/dall-e/

## Usage

This tool has a more extensive example usage documented in a Jupyter notebook [here](https://github.com/run-llama/llama_index/blob/main/llama-index-integrations/tools/llama-index-tools-openai/examples/multimodal_openai_image.ipynb).

### Usage with Agent

```python
from llama_index.tools.openai import OpenAIImageGenerationToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

image_generation_tool = OpenAIImageGenerationToolSpec(
    api_key=os.environ["OPENAI_API_KEY"]
)

agent = FunctionAgent(
    tools=[*image_generation_tool.to_tool_list()],
    llm=OpenAI(model="gpt-4.1"),
)

print(
    await agent.run(
        "A pink and blue llama in a black background with the output"
    )
)
```

### Usage directly

```python
from llama_index.tools.openai import OpenAIImageGenerationToolSpec

image_generation_tool = OpenAIImageGenerationToolSpec(
    api_key=os.environ["OPENAI_API_KEY"]
)

image_data = image_generation_tool.image_generation(
    text="A pink and blue llama with a black background",
    response_format="b64_json",
)

image_bytes = base64.b64decode(image_data)

img = Image.open(BytesIO(image_bytes))

display(img)
```

`image_generation`: Takes an text input and generates an image

This loader is designed to be used as a way to load data as a Tool in a Agent.
llama-index-llms-mymagic 0.4.1
llama-index llms mymagic integration
Requires Python: <4.0,>=3.9

# LlamaIndex Llms Integration: Mymagic

## Installation

To install the required package, run:

```bash
%pip install llama-index-llms-mymagic
!pip install llama-index
```

## Setup

Before you begin, set up your cloud storage bucket and grant MyMagic API secure access. For detailed instructions, visit the [MyMagic documentation](https://docs.mymagic.ai).

### Initialize MyMagicAI

Create an instance of MyMagicAI by providing your API key and storage configuration:

```python
from llama_index.llms.mymagic import MyMagicAI

llm = MyMagicAI(
    api_key="your-api-key",
    storage_provider="s3",  # Options: 's3' or 'gcs'
    bucket_name="your-bucket-name",
    session="your-session-name",  # Directory for batch inference
    role_arn="your-role-arn",
    system_prompt="your-system-prompt",
    region="your-bucket-region",
    return_output=False,  # Set to True to return output JSON
    input_json_file=None,  # Input file stored on the bucket
    list_inputs=None,  # List of inputs for small batch
    structured_output=None,  # JSON schema of the output
)
```

> **Note:** If `return_output` is set to `True`, `max_tokens` should be at least 100.

### Generate Completions

To generate a text completion for a question, use the `complete` method:

```python
resp = llm.complete(
    question="your-question",
    model="choose-model",  # Supported models: mistral7b, llama7b, mixtral8x7b, codellama70b, llama70b, etc.
    max_tokens=5,  # Number of tokens to generate (default is 10)
)
print(
    resp
)  # The response indicates if the final output is stored in your bucket or raises an exception if the job failed
```

### Asynchronous Requests

For asynchronous operations, use the `acomplete` endpoint:

```python
import asyncio


async def main():
    response = await llm.acomplete(
        question="your-question",
        model="choose-model",  # Supported models listed in the documentation
        max_tokens=5,  # Number of tokens to generate (default is 10)
    )
    print("Async completion response:", response)


await main()
```

### LLM Implementation example

https://docs.llamaindex.ai/en/stable/examples/llm/mymagic/
llama-index-voice-agents-gemini-live 0.2.1
LlamaIndex x Gemini Live integration
Requires Python: <4.0,>=3.9

# LlamaIndex x Gemini Live Integration

Integration between LlamaIndex and Google Gemini Live. Install the integration with:

```bash
pip install llama-index-voice-agents-gemini-live
```

And test it with the following minimal example:

```python
from llama_index.voice_agents.gemini_live import GeminiLiveVoiceAgent
from llama_index.core.tools import FunctionTool
from llama_index.core.voice_agents import BaseVoiceAgentEvent
from llama_index.core.llms import ChatMessage, TextBlock
from typing import List
import random
import json


# use filter functions to export messages and events without your terminal being swamped by base64-encoded audio bytes :)
def filter_events(
    events: List[BaseVoiceAgentEvent],
) -> List[BaseVoiceAgentEvent]:
    evs = []
    for event in events:
        if not "audio" in event.type_t:
            evs.append(event)
    return evs


def filter_messages(messages: List[ChatMessage]) -> List[ChatMessage]:
    msgs = []
    for message in messages:
        msg = ChatMessage(role=message.role, blocks=[])
        for b in message.blocks:
            if isinstance(b, TextBlock):
                msg.blocks.append(b)
        if len(msg.blocks) > 0:
            msgs.append(msg)
    return msgs


def get_weather(location: str) -> dict:
    """Fetch weather data for a given location."""
    return json.dumps(
        {
            "location": location,
            "temperature_c": round(random.uniform(15, 30), 1),
            "humidity_percent": random.randint(40, 90),
            "wind_speed_kmh": round(random.uniform(5, 25), 1),
            "precipitation_probability_percent": random.randint(0, 100),
        },
        indent=4,
    )


weather_tool = FunctionTool.from_defaults(
    fn=get_weather,
    name="get_weather",
    description="Get the weather at a given location",
)


async def main():
    conversation = GeminiLiveVoiceAgent(tools=[weather_tool])

    await conversation.start()

    if conversation._quitflag:
        print("Events")
        print(conversation.export_events(filter=filter_events))
        print()
        print("Messages")
        print(conversation.export_messages(filter=filter_messages))


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())
```

Remember that:

- You have to either set `GOOGLE_API_KEY` as env variable or pass the `api_key` when initializing `GoogleGeminiVoiceAgent`
- You have to start the conversation
llama-index-llms-vercel-ai-gateway 0.1.1
llama-index llms vercel ai gateway integration
Requires Python: <4.0,>=3.9

# LlamaIndex Llms Integration: Vercel AI Gateway

## Installation

To install the required packages, run:

```bash
%pip install llama-index-llms-vercel-ai-gateway
!pip install llama-index
```

## Setup

### Initialize Vercel AI Gateway

You need to set either the environment variable `VERCEL_AI_GATEWAY_API_KEY`, `VERCEL_OIDC_TOKEN`, or pass your API key directly in the class constructor. Replace `<your-api-key>` with your actual API key:

```python
from llama_index.llms.vercel_ai_gateway import VercelAIGateway
from llama_index.core.llms import ChatMessage

llm = VercelAIGateway(
    api_key="<your-api-key>",
    max_tokens=200000,
    context_window=64000,
    model="anthropic/claude-4-sonnet",
)
```

## Generate Chat Responses

You can generate a chat response by sending a list of `ChatMessage` instances:

```python
message = ChatMessage(role="user", content="Tell me a joke")
resp = llm.chat([message])
print(resp)
```

### Streaming Responses

To stream responses, use the `stream_chat` method:

```python
message = ChatMessage(role="user", content="Tell me a story in 250 words")
resp = llm.stream_chat([message])
for r in resp:
    print(r.delta, end="")
```

### Complete with Prompt

You can also generate completions with a prompt using the `complete` method:

```python
resp = llm.complete("Tell me a joke")
print(resp)
```

### Streaming Completion

To stream completions, use the `stream_complete` method:

```python
resp = llm.stream_complete("Tell me a story in 250 words")
for r in resp:
    print(r.delta, end="")
```

## Model Configuration

To use a specific model, you can specify it during initialization. For example, to use Anthropic's Claude 3 Sonnet model, you can set it like this:

```python
llm = VercelAIGateway(model="anthropic/claude-4-sonnet")
resp = llm.complete("Write a story about a dragon who can code in Rust")
print(resp)
```

### LLM Implementation example

https://docs.llamaindex.ai/en/stable/examples/llm/vercel-ai-gateway/
llama-index-postprocessor-rankllm-rerank 0.6.1
llama-index postprocessor rankllm-rerank integration
Requires Python: <4.0,>=3.10

# LlamaIndex Postprocessor Integration: Rankllm-Rerank

RankLLM offers a suite of rerankers, albeit with focus on open source LLMs finetuned for the task. To use a model offered by the RankLLM suite, pass the desired model's **Hugging Face model path**, found at [Castorini's Hugging Face](https://huggingface.co/castorini).

e.g., to access `LiT5-Distill-base`, pass [`castorini/LiT5-Distill-base`](https://huggingface.co/castorini/LiT5-Distill-base) as the model name.

For more information about RankLLM and the models supported, visit **[rankllm.ai](http://rankllm.ai)**. Please `pip install llama-index-postprocessor-rankllm-rerank` to install RankLLM rerank package.

#### Parameters:

- `model`: Reranker model name
- `top_n`: Top N nodes to return from reranking
- `window_size`: Reranking window size. Applicable only for listwise and pairwise models.
- `batch_size`: Reranking batch size. Applicable only for pointwise models.

#### Model Coverage

Below are all the rerankers supported with the model name to be passed as an argument to the constructor. Some model have convenience names for ease of use:

**Listwise**:

- **RankZephyr**. model=`rank_zephyr` or `castorini/rank_zephyr_7b_v1_full`
- **RankVicuna**. model=`rank_zephyr` or `castorini/rank_vicuna_7b_v1`
- **RankGPT**. Takes in a _valid_ gpt model. e.g., `gpt-3.5-turbo`, `gpt-4`,`gpt-3`
- **LiT5 Distill**. model=`castorini/LiT5-Distill-base`
- **LiT5 Score**. model=`castorini/LiT5-Score-base`

**Pointwise**:

- MonoT5. model='monot5'

### 💻 Example Usage

```
pip install llama-index-core
pip install llama-index-llms-openai
from llama_index.postprocessor.rankllm_rerank import RankLLMRerank
```

First, build a vector store index with [llama-index](https://pypi.org/project/llama-index/).

```
index = VectorStoreIndex.from_documents(
    documents,
)
```

To set up the _retriever_ and _reranker_:

```
query_bundle = QueryBundle(query_str)

# configure retriever
retriever = VectorIndexRetriever(
    index=index,
    similarity_top_k=vector_top_k,
)

# configure reranker
reranker = RankLLMRerank(
    model=model_name
    top_n=reranker_top_n,
)
```

To run _retrieval+reranking_:

```
# retrieve nodes
retrieved_nodes = retriever.retrieve(query_bundle)

# rerank nodes
reranked_nodes = reranker.postprocess_nodes(
    retrieved_nodes, query_bundle
)
```

### 🔧 Dependencies

Currently, RankLLM rerankers require `CUDA` and for `rank-llm` to be installed (`pip install rank-llm`). The built-in retriever, which uses [Pyserini](https://github.com/castorini/pyserini), requires `JDK11`, `PyTorch`, and `Faiss`.

### `castorini/rank_llm`

Repository for prompt-decoding using LLMs: **[http://rankllm.ai](http://rankllm.ai)**
llama-index-readers-graphdb-cypher 0.4.1
llama-index readers graphdb_cypher integration
Requires Python: <4.0,>=3.9
Keywords: cypher, graph, neo4j

# Graph Database Cypher Loader

```bash
pip install llama-index-readers-graphdb-cypher
```

This loader populates documents from results of Cypher queries from a Graph database endpoint.
The user specifies a GraphDB endpoint URL with optional credentials to initialize the reader.
By declaring the Cypher query and optional parameters the loader can fetch the nested result docs.
The results will be turned into a yaml representation to be turned into a string for the document.

The approach should work for Neo4j, AWS Neptune and Memgraph.

## Usage

Here's an example usage of the `GraphDBCypherReader`.

You can test out queries directly with the Neo4j labs demo server: demo.neo4jlabs.com or with a free instance https://neo4j.com/aura

```python
import os

from llama_index.readers.graphdb_cypher import GraphDBCypherReader

uri = "neo4j+s://demo.neo4jlabs.com"
username = "stackoverflow"
password = "stackoverflow"
database = "stackoverflow"

query = """
    MATCH (q:Question)-[:TAGGED]->(:Tag {name:$tag})
    RETURN q.title as title
    ORDER BY q.createdAt DESC LIMIT 10
"""
reader = GraphDBCypherReader(uri, username, password, database)
documents = reader.load_data(query, parameters={"tag": "lua"})
```

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)
and/or subsequently used as a Tool in a [LangChain](https://github.com/hwchase17/langchain) Agent.

It uses the [Neo4j Graph Database](https://neo4j.com/developer) for the Cypher queries.
llama-index-readers-airbyte-hubspot 0.4.1
llama-index readers airbyte_hubspot integration
Requires Python: <4.0,>=3.9

# Airbyte Hubspot Loader

```bash
pip install llama-index-readers-airbyte-hubspot
```

The Airbyte Hubspot Loader allows you to access different Hubspot objects.

## Usage

Here's an example usage of the AirbyteHubspotReader.

```python
from llama_index.readers.airbyte_hubspot import AirbyteHubspotReader

hubspot_config = {
    # ...
}
reader = AirbyteHubspotReader(config=hubspot_config)
documents = reader.load_data(stream_name="products")
```

## Configuration

Check out the [Airbyte documentation page](https://docs.airbyte.com/integrations/sources/hubspot/) for details about how to configure the reader.
The JSON schema the config object should adhere to can be found on Github: [https://github.com/airbytehq/airbyte/blob/master/airbyte-integrations/connectors/source-hubspot/source_hubspot/spec.yaml](https://github.com/airbytehq/airbyte/blob/master/airbyte-integrations/connectors/source-hubspot/source_hubspot/spec.yaml).

The general shape looks like this:

```python
{
    "start_date": "<date from which to start retrieving records from in ISO format, e.g. 2020-10-20T00:00:00Z>",
    "credentials": {
        "credentials_title": "Private App Credentials",
        "access_token": "<access token of your private app>",
    },
}
```

By default all fields are stored as metadata in the documents and the text is set to the JSON representation of all the fields. Construct the text of the document by passing a `record_handler` to the reader:

```python
def handle_record(record, id):
    return Document(
        doc_id=id, text=record.data["title"], extra_info=record.data
    )


reader = AirbyteHubspotReader(
    config=hubspot_config, record_handler=handle_record
)
```

## Lazy loads

The `reader.load_data` endpoint will collect all documents and return them as a list. If there are a large number of documents, this can cause issues. By using `reader.lazy_load_data` instead, an iterator is returned which can be consumed document by document without the need to keep all documents in memory.

## Incremental loads

This loader supports loading data incrementally (only returning documents that weren't loaded last time or got updated in the meantime):

```python
reader = AirbyteHubspotReader(config={...})
documents = reader.load_data(stream_name="products")
current_state = reader.last_state  # can be pickled away or stored otherwise

updated_documents = reader.load_data(
    stream_name="products", state=current_state
)  # only loads documents that were updated since last time
```

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