semvec/pypi-packages huggingface dataset:
llama-index-tools-openapi 0.5.1
llama-index tools openapi integration
Requires Python: <4.0,>=3.9

# OpenAPI Tool

```bash
pip install llama-index-tools-openapi
```

This tool loads an OpenAPI spec and allow the Agent to retrieve endpoints and details about endpoints. The RequestsToolSpec can also be loaded into the agent to allow the agent to hit the necessary endpoints with a REST request.

## Usage

This tool has 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-openapi/examples/openapi_and_requests.ipynb)

Here's an example usage of the OpenAPIToolSpec.

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

f = requests.get(
    "https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/openai.com/1.2.0/openapi.yaml"
).text
open_api_spec = yaml.safe_load(f)
# OR
open_spec = OpenAPIToolSpec(
    url="https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/openai.com/1.2.0/openapi.yaml"
)


tool_spec = OpenAPIToolSpec(open_api_spec)

agent = FunctionAgent(
    tools=tool_spec.to_tool_list(),
    llm=OpenAI(model="gpt-4.1"),
)

print(await agent.run("What is the base url for the API"))
print(await agent.run("What parameters does the x endpoint need?"))
```

`load_openapi_spec`: Returns the parsed OpenAPI spec that the class was initialized with

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

# Weather Loader

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

This loader fetches the weather data from the [OpenWeatherMap](https://openweathermap.org/api)'s OneCall API, using the `pyowm` Python package. You must initialize the loader with your OpenWeatherMap API token, and then pass in the names of the cities you want the weather data for.

OWM's One Call API provides the following weather data for any geographical coordinate: - Current weather - Hourly forecast for 48 hours - Daily forecast for 7 days

## Usage

To use this loader, you need to pass in an array of city names (eg. [chennai, chicago]). Pass in the country codes as well for better accuracy.

```python
from llama_index.readers.weather import WeatherReader

loader = WeatherReader(token="[YOUR_TOKEN]")
documents = loader.load_data(places=["Chennai, IN", "Dublin, IE"])
```

This loader is designed to be used as a way to load data into [LlamaIndex](https://github.com/run-llama/llama_index/).
llama-index-packs-multidoc-autoretrieval 0.4.1
llama-index packs multidoc_autoretrieval integration
Requires Python: <4.0,>=3.9
Keywords: autoretrieval, document, multi, multidoc, retrieval

# Multi-Document AutoRetrieval (with Weaviate) Pack

This LlamaPack implements structured hierarchical retrieval over multiple documents, using multiple @weaviate_io collections.

## CLI Usage

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

```bash
llamaindex-cli download-llamapack MultiDocAutoRetrieverPack --download-dir ./multidoc_autoretrieval_pack
```

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

## Code Usage

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

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

# download and install dependencies
MultiDocAutoRetrieverPack = download_llama_pack(
    "MultiDocAutoRetrieverPack", "./multidoc_autoretrieval_pack"
)
```

From here, you can use the pack. To initialize it, you need to define a few arguments, see below.

Then, you can set up the pack like so:

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

import weaviate

# cloud
auth_config = weaviate.AuthApiKey(api_key="<api_key>")
client = weaviate.Client(
    "https://<cluster>.weaviate.network",
    auth_client_secret=auth_config,
)

vector_store_info = VectorStoreInfo(
    content_info="Github Issues",
    metadata_info=[
        MetadataInfo(
            name="state",
            description="Whether the issue is `open` or `closed`",
            type="string",
        ),
        ...,
    ],
)

# metadata_nodes is set of nodes with metadata representing each document
# docs is the source docs
# metadata_nodes and docs must be the same length
metadata_nodes = [TextNode(..., metadata={...}), ...]
docs = [Document(...), ...]

pack = MultiDocAutoRetrieverPack(
    client,
    "<metadata_index_name>",
    "<doc_chunks_index_name>",
    metadata_nodes,
    docs,
    vector_store_info,
    auto_retriever_kwargs={
        # any kwargs for the auto-retriever
        ...
    },
)
```

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

```python
response = pack.run("Tell me a bout a Music celebritiy.")
```

You can also use modules individually.

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

# use the query engine
query_engine = pack.query_engine
response = query_engine.query("query_str")
```
llama-index-llms-friendli 0.4.1
llama-index llms friendli integration
Requires Python: <4.0,>=3.9

