Getting Started with Naylence for Python
This quickstart mirrors the examples/simple/hello.py
sample in the Naylence Python examples repo and shows the minimum to spin up a fabric, serve an agent, and send it a message.
This single-process example runs agent and client in the same process. It’s meant to teach the core Agent SDK concepts without any distributed wiring (no sentinel, no fabric admission URLs, no Docker networking). It starts a local fabric, serves an agent, obtains a typed proxy, makes a call, and prints results.
Prerequisites
- Python 3.12+
pip(or Poetry) and a virtual environment- Access to the Naylence Agent SDK package (hosted on TestPyPI)
1) Install the SDK dependencies
Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activateInstall the dependencies:
pip install naylence-agent-sdk2) Create hello.py
import asyncio
from typing import Any
from naylence.fame.core import FameFabric
from naylence.agent import BaseAgent
class HelloAgent(BaseAgent):
async def on_message(self, message: Any) -> Any:
print(f"Agent received message: {message}")
async def main():
# Start a fabric session and serve the agent
async with FameFabric.create() as fabric:
agent_address = await fabric.serve(HelloAgent())
await fabric.send_message(agent_address, "Hello, World")
if __name__ == "__main__":
asyncio.run(main())3) Run it
python hello.pyExpected output:
Agent received message: Hello, WorldNext steps
- Run more single-process samples from the examples repo, like
echo_agent.py(minimal echo),rpc_agent.py(RPC + streaming), oragent_ping_pong.py(agent-to-agent forwarding). Full list: https://github.com/naylence/naylence-examples-python/tree/main/examples/simple - Explore simple LLM agent examples: https://github.com/naylence/naylence-examples-python/tree/main/examples/llmÂ
Last updated on