mixedbread-ai


Namemixedbread-ai JSON
Version 2.1.1 PyPI version JSON
download
home_pagehttps://github.com/mixedbread-ai/python-sdk.git
Summarymixedbread ai (https://www.mixedbread.ai)
upload_time2024-04-05 14:40:42
maintainerNone
docs_urlNone
authormixedbread.ai
requires_python<4.0,>=3.8
licenseApache-2.0
keywords embeddings nlp mixedbread.ai
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # mixedbread ai Python SDK

## Table of Contents
- [Requirements](#requirements)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Usage](#usage)
  - [Embeddings](#embeddings)
  - [Reranking](#reranking)
- [Error Handling](#error-handling)
- [API Documentation](#api-documentation)

## Requirements
- Python 3.8+

## Installation
You can install directly using:
```sh
pip install mixedbread-ai
```

## Quick Start
Here's a minimal example to get started with the mixedbread ai SDK:
```python
from mixedbread_ai.client import MixedbreadAI

mxbai = MixedbreadAI(api_key="{YOUR_API_KEY}")

embeddings = mxbai.embeddings(
    model="mixedbread-ai/mxbai-embed-large-v1",
    input=["I like to eat apples."]
)

print(embeddings)
```

## Usage

### Embeddings

Here's an example of using the mixedbread ai SDK to create basic embeddings:
```python
from mixedbread_ai.client import MixedbreadAI

mxbai = MixedbreadAI(api_key="{YOUR_API_KEY}")

embeddings = mxbai.embeddings(
    model="mixedbread-ai/mxbai-embed-large-v1",
    input=["I like to eat apples.", "I like to eat bananas."]
)

print(embeddings)
```

By providing a prompt, you can guide the model to produce embeddings that are optimized for your specific use-case or downstream task.

```python
from mixedbread_ai.client import MixedbreadAI

mxbai = MixedbreadAI(api_key="{YOUR_API_KEY}")

embeddings = mxbai.embeddings(
    model="mixedbread-ai/mxbai-embed-large-v1",
    input=["I like to eat apples.", "I like to eat bananas."],
    prompt="Represent this sentence for searching relevant passages"
)

print(embeddings)
```

By specifying the encoding format, you can leverage f.e. binary embeddings.

```python
from mixedbread_ai.client import MixedbreadAI
from mixedbread_ai.types import EncodingFormat

mxbai = MixedbreadAI(api_key="{YOUR_API_KEY}")

embeddings = mxbai.embeddings(
    model="mixedbread-ai/mxbai-embed-large-v1",
    input=["I like to eat apples.", "I like to eat bananas."],
    encoding_format=[EncodingFormat.FLOAT, EncodingFormat.UBINARY]
)

print(embeddings.data[0].embedding.float_, embeddings.data[0].embedding.ubinary)
```

### Reranking (Asynchronous)
Here's an asynchronous example of using the mixedbread ai SDK to rerank documents:
```python
from mixedbread_ai.client import AsyncMixedbreadAI

mxbai_async = AsyncMixedbreadAI(api_key="{YOUR_API_KEY}")

model = "mixedbread-ai/mxbai-rerank-large-v1"
query = "Who wrote 'To Kill a Mockingbird'?"

documents = [
    "'To Kill a Mockingbird' is a novel by Harper Lee published in 1960. It was immediately successful, winning the Pulitzer Prize, and has become a classic of modern American literature.",
    "The novel 'Moby-Dick' was written by Herman Melville and first published in 1851. It is considered a masterpiece of American literature and deals with complex themes of obsession, revenge, and the conflict between good and evil.",
    "Harper Lee, an American novelist widely known for her novel 'To Kill a Mockingbird', was born in 1926 in Monroeville, Alabama. She received the Pulitzer Prize for Fiction in 1961.",
    "Jane Austen was an English novelist known primarily for her six major novels, which interpret, critique and comment upon the British landed gentry at the end of the 18th century.",
    "The 'Harry Potter' series, which consists of seven fantasy novels written by British author J.K. Rowling, is among the most popular and critically acclaimed books of the modern era.",
    "'The Great Gatsby', a novel written by American author F. Scott Fitzgerald, was published in 1925. The story is set in the Jazz Age and follows the life of millionaire Jay Gatsby and his pursuit of Daisy Buchanan."
]

reranked_docs = await mxbai_async.reranking(
    model=model,
    query=query,
    input=documents
)

print(reranked_docs)
```

Don't forget to replace `"{YOUR_API_KEY}"` with your actual API key. If you don't have an API key, you can get one for free by signing up for an account at [mixedbread.ai](https://mixedbread.ai/).


## Error Handling
The SDK will raise errors if there is an issue with the API request, such as an invalid API key or a network error. Make sure to handle these exceptions in your code.

## API Documentation
For more information on the available methods and options in the mixedbread ai SDK, please refer to our [API documentation](https://mixedbread.ai/api-reference).
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mixedbread-ai/python-sdk.git",
    "name": "mixedbread-ai",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "Embeddings, NLP, mixedbread.ai",
    "author": "mixedbread.ai",
    "author_email": "support@mixedbread.ai",
    "download_url": "https://files.pythonhosted.org/packages/f3/e2/b38a4f4fe1b99cb7932a0543401e42b3b40a3a8b90903849ccd08e17e432/mixedbread_ai-2.1.1.tar.gz",
    "platform": null,
    "description": "# mixedbread ai Python SDK\n\n## Table of Contents\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [Usage](#usage)\n  - [Embeddings](#embeddings)\n  - [Reranking](#reranking)\n- [Error Handling](#error-handling)\n- [API Documentation](#api-documentation)\n\n## Requirements\n- Python 3.8+\n\n## Installation\nYou can install directly using:\n```sh\npip install mixedbread-ai\n```\n\n## Quick Start\nHere's a minimal example to get started with the mixedbread ai SDK:\n```python\nfrom mixedbread_ai.client import MixedbreadAI\n\nmxbai = MixedbreadAI(api_key=\"{YOUR_API_KEY}\")\n\nembeddings = mxbai.embeddings(\n    model=\"mixedbread-ai/mxbai-embed-large-v1\",\n    input=[\"I like to eat apples.\"]\n)\n\nprint(embeddings)\n```\n\n## Usage\n\n### Embeddings\n\nHere's an example of using the mixedbread ai SDK to create basic embeddings:\n```python\nfrom mixedbread_ai.client import MixedbreadAI\n\nmxbai = MixedbreadAI(api_key=\"{YOUR_API_KEY}\")\n\nembeddings = mxbai.embeddings(\n    model=\"mixedbread-ai/mxbai-embed-large-v1\",\n    input=[\"I like to eat apples.\", \"I like to eat bananas.\"]\n)\n\nprint(embeddings)\n```\n\nBy providing a prompt, you can guide the model to produce embeddings that are optimized for your specific use-case or downstream task.\n\n```python\nfrom mixedbread_ai.client import MixedbreadAI\n\nmxbai = MixedbreadAI(api_key=\"{YOUR_API_KEY}\")\n\nembeddings = mxbai.embeddings(\n    model=\"mixedbread-ai/mxbai-embed-large-v1\",\n    input=[\"I like to eat apples.\", \"I like to eat bananas.\"],\n    prompt=\"Represent this sentence for searching relevant passages\"\n)\n\nprint(embeddings)\n```\n\nBy specifying the encoding format, you can leverage f.e. binary embeddings.\n\n```python\nfrom mixedbread_ai.client import MixedbreadAI\nfrom mixedbread_ai.types import EncodingFormat\n\nmxbai = MixedbreadAI(api_key=\"{YOUR_API_KEY}\")\n\nembeddings = mxbai.embeddings(\n    model=\"mixedbread-ai/mxbai-embed-large-v1\",\n    input=[\"I like to eat apples.\", \"I like to eat bananas.\"],\n    encoding_format=[EncodingFormat.FLOAT, EncodingFormat.UBINARY]\n)\n\nprint(embeddings.data[0].embedding.float_, embeddings.data[0].embedding.ubinary)\n```\n\n### Reranking (Asynchronous)\nHere's an asynchronous example of using the mixedbread ai SDK to rerank documents:\n```python\nfrom mixedbread_ai.client import AsyncMixedbreadAI\n\nmxbai_async = AsyncMixedbreadAI(api_key=\"{YOUR_API_KEY}\")\n\nmodel = \"mixedbread-ai/mxbai-rerank-large-v1\"\nquery = \"Who wrote 'To Kill a Mockingbird'?\"\n\ndocuments = [\n    \"'To Kill a Mockingbird' is a novel by Harper Lee published in 1960. It was immediately successful, winning the Pulitzer Prize, and has become a classic of modern American literature.\",\n    \"The novel 'Moby-Dick' was written by Herman Melville and first published in 1851. It is considered a masterpiece of American literature and deals with complex themes of obsession, revenge, and the conflict between good and evil.\",\n    \"Harper Lee, an American novelist widely known for her novel 'To Kill a Mockingbird', was born in 1926 in Monroeville, Alabama. She received the Pulitzer Prize for Fiction in 1961.\",\n    \"Jane Austen was an English novelist known primarily for her six major novels, which interpret, critique and comment upon the British landed gentry at the end of the 18th century.\",\n    \"The 'Harry Potter' series, which consists of seven fantasy novels written by British author J.K. Rowling, is among the most popular and critically acclaimed books of the modern era.\",\n    \"'The Great Gatsby', a novel written by American author F. Scott Fitzgerald, was published in 1925. The story is set in the Jazz Age and follows the life of millionaire Jay Gatsby and his pursuit of Daisy Buchanan.\"\n]\n\nreranked_docs = await mxbai_async.reranking(\n    model=model,\n    query=query,\n    input=documents\n)\n\nprint(reranked_docs)\n```\n\nDon't forget to replace `\"{YOUR_API_KEY}\"` with your actual API key. If you don't have an API key, you can get one for free by signing up for an account at [mixedbread.ai](https://mixedbread.ai/).\n\n\n## Error Handling\nThe SDK will raise errors if there is an issue with the API request, such as an invalid API key or a network error. Make sure to handle these exceptions in your code.\n\n## API Documentation\nFor more information on the available methods and options in the mixedbread ai SDK, please refer to our [API documentation](https://mixedbread.ai/api-reference).",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "mixedbread ai (https://www.mixedbread.ai)",
    "version": "2.1.1",
    "project_urls": {
        "Homepage": "https://github.com/mixedbread-ai/python-sdk.git",
        "Repository": "https://github.com/mixedbread-ai/python-sdk.git"
    },
    "split_keywords": [
        "embeddings",
        " nlp",
        " mixedbread.ai"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "532979c577717159800382add2428e4262f81c93b7e59fa19cba4527aa1c99fa",
                "md5": "99f63c66ef5af069252a5f413dcdd261",
                "sha256": "0cfe20bd15f317ce3b3f4626d96f7442693d3d56285536394d47cab3a675b3d1"
            },
            "downloads": -1,
            "filename": "mixedbread_ai-2.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "99f63c66ef5af069252a5f413dcdd261",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 39686,
            "upload_time": "2024-04-05T14:40:40",
            "upload_time_iso_8601": "2024-04-05T14:40:40.611211Z",
            "url": "https://files.pythonhosted.org/packages/53/29/79c577717159800382add2428e4262f81c93b7e59fa19cba4527aa1c99fa/mixedbread_ai-2.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f3e2b38a4f4fe1b99cb7932a0543401e42b3b40a3a8b90903849ccd08e17e432",
                "md5": "492c21d0787b009f0392d100fcb2a508",
                "sha256": "bc1a61d7e18d02bb9726cb6a9a93efb14e8fb01d5fb01ec9a873ab2afa813330"
            },
            "downloads": -1,
            "filename": "mixedbread_ai-2.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "492c21d0787b009f0392d100fcb2a508",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 19509,
            "upload_time": "2024-04-05T14:40:42",
            "upload_time_iso_8601": "2024-04-05T14:40:42.292665Z",
            "url": "https://files.pythonhosted.org/packages/f3/e2/b38a4f4fe1b99cb7932a0543401e42b3b40a3a8b90903849ccd08e17e432/mixedbread_ai-2.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-05 14:40:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mixedbread-ai",
    "github_project": "python-sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "mixedbread-ai"
}
        
Elapsed time: 0.22723s