Skip to main content

An integration package connecting OPEA and Haystack

Project description

GitHub License PyPI - Version PyPI - Python Version

Haystack-OPEA

This package contains the Haystack integrations for OPEA Compatible OPEA Microservices. At its core, OPEA offers a suite of containerized microservices—including components for LLMs, embedding, retrieval, and reranking—that can be orchestrated to build sophisticated AI workflows like Retrieval-Augmented Generation (RAG). These microservices are designed for flexibility, supporting deployment across various environments such as cloud platforms, data centers, and edge devices.​

For more information, see Getting Started with OPEA, OPEA Components and Full Examples.

Installation

You can install Haystack OPEA package in several ways:

Install from Source

To install the package from the source, run:

pip install poetry && poetry install --with test

Install from Wheel Package

To install the package from a pre-built wheel, run:

  1. Build the Wheels: Ensure the wheels are built using Poetry.
    poetry build
    
  2. Install via Wheel File: Install the package using the generated wheel file.
    pip install dist/haystack_opea-0.1.0-py3-none-any.whl
    

Examples

See the Examples folder; it contains two jupyter notebooks, using an OPEA LLM and text embedder. The folder also includes a docker compose configuration for starting the OPEA backend.

Embeddings

The classes OPEADocumentEmbedder and OPEATextEmbedder are introduced.

from haystack_opea import OPEATextEmbedder

text_to_embed = "I love pizza!"

text_embedder = OPEATextEmbedder(api_url="http://localhost:6006")
text_embedder.warm_up()

print(text_embedder.run(text_to_embed)

And similarly:

from haystack import Document
from haystack_opea import OPEADocumentEmbedder

doc = Document(content="I love pizza!")

document_embedder = OPEADocumentEmbedder(api_url="http://localhost:6006")
document_embedder.warm_up()

result = document_embedder.run([doc])
print(result["documents"][0].embedding)

LLMs

The class OPEAGenerator is introduced:

from haystack_opea import OPEAGenerator

generator = OPEAGenerator(
    "http://localhost:9009",
    model_arguments={
        "temperature": 0.2,
        "top_p": 0.7,
        "max_tokens": 1024,
    },
)
generator.warm_up()
result = generator.run(prompt="What is the answer?")

For more information, see Haystack Docs and OPEA.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

haystack_opea-0.1.2.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

haystack_opea-0.1.2-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file haystack_opea-0.1.2.tar.gz.

File metadata

  • Download URL: haystack_opea-0.1.2.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.5 Darwin/24.5.0

File hashes

Hashes for haystack_opea-0.1.2.tar.gz
Algorithm Hash digest
SHA256 cf03997449628ccb7e98ec5abc3b41b5cae9ecb41c05bea9419511ccb6a22134
MD5 be56826934f6439417d5e11ec0aff3f6
BLAKE2b-256 f6c506cc8f5772949eeeac61a4beb9853bd821cb31aaf393152b9b884f91f88a

See more details on using hashes here.

File details

Details for the file haystack_opea-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: haystack_opea-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.5 Darwin/24.5.0

File hashes

Hashes for haystack_opea-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8f344af63bc1838d39fe547595ded81094d53efd2d0891becdce4810f825f56c
MD5 3ca67f3cce427f68bf12c96b0dfb0f8f
BLAKE2b-256 1c7c36702ac82883df3b8e840b7dc85d7f40d9322c4b25449da5df8c84157b07

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page