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-1.0.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchainbridge-1.0.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-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f651eed6fd433462113b557bccd39a5ec2c3486c8c037e04824d94f2e36b80ba
MD5 cd861a15a366d0a5a7fb32931871637c
BLAKE2b-256 51232cf7cafe8d0eecfbdbac7dcf94b9935968c1f2eba607665e62cddd8f3d2b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchainbridge-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 921bc8590b6b638336efc73d0f4ae7a6526215f88d7bb5f1f9ce729cf27da0e0
MD5 b8f1bf323326b23851b505b2254ae286
BLAKE2b-256 c6024220743fb70994816e8bad68a96684dd81e30da2448dc22b909f80671433

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