Skip to main content

A minimalist library with as few dependencies as possible.

Project description

Kiori

A minimalist Python agent library with as few dependencies as possible.

Installation

# Basic installation
pip install kiori

# Installation with memory support
pip install "kiori[memory]"

Quick Start

from kiori.agent import KioriAgent
from kiori.models import Action, ActionExample

# Initialize agent
agent = KioriAgent()

# Define an action
def my_func():
    return "Action executed!"

action = Action(
    name="my_action",
    description="Does something cool",
    function_callable=my_func
)
agent.add_action(action)

# Add an example
example = ActionExample(
    user_prompt="Do something cool",
    expected_action_text="my_action()"
)
agent.add_example(example)

# Run agent
agent.run("Do something cool")

Memory (LTM & STM)

Kiori provides memory modules for both Long-Term Memory (LTM) and Short-Term Memory (STM).

Long-Term Memory (MilvusLTM)

Kiori provides a MilvusLTM class using Milvus Lite.

from kiori.memory import MilvusLTM
from kiori.models import ActionExample

# Initialize memory (auto-creates local Milvus Lite DB)
ltm = MilvusLTM()

example = ActionExample(
    user_prompt="Do something cool",
    expected_action_text="my_action()"
)

# Add examples to memory
ltm.add_examples([example])

# Search memory
results = ltm.search("Do something cool", top_k=1)

Short-Term Memory (ReplayBuffer)

ReplayBuffer stores examples from the immediate previous conversation turn.

from kiori.memory import ReplayBuffer

replay_buffer = ReplayBuffer()
replay_buffer.update_buffer([example])

Context Integration

KioriAgent automatically merges contexts from both memory sources.

from kiori.agent import KioriAgent

agent = KioriAgent(ltm=ltm, replay_buffer=replay_buffer)

# Automatically searches LTM and samples STM to generate context examples
ctx = agent.get_context_examples("User's new prompt")
print(ctx)

Routing & Probabilities (MarkovRouter)

Kiori allows combining semantic search (Cosine Similarity) with Markov Chain probabilities to resolve ambiguous prompts based on the conversation history.

from kiori.router import MarkovRouter
from kiori.agent import KioriAgent

# Define transition matrix P(Action_B | Action_A)
transition_matrix = {
    "action_A": {"action_B": 0.9, "action_C": 0.1}
}

router = MarkovRouter(
    transition_matrix=transition_matrix,
    all_actions=["action_A", "action_B", "action_C"]
)

# Initialize agent with alpha (cosine weight) and beta (Markov weight)
agent = KioriAgent(ltm=ltm, router=router, alpha=0.5, beta=0.5)

# If the previous action was "action_A", the agent will scale up "action_B" 
# even if a new user prompt semantically looks slightly more like "action_C".

Philosophy

Kiori is built to be lightweight, easy to understand, and independent of bloated external packages.

License

MIT

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

kiori-0.4.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

kiori-0.4.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file kiori-0.4.0.tar.gz.

File metadata

  • Download URL: kiori-0.4.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for kiori-0.4.0.tar.gz
Algorithm Hash digest
SHA256 946348e3c60a86cd6648796089f622b6824e5876866c14687d5d2da59a942142
MD5 9b00d41e85bafb0d5a67ea0991f071bf
BLAKE2b-256 f7d7537d2ba434506e165ae69843b57e3c41ba6da513a57d570c57c20ce214d3

See more details on using hashes here.

File details

Details for the file kiori-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: kiori-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for kiori-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a432633e5d37b1b1d904a7f1ed670ee0d588ca9169af9fb58b463a197eb8a92
MD5 7535a43c797dbf73a0680032b35db64d
BLAKE2b-256 642e2c9e0918950902fa6a6c5448a889853a7ca790f4673660a34e36936cca44

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