Skip to main content

An integration package connecting Mixedbread AI and LangChain

Project description

langchain-mixedbread-ai

This package contains the LangChain integration with Mixedbread AI

Installation

pip install -U langchain-mixedbread-ai

And you should configure credentials by setting the following environment variables:

  • Get a Mixedbread AI api key and set the environment variable MXBAI_API_KEY to it or use it as a SDK argument.

Embeddings

MixedbreadAIEmbeddings class exposes embeddings from MixedbreadAI.

from langchain_mixedbread_ai import MixedbreadAIEmbeddings

embeddings = MixedbreadAIEmbeddings(mxbai_api_key="a legit baker id")
embeddings.embed_query("What is the meaning of life?")

Rerank

MixedbreadAIRerank class exposes reranker from MixedbreadAI.

from langchain_mixedbread_ai import MixedbreadAIRerank

reranker = MixedbreadAIRerank(mxbai_api_key="a legit baker id", top_n=3)
reranker.rerank(
    query="Who is the author of 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."
  ]
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_mixedbread_ai-0.1.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

langchain_mixedbread_ai-0.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file langchain_mixedbread_ai-0.1.0.tar.gz.

File metadata

File hashes

Hashes for langchain_mixedbread_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 041b6fd639fd123848abceafb6aa4dc8af40beeacc41463dc8345c3e2990cdb0
MD5 a54e36a3f7597683cef6818c4d79808c
BLAKE2b-256 c95ebd595167acb46b17dc4a8b34ed45ecf8da96ab6fbed1532b2e0c6e39c700

See more details on using hashes here.

File details

Details for the file langchain_mixedbread_ai-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_mixedbread_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1b427ca027d4d04fc555f06c262d9f075def85b1e788d65879ec7b2571afb4b7
MD5 d6bbadf190c2509bdd1edd4f7d294c10
BLAKE2b-256 f1f9b3d21817538566b1d50ce891e51973a74169afc626e9b560abda76165b12

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page