Skip to main content

Pions

A lightweight, modular agent library for building AI agent systems with circuit-based workflows.

Overview

Pions provides a simple yet powerful architecture for building agent-based systems using a circuit-based approach. It includes:

  • Protocol definitions for agents and tools
  • Base classes for extending agent and tool functionality
  • A controller agent for orchestrating complex workflows
  • Circuit components for visualizing and composing agent workflows
  • Example implementations to get started quickly

Core Components

Circuits

Circuits are the fundamental building blocks in Pions. They allow for the composition of agents and tools into complex workflows.

from pions.circuits import CircuitBuilder, CircuitVisualizer

# Create a simple weather information circuit
weather_circuit = CircuitBuilder.series(
    name="Weather Information Circuit",
    components=[
        FunctionComponent(entity_extractor),
        ToolComponent(WeatherTool()),
        FunctionComponent(result_formatter)
    ]
)

# Visualize the circuit
print(CircuitVisualizer.visualize_circuit(weather_circuit, "text"))
print(CircuitVisualizer.visualize_circuit(weather_circuit, "mermaid"))

# Process a query through the circuit
result = await weather_circuit.process({"query": "What's the weather in San Francisco?"})

Agents

Agents are the primary actors in the system. They implement the AgentProtocol and can process queries to produce results.

from pions import Agent

class MyCustomAgent(Agent):
    def __init__(self):
        super().__init__(name="my_custom_agent")
    
    async def process(self, query: str, **kwargs):
        # Implement your agent's logic here
        return {"result": f"Processed: {query}"}

Tools

Tools are utilities that agents can use to perform specific tasks. They implement the ToolProtocol.

from pions import BaseTool

class MyCustomTool(BaseTool):
    def __init__(self):
        super().__init__(name="my_custom_tool")
    
    async def execute(self, *args, **kwargs):
        # Implement your tool's logic here
        return {"result": "Tool executed"}

Controller

The ControllerAgent orchestrates multiple agents and tools, facilitating complex workflows. For more advanced workflows, consider using the circuit-based approach.

from pions import ControllerAgent

# Create controller
controller = ControllerAgent(name="my_controller")

# Register agents and tools
controller.register_agent(my_agent)
controller.register_tool(my_tool)

# Process queries
result = await controller.process("My query", agent_name="my_agent")

# Execute tools directly
tool_result = await controller.execute_tool("my_tool", arg1, arg2)

# Run pipelines
pipeline_result = await controller.run_pipeline(
    "My pipeline query",
    ["agent1", "agent2", "tool1"]
)

Examples

The library includes example implementations in the examples.py and circuit_examples.py modules:

# Traditional agent example
from pions.examples import ResearchAgent, ContentAnalysisAgent

# Create and use example agents
research_agent = ResearchAgent()
result = await research_agent.process("How does AI work?")

# Circuit-based example
from pions.circuit_examples import create_weather_circuit

# Create a weather information circuit
weather_circuit = create_weather_circuit()

# Process a query through the circuit
result = await weather_circuit.process({"query": "What's the weather in San Francisco?"})
print(result.get("formatted_result"))

Installation

pip install pions

Or from source:

git clone https://github.com/janhq/asimov.git
cd asimov
pip install -e .

Dependencies

Pions requires:

  • Python 3.8+
  • bhumi (for LLM inference)
  • numpy (for certain features)
  • typing-extensions

Using with Bhumi

Pions integrates seamlessly with Bhumi for LLM inference:

from bhumi.base_client import BaseLLMClient, LLMConfig
from pions import Agent

class LLMAgent(Agent):
    def __init__(self, name: str, llm_config: dict):
        super().__init__(name=name)
        self.llm_client = BaseLLMClient(LLMConfig(**llm_config))
        
    async def process(self, query: str, **kwargs):
        response = await self.llm_client.generate(query)
        return {"result": response}

# Usage
llm_config = {
    "api_key": "your_api_key",
    "model": "gemini/gemini-1.5-flash-latest",
    "debug": False
}

agent = LLMAgent("my_llm_agent", llm_config)
result = await agent.process("Tell me about quantum computing")

License

MIT License

Metadata

Release files for quarkflow 0.1.2

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

Source distribution (sdist)

Source distribution for quarkflow 0.1.2
File Size Uploaded Provenance
quarkflow-0.1.2.tar.gz 23.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for quarkflow 0.1.2
File Interpreter ABI Platform
quarkflow-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 49.0 kB

Release files / quarkflow-0.1.2.tar.gz

Download URL quarkflow-0.1.2.tar.gz
Size 23.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6388065c143c21960e47b8f84d963a691035ea09d0e311880184789545d5c030
BLAKE2b-256 checksum
How to use checksums
01585adbc525355d387af417a6a119d97b079ea8bd4ba6506d06fb14dc34c918
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.5

Release files / quarkflow-0.1.2-py3-none-any.whl

Download URL quarkflow-0.1.2-py3-none-any.whl
Size 25.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ceaf1bae5032ab413094b6fbdba30f7ee7a65b39dc57db3f4c3f004ecda775d7
BLAKE2b-256 checksum
How to use checksums
9a018924440b899a23bff2b0c4afa429c2e32633e3fdc78c1ae19fa8353ff289
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.5

Security for quarkflow 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

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