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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchainbridge-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 d52dee0368b333f272a7cbaf246efa5027fb1facf67580944cc19c8c6ba5724c
MD5 33d131987b2a046902009ec7addbb2f7
BLAKE2b-256 8f95572d96d3e3cbbb81a6e2deebc5930ec98f996ccbdeaad01f459701c57f2b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchainbridge-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dcebab97c38f08ed41f234cf25de55b9ffb7615af847ed3ba2e7a9d179ea9674
MD5 55d921da7a465961d1a8d37a27a83210
BLAKE2b-256 3237452510d15aa001b3ec822a835939b37801a4d3c1893ab0c9b1777f940ae4

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