Skip to main content
Pre-release

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:

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.

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)

Source distribution for retrieve-sentence-embeddings 0.1.0a0
File Size Uploaded
retrieve_sentence_embeddings-0.1.0a0.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for retrieve-sentence-embeddings 0.1.0a0
File Interpreter ABI Platform
retrieve_sentence_embeddings-0.1.0a0-py2.py3-none-any.whl Python 2, Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

0.1.0a0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page