LangPipe: A Lightweight Framework for LLM Pipeline Applications

LangPipe is a lightweight framework designed for building applications with large language models. It provides solutions for various tasks including:

  • Text generation
  • Conversations with LLMs
  • Task classification
  • Parametre extraction
  • Web search-based RAG
  • SQL-based RAG
  • Vector-based RAG
  • Database interactions
  • Web content conversations
  • Knowledge base conversations

LangPipe Repository

The repository contains several sample implementations demonstrating different capabilities:

Chat with LLMs

This example shows basic conversation functionality with language models.

# chat_example.py
from langpipe import LangPipe, LLMNode

# Initialize the pipeline
pipeline = LangPipe()

# Add an LLM node for conversation
chat_node = LLMNode(model="deepseek-r1:8b")
pipeline.add_node(chat_node)

# Run a query
response = pipeline.run("How can I overcome my fears?")
print(response)

Text Generation

Demonstrates text generation capabilities with parameter tuning.

# text_generation.py
from langpipe import LangPipe, GenerationNode

# Create pipeline with generation node
pipeline = LangPipe()
generator = GenerationNode(
    model="deepseek-r1:8b",
    temperature=0.7,
    max_length=500
)
pipeline.add_node(generator)

# Generate text about airplane piloting
result = pipeline.run("Explain how to pilot an airplane")
print(result)

Task Classification

Shows how to classify differetn types of tasks.

# classification.py
from langpipe import LangPipe, ClassificationNode

pipeline = LangPipe()
classifier = ClassificationNode(model="text-classifier")
pipeline.add_node(classifier)

# Classify the task type
task_type = pipeline.run("What are the symptoms of flu?")
print(f"Task type: {task_type}")

Parameter Extraction

Extracts specific parameters from text input.

# extraction.py
from langpipe import LangPipe, ExtractionNode

pipeline = LangPipe()
extractor = ExtractionNode(schema={
    "time": "datetime",
    "location": "string", 
    "event": "string"
})
pipeline.add_node(extractor)

# Extract structured information
data = pipeline.run("Chemical plant explosion in Nantong, Jiangsu at 10:30 AM on March 22, 2025")
print(data)

Search Engine RAG

Implements Retrieval-Augmented Generation using web search.

# search_rag.py
from langpipe import LangPipe, SearchRAGNode

pipeline = LangPipe()
rag_node = SearchRAGNode(search_api="bocha")
pipeline.add_node(rag_node)

# Get information with references
result = pipeline.run("What happened to Xiaomi car in 2025?")
print(result)

SQL-based RAG

Enables natural language queries to databases.

# sql_rag.py
from langpipe import LangPipe, SQLRAGNode

pipeline = LangPipe()
sql_rag = SQLRAGNode(database="ecommerce.db")
pipeline.add_node(sql_rag)

# Query database in natural language
response = pipeline.run("Which user has the most returns?")
print(response)

Vector-based RAG

Uses vector databases for knowledge retrieval.

# vector_rag.py
from langpipe import LangPipe, VectorRAGNode

pipeline = LangPipe()
vector_rag = VectorRAGNode(index="faiss_index")
pipeline.add_node(vector_rag)

# Retrieve from vector database
info = pipeline.run("What is VideoPipe?")
print(info)

Multi-round Chat

Demonstrates conversation with multiple turns.

# multi_chat.py
from langpipe import LangPipe, ChatNode

pipeline = LangPipe()
chat = ChatNode(model="deepseek-r1:8b")
pipeline.add_node(chat)

# Start conversation
while True:
    user_input = input("You: ")
    if user_input.lower() == "exit":
        break
    response = pipeline.run(user_input)
    print(f"AI: {response}")

Database Chat

Enables conversational database queries.

# db_chat.py
from langpipe import LangPipe, DatabaseChatNode

pipeline = LangPipe()
db_chat = DatabaseChatNode(connection="mysql://user:pass@localhost/db")
pipeline.add_node(db_chat)

# Chat with database
response = pipeline.run("Which users bought Coca-Cola and when?")
print(response)

Web Content Chat

Interacts with web content through natural language.

# web_chat.py
from langpipe import LangPipe, WebChatNode

pipeline = LangPipe()
web_chat = WebChatNode()
pipeline.add_node(web_chat)

# Query web content
result = pipeline.run("What major events happened in South Korea in 2025?")
print(result)

Knowledge Base Chat

Chat with local knowledge bases.

# kb_chat.py
from langpipe import LangPipe, KnowledgeBaseChatNode

pipeline = LangPipe()
kb_chat = KnowledgeBaseChatNode(knowledge_base="documents")
pipeline.add_node(kb_chat)

# Query knowledge base
answer = pipeline.run("When does vehicle color recognition algorithm perform poorly?")
print(answer)

Each example demonstrates a different aspect of LangPipe's capabilities, showing how to build complex AI applications with minimal code while maintaining flexibility and power.

Tags: LangPipe LLM RAG python AI framework

Posted on Tue, 30 Jun 2026 17:06:21 +0000 by adnan856