Build prompt pipelines easily.
Project description
Conflux
A simple Python library to build prompt pipelines and applications with Large Language Models (LLMs). Conflux is designed for flexibility, composability, and ease of use, making it easy to create complex LLM workflows.
Core Concept
graph LR
subgraph "HandlerChain"
A[Handler 1] -->|Message| B[Handler 2]
B -->|Message| C[Handler 3]
end
Input["Input (Message)"] --> A
C --> Output["Output (Message)"]
Conflux has three main components:
- Messages: Entities in an application communicate through
Messageobjects. - Handlers:
Messages are passed throughHandlers that can modify, transform, or format the message. - HandlerChains:
Handlers are chained together to form aHandlerChain, which executes handlers in order.
Installation
pip install conflux-ai
or, if you use faiss for similarity search:
pip install -U "conflux-ai[faiss]"
Example Usage
import asyncio
from conflux import HandlerChain, Message, handler
from conflux.handlers import OpenAiLLM
@handler
async def company_name(msg: Message, chain: HandlerChain) -> str:
chain.variables["product"] = msg.primary
return (
f"What would be an appropriate name for a business specializing in {msg.primary}?"
"Only mention the company name and nothing else."
)
@handler
async def company_tagline(msg: Message, chain: HandlerChain) -> str:
return (
f"What would be an appropriate tagline for a business specializing in {chain.variables['product']}"
f" and with company name {msg.primary}?\nFormat your output in the following"
f" format:\n{msg.primary}: <tagline>"
)
def main():
name_and_tagline_generator = (
company_name >> OpenAiLLM() >> company_tagline >> OpenAiLLM()
)
res = asyncio.run(name_and_tagline_generator("bike"))
print(res)
if __name__ == "__main__":
main() # Socket: The best socks in the world
Advanced Examples
Explore more advanced usage patterns and integrations in the examples/ directory:
- MCP Tool Call Example: How to call tools from an MCP (Model Context Protocol) server as part of your handler chain.
- Retrieval-Augmented Generation (RAG) Example: How to build a RAG pipeline using OpenAI embeddings and a FAISS vector index.
For more, see the examples/ folder in the repository.
Why Conflux?
Applications with LLMs can get complex quickly. Conflux is designed for simplicity and scalability, giving you control over prompts and execution while maintaining an intuitive API. Unlike more rigid frameworks, Conflux lets you customize every step of your pipeline.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file conflux_ai-0.7.1.tar.gz.
File metadata
- Download URL: conflux_ai-0.7.1.tar.gz
- Upload date:
- Size: 3.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99d55c9c3bb4776bd8e2a1f60668f5d868d67af77da1e06e688c502d2a250353
|
|
| MD5 |
c7c771ec2e2e2d4c21a8163b1362583b
|
|
| BLAKE2b-256 |
2a96014ade3894a3ffab95bed112cb7ae5675c516e991ca8122e87d21614a1c5
|
File details
Details for the file conflux_ai-0.7.1-py3-none-any.whl.
File metadata
- Download URL: conflux_ai-0.7.1-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9793c20299e88dbb17fa3afbad6b922c8960305bb27ce5be2ee22454a630c296
|
|
| MD5 |
a1aa411ef8b992f842915f9324ed2898
|
|
| BLAKE2b-256 |
57ee38546e9a4af50fdced9d793c4ef06217a7ecb83ad31c9139172fd415d594
|