# LlamaIndex Llms Integration: Friendli

## Installation

1. Install the required Python packages:

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

2. Set the Friendli token as an environment variable:

   ```bash
   %env FRIENDLI_TOKEN=your_token_here
   ```

## Usage

### Basic Chat

To generate a chat response, use the following code:

```python
from llama_index.llms.friendli import Friendli
from llama_index.core.llms import ChatMessage, MessageRole

llm = Friendli()

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

### Streaming Responses

To stream chat responses in real-time:

```python
resp = llm.stream_chat([message])
for r in resp:
    print(r.delta, end="")
```

### Asynchronous Chat

For asynchronous chat interactions, use the following:

```python
resp = await llm.achat([message])
print(resp)
```

### Async Streaming

To handle async streaming of chat responses:

```python
resp = await llm.astream_chat([message])
async for r in resp:
    print(r.delta, end="")
```

### Complete with a Prompt

To generate a completion based on a prompt:

```python
prompt = "Draft a cover letter for a role in software engineering."
resp = llm.complete(prompt)
print(resp)
```

### Streaming Completion

To stream completions in real-time:

```python
resp = llm.stream_complete(prompt)
for r in resp:
    print(r.delta, end="")
```

### Async Completion

To handle async completions:

```python
resp = await llm.acomplete(prompt)
print(resp)
```

### Async Streaming Completion

For async streaming of completions:

```python
resp = await llm.astream_complete(prompt)
async for r in resp:
    print(r.delta, end="")
```

### Model Configuration

To configure a specific model:

```python
llm = Friendli(model="llama-2-70b-chat")
resp = llm.chat([message])
print(resp)
```

### LLM Implementation example

https://docs.llamaindex.ai/en/stable/examples/llm/friendli/
llama-index-readers-airbyte-cdk 0.4.1
llama-index readers airbyte_cdk integration
Requires Python: <4.0,>=3.9

# Airbyte CDK Loader

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

The Airbyte CDK Loader is a shim for sources created using the [Airbyte Python CDK](https://docs.airbyte.com/connector-development/cdk-python/). It allows you to load data from any Airbyte source into LlamaIndex.

## Installation

- Install llama-index reader: `pip install llama-index-readers-airbyte-cdk`
- Install airbyte-cdk: `pip install airbyte-cdk`
- Install a source via git (or implement your own): `pip install git+https://github.com/airbytehq/airbyte.git@master#egg=source_github&subdirectory=airbyte-integrations/connectors/source-github`

## Usage

