This release is a pre-release and may not be stable for production use.
retrieve-sentence-embeddings
A simple function to retrieve sentence embeddings from an OpenAI Embeddings-compatible API. That includes:
- OpenAI's embedding models (
base_url='https://api.openai.com/v1) - Google Gemini (
base_url='https://generativelanguage.googleapis.com/v1beta/openai') - ollama (
base_url='http://localhost:11434/v1').
with compatible models.
Features
- Compatibility: Unlike openai, works on Python 2+ with zero non-Python dependencies.
Installation
pip install retrieve-sentence-embeddings
Usage
# coding=utf-8
from retrieve_sentence_embeddings import retrieve_sentence_embeddings
api_key = u'OPENAI_API_KEY'
base_url = u'https://api.openai.com/v1'
model = u'text-embedding-ada-002'
sentences = [
u'Hello, world!',
u'This is a test sentence.',
u'Embeddings are useful!'
]
sentence_embeddings = retrieve_sentence_embeddings(api_key, base_url, model, sentences)
sentence_embeddings is a List[List[float]], e.g.,
[
[0.123, -0.982, ...],
[0.222, 0.088, ...],
...
]
Error Handling
If a network error or malformed response is encountered, the exception is propagated.
Contributing
Contributions are welcome! Please submit pull requests or open issues on the GitHub repository.
License
This project is licensed under the MIT License.
Metadata
Release files for retrieve-sentence-embeddings 0.1.0a0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| retrieve_sentence_embeddings-0.1.0a0.tar.gz | 3.4 kB | Without provenance | Details for retrieve_sentence_embeddings-0.1.0a0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| retrieve_sentence_embeddings-0.1.0a0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for retrieve_sentence_embeddings-0.1.0a0-py2.py3-none-any.whl |
Total release size: 7.4 kB
Release files / retrieve_sentence_embeddings-0.1.0a0.tar.gz
| Download URL | retrieve_sentence_embeddings-0.1.0a0.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c0e5f54ff68a24d8c233c0c2ab30b7161d3849ca8a908222577a178efabe0fed
|
|
BLAKE2b-256 checksum How to use checksums |
d595255a27703df5fa9f86b3615c448783cb5467794205e71a31b394ba56cfcc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.2
|
Release files / retrieve_sentence_embeddings-0.1.0a0-py2.py3-none-any.whl
| Download URL | retrieve_sentence_embeddings-0.1.0a0-py2.py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
b02d95d81dc43830025428e57f5a4fd8496d3e348a8b56ad2707edb417800746
|
|
BLAKE2b-256 checksum How to use checksums |
1b4f18a454c9920d985116bac6c7f59ea1ab0675a062a0abf53dd440065688d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.2
|
Security for retrieve-sentence-embeddings 0.1.0a0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.