Haystack components to integrate with Together.AI inference models.
Project description
togetherai-haystack
together-haystack
provides Haystack components to use Together.ai models in Haystack pipelines.
[!CAUTION] This project is unofficial, and the authors are not affiliated with either Haystack or Together.AI
At the moment, the integration is limited to embedder components that use Together Embeddings Inference APIs.
TogetherAITextEmbedder
to embed strings / textTogetherAIDocumentEmbedder
to embed a collection of Haystack documents.
Refer to Haystack's documentation to see how these can be plugged-in in Haystack Pipelines to build whatever you need to.
Support for Generators (LLM) and other resources offered by together will be added soon™.
Usage
- Install from pypi using your python dependency manager, e.g.
pip install togetherai-haystack
- Import and use as any haystack component:
>>> from togetherai_haystack.components.embedders import TogetherAITextEmbedder # by default the API KEY is read from the TOGETHER_API_KEY environment variable >>> text_embedder = TogetherTextEmbedder(model="togethercomputer/m2-bert-80M-32k-retrieval") >>> text_embedder.run("Together.ai provides optimized inference endpoints") {'embedding': [-0.3592394, 0.1824189, ...]}
Development
This project uses pdm as a package manager and ruff as a formatter and linter.
The test suite is currently quite bad, there are just two "integration" tests which require a real API key and will invoke the real Together endpoints. These means that:
- You need an account and to set up an API key to run these tests
- These tests require an internet connection and won't work if the environment can't reach https://api.together.xyz/v1 or if Together itself is nonresponsive.
- These tests will use your Together.ai account credit. Though, given their low prices and the minuscule number of tokens used in the tests, each run should cost you ~$0.0000008, meaning you'd have to run them ~12500 times before 1cent is taken from your account.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for togetherai_haystack-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f469997561fbb0a29ecc3d6621d3e5ac1a3309944afc5fec260c0beef26ee0a1 |
|
MD5 | 179a495008da52802959c2ebe4caf4cf |
|
BLAKE2b-256 | 2fe2d6be3304b31b14272ed5a4841a64edc97f08c680cda085c94e1d4622750a |
Hashes for togetherai_haystack-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27041930f6464657e702a739647fbb1ae38ad7542ee947601585a764e4cc6081 |
|
MD5 | 466ec09bb486088c78f72612433011ca |
|
BLAKE2b-256 | ea80c8e61e2644e080f0875e8eccf3fd6b91d12cb055948f4e09176edf33bb8a |