Implement and import your own source. You can find lots of resources for how to achieve this on the [Airbyte documentation page](https://docs.airbyte.com/connector-development/).

Here's an example usage of the AirbyteCdkReader.

```python
from llama_index.readers.airbyte_cdk import AirbyteCDKReader
from source_github.source import (
    SourceGithub,
)  # this is just an example, you can use any source here - this one is loaded from the Airbyte Github repo via pip install git+https://github.com/airbytehq/airbyte.git@master#egg=source_github&subdirectory=airbyte-integrations/connectors/source-github`


github_config = {
    # ...
}
reader = AirbyteCDKReader(source_class=SourceGithub, config=github_config)
documents = reader.load_data(stream_name="issues")
```

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 = AirbyteCDKReader(
    source_class=SourceGithub,
    config=github_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

If a stream supports it, this loader can be used to load data incrementally (only returning documents that weren't loaded last time or got updated in the meantime):

```python
reader = AirbyteCDKReader(source_class=SourceGithub, config=github_config)
documents = reader.load_data(stream_name="issues")
current_state = reader.last_state  # can be pickled away or stored otherwise

updated_documents = reader.load_data(
    stream_name="issues", 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/).
llama-index-tools-azure-cv 0.4.1
llama-index tools azure_cv integration
Requires Python: <4.0,>=3.9
Keywords: cv, image, vision

# Azure Computer Vision Tool

This tool connects to a Azure account and allows an Agent to perform a variety of computer vision tasks on image urls.

You will need to set up an api key and computer vision instance using Azure, learn more here: https://azure.microsoft.com/en-ca/products/cognitive-services/computer-vision

## 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-azure-cv/examples/azure_vision.ipynb)

Here's an example usage of the AzureCVToolSpec.

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

tool_spec = AzureCVToolSpec(api_key="your-key", resource="your-resource")

agent = FunctionAgent(
    tools=tool_spec.to_tool_list(), llm=OpenAI(model="gpt-4.1")
)

await agent.run(
    "caption this image and tell me what tags are in it https://portal.vision.cognitive.azure.com/dist/assets/ImageCaptioningSample1-bbe41ac5.png"
)
await agent.run(
    "caption this image and read any text https://portal.vision.cognitive.azure.com/dist/assets/OCR3-4782f088.jpg"
)
```

`process_image`: Send an image for computer vision classification of objects, tags, captioning or OCR.

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

# LlamaIndex Llms Integration: Servam

This is the Servam integration for LlamaIndex. Visit [Servam](https://docs.sarvam.ai/api-reference-docs/chat/completions) for information on how to get an API key and which models are supported.

## Installation

```bash
pip install llama-index-llms-servam
```

## Usage

```python
from llama_index.llms.servam import Servam

llm = Servam(model="servam-m", api_key="your-api-key")
```
llama-index-postprocessor-contextual-rerank 0.2.1
llama-index postprocessor contextual rerank integration
Requires Python: <4.0,>=3.9

# Contextual Reranker

This is a Llama_index package that calls Contextual's `/rerank` endpoint. It will rank a list of documents according to their relevance to a query.

The total request cannot exceed 400,000 tokens. The combined length of any document, instruction and the query must not exceed 4,000 tokens. Email [rerank-feedback@contextual.ai](mailto:rerank-feedback@contextual.ai) with any feedback or questions.

## Usage

```python
from llama_index.postprocessor.contextual_rerank import ContextualRerank
from llama_index.core.schema import NodeWithScore, TextNode

nodes = [
    NodeWithScore(node=TextNode(text="the capital of france is paris")),
    NodeWithScore(
        node=TextNode(text="the capital of the United States is Washington DC")
    ),
]

query = "What is the capital of France?"

contextual_rerank = ContextualRerank(
    api_key="key-...",
    model="ctxl-rerank-en-v1-instruct",
    top_n=2,
)

response = contextual_rerank.postprocess_nodes(nodes, query_str=query)

for node in response:
    print(node)
```
llama-index-readers-database 0.5.1
llama-index readers database integration
Requires Python: <4.0,>=3.9
Keywords: aws rds, postgres, snowflake, sql

# LlamaIndex Readers Integration: Database

## Overview

Database Reader is a tool designed to query and load data from databases efficiently.

### Key features

- Accepts connection via `SQLDatabase`, SQLAlchemy `Engine`, full URI, or discrete credentials
- Optional `schema` selection (namespace)
- Column-level metadata mapping (`metadata_cols`) and text exclusion (`excluded_text_cols`)
- Custom `id_` generation function (`document_id`)
- Supports streaming (`lazy_load_data`) and async (`aload_data`)

### Installation

You can install Database Reader via pip:

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

## Usage

```python
from llama_index.readers.database import DatabaseReader

# Initialize DatabaseReader with the SQL database connection details
reader = DatabaseReader(
    sql_database="<SQLDatabase Object>",  # Optional: SQLDatabase object
    engine="<SQLAlchemy Engine Object>",  # Optional: SQLAlchemy Engine object
    uri="<Connection URI>",  # Optional: Connection URI
    scheme="<Scheme>",  # Optional: Scheme
    host="<Host>",  # Optional: Host
    port="<Port>",  # Optional: Port
    user="<Username>",  # Optional: Username
    password="<Password>",  # Optional: Password
    dbname="<Database Name>",  # Optional: Database Name
)

# Load data from the database using a query
documents = reader.load_data(
    query="<SQL Query>"  # SQL query parameter to filter tables and rows
)
```

```python
# Initialize DatabaseReader with the SQL connection string and custom database schema
from llama_index.readers.database import DatabaseReader

reader = DatabaseReader(
    uri="postgresql+psycopg2://user:pass@localhost:5432/mydb",
    schema="warehouse",  # optional namespace
)
# Streaming variant, excluded id from text_resource
for doc in reader.lazy_load_data(
    query="SELECT * FROM warehouse.big_table", excluded_text_cols={"id"}
):
    process(doc)

# Async variant, added region to metadata
docs_async = await reader.aload_data(
    query="SELECT * FROM warehouse.big_table", metadata_cols=["region"]
)
```

```python
# Advanced usage with custom named metadata columns, columns excluded from the `Document.text_resource`, and a dynamic `Document.id_` generated from row data and a fstring template
from llama_index.readers.database import DatabaseReader

reader_media = DatabaseReader(
    uri="postgresql+psycopg2://user:pass@localhost:5432/mydb",
    schema="media",  # optional namespace
)

docs = reader_media.load_data(
    query="SELECT id, title, body, updated_at FROM media.articles",
    metadata_cols=[
        ("id", "article_id"),
        "updated_at",
    ],  # map / include in metadata
    excluded_text_cols=["updated_at"],  # omit from text
    document_id=lambda row: f"media-articles-{row['id']}",  # custom document id
)
```

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-readers-oracleai 0.3.1
llama-index readers oracleai integration
Requires Python: <4.0,>=3.9

# LlamaIndex Readers Integration: Oracleai

There are two classes here:

- OracleReader: This API is to load document(s) from a file or a directory or a Oracle Database table.
- OracleTextSplitter: This API is to split a document into chunks with a lots of customizations.

`pip install llama-index-readers-oracleai`

# A sample example

```python
# get the Oracle connection
conn = oracledb.connect(
    user="",
    password="",
    dsn="",
)
print("Oracle connection is established...")

# params
loader_params = {"owner": "ut", "tablename": "demo_tab", "colname": "data"}
splitter_params = {"by": "words", "max": "100"}

# instances
loader = OracleReader(conn=conn, params=loader_params)
splitter = OracleTextSplitter(conn=conn, params=splitter_params)

print("Processing the documents...")
docs = loader.load()
for id, doc in enumerate(docs, start=1):
    print(f"Document#{id}, Metadata: {doc.metadata}")
    chunks = splitter.split_text(doc.text)
    print(f"Document#{id}, Num of Chunk: {len(chunks)}\n")

conn.close()
print("Connection is closed.")
```
llama-index-tools-requests 0.5.1
llama-index tools requests integration
Requires Python: <4.0,>=3.9

# Requests Tool

This tool provides the agent the ability to make HTTP requests. It can be combined with the OpenAPIToolSpec to interface with an OpenAPI server.

For security reasons, you must specify the hostname for the headers that you wish to provide. See [here for an example](https://github.com/emptycrown/llama-hub/tree/main/llama_hub/tools/notebooks/openapi_and_requests.ipynb)

## Usage

This tool has more extensive example usage documented in a Jupyter notebook [here](https://github.com/emptycrown/llama-hub/tree/main/llama_hub/tools/notebooks/openapi_and_requests.ipynb)

Here's an example usage of the RequestsToolSpec.

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

domain_headers = {
    "api.openai.com": {
        "Authorization": "Bearer sk-your-key",
        "Content-Type": "application/json",
    }
}

tool_spec = RequestsToolSpec(domain_headers=domain_headers)

agent = FunctionAgent(
    tools=tool_spec.to_tool_list(),
    llm=OpenAI(model="gpt-4.1"),
)

print(await agent.run("<query>"))
```

`get_request`: Performs a get request against the URL
`post_request`: Performs a post request against the URL
`patch_request`: Performs a patch request against the URL

This loader is designed to be used as a way to load data as a Tool in a Agent.
llama-index-tools-measurespace 0.2.1
llama-index tools weather, climate, air quality and geocoding integration
Requires Python: >=3.10

# Measure Space Weather, Climate, Air Quality and Geocoding Tool

```bash
pip install llama-index-tools-measurespace
```

This tool connects to the [MeasureSpace](https://measurespace.io/documentation)'s API, using the [measure-space-api](https://pypi.org/project/measure-space-api/) Python package. You must initialize the tool with corresponding API keys from [MeasureSpace](https://measurespace.io/pricing) and [OpenAI](https://platform.openai.com/api-keys) (if you use OpenAI).

The tool has access to the following functions:

- hourly weather forecast (next 5 days)
- daily weather forecast (next 15 days)
- daily climate forecast (next 10 months)
- daily air quality forecast (next 5 days)
- get latitude and longitude from given city names
- get nearest city for given latitude and longitude

## Usage

Assume you have an `.env` file with the following content:

```env
GEOCODING_API_KEY=<your-geocoding-api-key>
HOURLY_WEATHER_API_KEY=<your-hourly-weather-api-key>
DAILY_WEATHER_API_KEY=R<your-daily-weather-api-key>
DAILY_CLIMATE_API_KEY=<your-daily-climate-api-key>
AIR_QUALITY_API_KEY=<your-air-quality-api-key>
OPENAI_API_KEY=<your-openai-api-key>
```

Note that you only need the API keys if you need the services.

```python
from llama_index.tools.measurespace import MeasureSpaceToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
from dotenv import load_dotenv
import os

load_dotenv()

api_keys = {
    "hourly_weather": os.getenv("HOURLY_WEATHER_API_KEY"),
    "daily_weather": os.getenv("DAILY_WEATHER_API_KEY"),
    "daily_climate": os.getenv("DAILY_CLIMATE_API_KEY"),
    "air_quality": os.getenv("AIR_QUALITY_API_KEY"),
    "geocoding": os.getenv("GEOCODING_API_KEY"),
}

tool_spec = MeasureSpaceToolSpec(api_keys)
agent = FunctionAgent(
    tools=tool_spec.to_tool_list(),
    llm=OpenAI(model="gpt-4.1"),
)

print(await agent.run("How's the temperature for New York in next 3 days?"))
print(await agent.run("What's the latitude and longitude of New York?"))

# get a list of tools
for tool in tool_spec.to_tool_list():
    print(tool.metadata.name)

# Use a specific tool
tool_spec.get_daily_weather_forecast("New York")
tool_spec.get_latitude_longitude_from_location("New York")
```
llama-index-tools-zapier 0.4.1
llama-index tools zapier integration
Requires Python: <4.0,>=3.9

# Zapier Tool

This tool connects to a Zapier account and allows access to the natural language actions API. You can learn more about and enable the NLA API here: https://nla.zapier.com/start/

## Usage

This tool has 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-zapier/examples/zapier.ipynb)

Here's an example usage of the ZapierToolSpec.

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


zapier_spec = ZapierToolSpec(api_key="sk-ak-your-key")
## Or
zapier_spec = ZapierToolSpec(api_key="oauth-token")

agent = FunctionAgent(
    tools=zapier_spec.to_tool_list(),
    llm=OpenAI(model="gpt-4.1"),
)

print(await agent.run("what actions are available"))
print(await agent.run("Can you find the taco night file in google drive"))
```

`list_actions`: Get the actions that you have enabled through zapier
`natural_language_query`: Make a natural language query to zapier

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

# MangoppsGuides Loader

```bash
pip install llama-index-readers-mangoapps-guides
```

This loader fetches the text from Mangopps Guides.

## Usage

To use this loader, you need to pass base url of the MangoppsGuides installation (e.g. `https://guides.mangoapps.com/`) and the limit , i.e. max number of links it should crawl

```python
from llama_index.readers.mangoapps_guides import MangoppsGuidesReader

loader = MangoppsGuidesReader()
documents = loader.load_data(
    domain_url="https://guides.mangoapps.com", limit=1
)
```

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