Metadata-Version: 2.1
Name: langchain-localai
Version: 1.0.0
Summary: An integration package connecting LocalAI and LangChain
Home-page: https://github.com/mkhludnev/langchain-localai
License: MIT
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: langchain-core (>=1.0.0,<2.0.0)
Requires-Dist: openai (>=1.109.1,<3.0.0)
Project-URL: Repository, https://github.com/mkhludnev/langchain-localai
Project-URL: Release Notes, https://github.com/mkhludnev/langchain-localai/releases?&expanded=true
Project-URL: Source Code, https://github.com/mkhludnev/langchain-localai/tree/main/libs/localai
Description-Content-Type: text/markdown

# langchain-localai

This package contains the LangChain integration with LocalAI

## Installation

```bash
pip install -U langchain-localai
```

## Embeddings

`LocalAIEmbeddings` class exposes embeddings from LocalAI.

```python
from langchain_localai import LocalAIEmbeddings

embeddings = LocalAIEmbeddings(
    openai_api_base="http://localhost:8080",
    model="embedding-model-name")
embeddings.embed_query("What is the meaning of life?")
```

## Reranker

`LocalAIRerank` class exposes reranker from LocalAI.

```python
from langchain_localai import LocalAIRerank
from langchain_core.documents import Document

reranker = LocalAIRerank(
        openai_api_key="foo",
        model="bge-reranker-v2-m3",
        openai_api_base="http://localhost:8080",
    )
reranked_docs = reranker.compress_documents(documents=[
    Document(page_content="bar"),Document(page_content="baz")], query="foo")
