Skip to main content

A Python toolkit for working with Large Language Models (LLMs) using LangChain

Project description

LangChainKit

A Python toolkit for working with Large Language Models (LLMs) using LangChain. It provides structured output parsing and multi-provider LLM access.

Features

  • Multi-provider LLM access: Support for local/self-hosted, cloud API, and commercial LLM providers
  • Structured output parsing: Force LLM outputs into Pydantic models with built-in retry logic
  • Batch processing: Concurrent batch requests with configurable concurrency
  • Built-in observability: Integration with Langfuse for tracking and monitoring
  • Lazy initialization: Efficient resource management with lazy loading

Supported LLM Providers

Local/Self-hosted

  • Qwen3 variants with vLLM

Cloud API

  • DashScope Qwen3-235B

Commercial APIs

  • DeepSeek
  • OpenAI GPT-4o

Installation

pip install langchainkit

Quick Start

Basic Usage

from langchainkit import LocalLLM, ApiLLM, GeneralLLM

# Initialize different LLM providers
local_llm = LocalLLM(model="qwen3-32b", api_base="http://localhost:8000/v1")
api_llm = ApiLLM(model="qwen3-235b")
gpt_llm = GeneralLLM(model="gpt-4o")

# Use the LLMs
response = local_llm.invoke("Hello, world!")

Structured Output

from langchainkit import prompt_parsing
from pydantic import BaseModel

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

result = prompt_parsing(
    "What is the capital of France?",
    Response,
    llm=local_llm
)
print(result.answer)  # "Paris"
print(result.confidence)  # 0.95

Configuration

Set up your environment variables:

# For local vLLM instances
export LOCAL_VLLM_API_KEY="your-api-key"

# For cloud APIs
export DASHSCOPE_API_KEY="your-dashscope-key"
export DEEPSEEK_API_KEY="your-deepseek-key"
export OPENAI_API_KEY="your-openai-key"

Development

Installation from Source

git clone https://github.com/AInseven/langchainkit.git
cd langchainkit
pip install -e .

Running Tests

pip install -e ".[dev]"
pytest tests/

Code Quality

# Format code
black langchainkit/

# Sort imports
isort langchainkit/

# Lint code
flake8 langchainkit/

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

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.0.tar.gz (6.1 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.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchainkit-0.1.0.tar.gz
  • Upload date:
  • Size: 6.1 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.0.tar.gz
Algorithm Hash digest
SHA256 6a9c1f0ad27d2631e1aac662d1d0c9e2722a80967ea86957b143336be59a4fc4
MD5 5df0c68195c4b490844a3534d552f9fb
BLAKE2b-256 8f2ff0b80ae721f7bab5977cd2865b8421cba8436a0ea738032576997f704c5b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: langchainkit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.7 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb61867c036fbdc3da33ec9ab8af29948c166e01b2b98e3ab2cc6927e1cb855d
MD5 1e904a3ee9138bfb3b57a545e2fcb1b8
BLAKE2b-256 c3d29a4bb25ae26bb1f7725600f5cedf529bf956e3a5ce4e3b0a4686d949b912

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