Skip to main content

🦜️🔗langchain-nexus

Langchain-Nexus is a versatile Python library that provides a unified interface for interacting with various language models, allowing seamless integration and easy development with models like ChatGPT, GLM, and others.

License: MIT

Quick Install

With pip:

pip install langchain-nexus

🚀 How does LangChain-Nexus help?

📃LLM Model I/O

ChatOpenAI:

from langchain_core.messages import HumanMessage, SystemMessage
from langchain_nexus import ChatOpenAI

chat = ChatOpenAI(temperature=0, openai_api_key="YOUR_API_KEY")
messages = [
    SystemMessage(
        content="You are a helpful assistant that translates English to French."
    ),
    HumanMessage(
        content="Translate this sentence from English to French. I love programming."
    ),
]
chat.invoke(messages)

ChatZhipuAI:

from langchain_core.messages import HumanMessage, SystemMessage
from langchain_nexus import ChatZhipuAI

chat = ChatZhipuAI(temperature=0, zhipuai_api_key="YOUR_API_KEY")
messages = [
    SystemMessage(
        content="You are a helpful assistant that translates English to French."
    ),
    HumanMessage(
        content="Translate this sentence from English to French. I love programming."
    ),
]
chat.invoke(messages)

🧬 Embedding

OpenAIEmbeddings

from langchain_nexus import OpenAIEmbeddings

embeddings_model = OpenAIEmbeddings(openai_api_key="...")

# Embed list of texts
embeddings = embeddings_model.embed_documents(
    [
        "Hi there!",
        "Oh, hello!",
        "What's your name?",
        "My friends call me World",
        "Hello World!"
    ]
)
len(embeddings), len(embeddings[0])

# embed_query
embedded_query = embeddings_model.embed_query("What was the name mentioned in the conversation?")
embedded_query[:5]

ZhipuAIEmbeddings

from langchain_nexus import ZhipuAIEmbeddings

embeddings_model = ZhipuAIEmbeddings(zhipuai_api_key="...")

# Embed list of texts
embeddings = embeddings_model.embed_documents(
    [
        "Hi there!",
        "Oh, hello!",
        "What's your name?",
        "My friends call me World",
        "Hello World!"
    ]
)
len(embeddings), len(embeddings[0])

# embed_query
embedded_query = embeddings_model.embed_query("What was the name mentioned in the conversation?")
embedded_query[:5]

Release files for langchain-nexus 0.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-nexus 0.0.0
File Size Uploaded
langchain_nexus-0.0.0.tar.gz 15.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-nexus 0.0.0
File Interpreter ABI Platform
langchain_nexus-0.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 38.6 kB

Release files / langchain_nexus-0.0.0.tar.gz

Download URL langchain_nexus-0.0.0.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
21b6ba79bd521fb418bdb977cd930355af8d68213719ec0f4bd2e668ec0963a6
BLAKE2b-256 checksum
How to use checksums
743b34070ce99307feb13df34bd8cc8dedcabfd804a7a5fd35e34987455ebbe5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.7

Release files / langchain_nexus-0.0.0-py3-none-any.whl

Download URL langchain_nexus-0.0.0-py3-none-any.whl
Size 23.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b13a5d8572eef219e9d45f4e1035232336a45454afe114ea02c1c4d792b2ec8a
BLAKE2b-256 checksum
How to use checksums
890eb5a2668c1a5a865952cdfde0a511e1aac76e80b898735b179c1348500061
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.7

Release history Release notifications | RSS feed

This release

0.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page