Skip to main content

A unified wrapper for various LLM providers using LangChain.

Project description

LangChainBridge

LangChainBridge is a unified wrapper library designed to simplify the use of various Large Language Model (LLM) providers such as Google, OpenAI, Ollama, and Anthropic. By using LangChainBridge, developers can interact with multiple LLMs through a single, consistent interface, reducing complexity and minimizing the risk of errors.

Features

  • Unified API: Interact with different LLM providers through a common interface.
  • Easy Integration: Quickly switch between LLM providers without changing your code logic.
  • Extensibility: Easily add support for new LLM providers as needed.

Installation

Install LangChainBridge using pip:

pip install langchainbridge

Supported Providers

  • Google Generative AI
  • OpenAI
  • Ollama
  • Anthropic

Usage

Initialize the Wrapper

You can initialize the wrapper by specifying the provider using the LLMProvider enum and providing the necessary API key and other parameters.

from langchainbridge.core import LLMWrapper
from langchainbridge.providers.provider_enum import LLMProvider

# For Google
google_llm = LLMWrapper(provider=LLMProvider.GOOGLE, api_key='YOUR_GOOGLE_API_KEY')
response = google_llm.invoke("Where was Shivaji Maharaj born?")
print(response)

# For OpenAI
openai_llm = LLMWrapper(provider=LLMProvider.OPENAI, api_key='YOUR_OPENAI_API_KEY', organization='YOUR_ORG_ID')
response = openai_llm.invoke("What NFL team won the Super Bowl in the year Justin Bieber was born?")
print(response)

# For Ollama
ollama_llm = LLMWrapper(provider=LLMProvider.OLLAMA)
response = ollama_llm.invoke("Summarize the text given to you.")
print(response)

# For Anthropic
anthropic_llm = LLMWrapper(provider=LLMProvider.ANTHROPIC, api_key='YOUR_ANTHROPIC_API_KEY')
response = anthropic_llm.invoke("Translate 'I love programming.' to French.")
print(response)

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

langchainbridge-0.2.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

langchainbridge-0.2.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file langchainbridge-0.2.0.tar.gz.

File metadata

  • Download URL: langchainbridge-0.2.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.6

File hashes

Hashes for langchainbridge-0.2.0.tar.gz
Algorithm Hash digest
SHA256 53442335b02ba422340199204ece6b0d71fe6b8171de8812e82c063f32e3675b
MD5 a83aa88f8f68300099242692daa0e45d
BLAKE2b-256 d4fe358e181009680d11c3912f33b9d5ba0a426def6bf2eb8fbfa9a9a49aad13

See more details on using hashes here.

File details

Details for the file langchainbridge-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchainbridge-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cb55b4b0d0f166303dafb59d9ec047f094f31adf47e5e5b07959da0052cd2c0d
MD5 1f8fec0ff345c69ff0d707ee477899d9
BLAKE2b-256 000727768d2803ebc38816f4c09ebff9e04576846a8f5b0b6a1267e540d265df

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