https://github.com/danielfleischer/haystack_opea
https://github.com/danielfleischer/haystack_opea
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/danielfleischer/haystack_opea
- Owner: danielfleischer
- License: apache-2.0
- Created: 2025-03-12T13:38:38.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-03-23T11:40:56.000Z (about 1 year ago)
- Last Synced: 2025-04-04T17:52:36.600Z (about 1 year ago)
- Language: Python
- Size: 169 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Haystack-OPEA
This package contains the Haystack integrations for OPEA Compatible [OPEA](https://opea.dev/) Microservices.
## Installation
You can install Haystack OPEA package in several ways:
### Install from Source
To install the package from the source, run:
```bash
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.
```bash
poetry build
```
2. **Install via Wheel File**: Install the package using the generated wheel file.
```bash
pip install dist/haystack_opea-0.1.0-py3-none-any.whl
```
## Embeddings
The classes `OPEADocumentEmbedder` and `OPEATextEmbedder` are introduced.
```python
from haystack_opea.embedders.tei 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:
```python
from haystack import Document
from haystack_opea.embedders.tei 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:
```python
from haystack_opea.generators 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](https://docs.haystack.deepset.ai/docs/intro) and [OPEA](https://opea.dev).