Skip to main content

LangChainKit makes it easier to work with Qwen3 models via vLLM, and simplifies the process of prompting LLMs to return structured outputs using LangChain and Langfuse.

Project description

LangChainKit

LangChainKit makes it easier to work with Qwen3 models via vLLM, and simplifies the process of prompting LLMs to return structured outputs using LangChain and LangFuse.


🚀 Features

  • 🔧 Simplified Qwen3 + vLLM integration
    Automatically configure enable_thinking and other complex settings for Qwen3 models when using vLLM.

  • 🧠 Structured Output via LangChain
    Easily prompt the LLM to generate structured outputs, including batch prompting support, with minimal setup.

  • 📊 LangFuse Integration
    Track and evaluate LLM performance using LangFuse, without writing boilerplate code.


Installation

pip install langchainkit

Quick Start

Basic Usage

from dotenv import load_dotenv

load_dotenv() # load .env file

from langchainkit import LocalLLM

llm = LocalLLM().qwen3_14b_awq_think
res= llm.invoke('hello')
print(res.content) # Hello! How can I assist you today? 😊

Structured Output

from langchainkit import prompt_parsing
from pydantic import BaseModel

class Response(BaseModel):
    answer: str
    confidence: float

result = prompt_parsing(
    model=Response,
    failed_model=Response(answer="no_answer", confidence=0.0),
    query="What is the capital of France?",
    llm=llm
)
print(result.answer)  # "Paris"
print(result.confidence)  # 1.0

result = prompt_parsing(
    model=Response,
    failed_model=Response(answer="no_answer", confidence=0.0),
    query=["What is the capital of France?",
           "What is the capital of Germany?",
           "What is the capital of Italy?"],
    llm=llm
)
for each in result:
    print(each.answer)
    print(each.confidence)
# Paris
# 0.95
# Berlin
# 0.95
# Rome
# 1.0

Configuration

Set up your environment variables in .env file:

LOCAL_VLLM_BASE_URL=http://172.20.14.28:8000/v1
LOCAL_VLLM_API_KEY=your vLLM api key
LANGFUSE_SECRET_KEY=your langfuse secret key
LANGFUSE_PUBLIC_KEY=your langfuse public key
LANGFUSE_HOST=your langfuse host

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • LangChain for the core framework
  • vLLM for high-throughput LLM inference
  • Langfuse for observability and monitoring

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

langchainkit-0.1.1.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchainkit-0.1.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file langchainkit-0.1.1.tar.gz.

File metadata

  • Download URL: langchainkit-0.1.1.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for langchainkit-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9a32324675adcaaac853f5e1883b6b1d7d5401ff827f547f10252e887389e862
MD5 0447d4fd71856b91be95df510fe5e270
BLAKE2b-256 b3fa58d2e40fcde4fd4496fa6702d430d950f63dfb6e234177195dd0bd8cf40e

See more details on using hashes here.

File details

Details for the file langchainkit-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: langchainkit-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for langchainkit-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0c734243730bc23d2873da864ed1706540615d733c252128c2ea7a1a83619fa4
MD5 0d79feeb4048aea88e2721f632506cb0
BLAKE2b-256 f50534a0c9b060fcb3de97e26005844bb74d2601f8da703b16c0363e910d43f2

See more details on using hashes here.

Supported by

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