Skip to content

XYBEROS API

The xyberos singleton is the primary entry point for interacting with XYBEROS.

from xyberos import xyberos

Configuration

from xyberos import xyberos, XYBEROS, XyberosConfig

# With explicit config
config = XyberosConfig(llm_backend="ollama", llm_model="llama3")
xyberos = XYBEROS(config=config)

# Auto-load from YAML + env vars
xyberos = XYBEROS(config=XyberosConfig.load())

Methods

chat(message)

Run the full cognitive pipeline: perceive → reason → plan → decide → act → reflect → remember.

ctx = xyberos.chat("What is the capital of France?")
print(f"Thought: {ctx.thought.summary}")
print(f"Action: {ctx.action.name}")
print(f"Result: {ctx.action.metadata}")

Returns a CognitiveContext with: - observation — the original input - thought — perceived analysis - goal — reasoned objective - plan — structured steps - decision — selected action - action — executed result - metadata — cycle timing, errors

achat(message)

Async variant:

ctx = await xyberos.achat("Hello!")

reason(observation, context, strategy)

Run reasoning directly without the full cognitive loop:

conclusion = xyberos.reason(
    "If all humans are mortal and Socrates is human, what follows?",
    strategy="deductive"
)

plan(goal_description)

Generate a plan to achieve a goal:

steps = xyberos.plan("Write a research paper")
for i, step in enumerate(steps, 1):
    print(f"{i}. {step}")

remember(query, limit)

Retrieve relevant memories across all tiers:

memories = xyberos.remember("past conversations about Python", limit=5)
for m in memories:
    print(m)

store_memory(key, content, tier, metadata)

Store a value in a specific memory tier:

xyberos.store_memory(
    "user-preference",
    {"theme": "dark", "language": "Python"},
    tier="semantic"
)

execute(action_name, **params)

Execute a direct action:

result = xyberos.execute("calculator", expression="2 + 2")
print(result)

API Functions

For stateless usage, import functions directly:

from xyberos import chat, reason, plan, remember, execute

ctx = chat("Hello!")
conclusion = reason("If A > B, what follows?", strategy="deductive")
steps = plan("Build a house")
results = remember("previous queries")

These use a shared lazy-initialized xyberos singleton.