Skip to main content

Experimental aware runtime framework for Python.

Project description

from src.py_alive import AliveTagfrom src.py_alive import alive_tool

PyAlive

Experimental runtime aware framework for Python.

⚠️ Early development version. API may change.

Your Python class is the agent.

from py_alive import BaseAlive, AliveTag, AliveField, alive_agent, alive_tool
import asyncio
from pydantic_ai import AudioUrl
from pydantic_ai.models.test import TestModel


class Translator(BaseAlive):
    """"""
    text: str = AliveField(default="", description="the text to translate")  # this is for the agents. for you its just normal str!
    
    def __init__(self, text: str):
        super().__init__()
        self.text = text
    
    @alive_agent(llms=TestModel(), exclude=["*"]) #include=[AliveTag("memory")]) <- this will cause error in TestModel(). it will call it with memory 'a' - which not exist
    async def translate(self, specific_instruction: str) -> str:
        """translate memory text to hebrew"""
    
    async def some_func(self) -> str:
        self.text += "its a nice day today. do you know that?"
        if len(self.text) > 100:
            return "oy vey"
        else:
            return await self.translate(specific_instruction="also translate it to arabic")
    
    @alive_agent(llms=TestModel(), exclude=['*'])
    async def transcribe_audio(self, url: AudioUrl) -> str:
        """transcript"""



print(asyncio.run(Translator("hello world").translate()))
print(asyncio.run(Translator("hello world").some_func()))
print(asyncio.run(Translator("hello world").transcribe_audio(url=AudioUrl(url=""))))

install

uv add py-alive

concepts

AliveField — the agent's memory. described, typed, visible to agents. # memory cannot be modified now!

name: str = AliveField[str](default="", description="the customer's name")

@alive_agent — turns a method into an agent. docstring is the prompt.

@alive_agent(llm="openai:gpt-4o")
async def summarize(self) -> str:
    """return a 2 sentence summary of memory content"""

<tool description> — wrap part of the docstring to expose the method as a tool to other agents.

async def clean(self) -> str:
    """<cleans and normalizes memory 'text'>
    remove punctuation, lowercase, strip whitespace
    """

AliveTag — group fields or methods, control agent visibility.

# @AliveTag("memory") -> coming soon for memories. for now all memories are under include/exclude=[AliveTag("memory")] 
name: str = AliveField[str](...)

@alive_agent(llm="openai:gpt-4o", include=[AliveTag("memory")])
async def greet(self) -> None: ...

multiple LLMs → list back

@alive_agent(llm=["openai:gpt-4o", "anthropic:claude-sonnet-4-5"])
async def translate(self) -> list[str]:
    """translate memory 'text' to hebrew"""

  • llms are pydantic-ai models. simple usage: pydantic-ai models
  • don't forget to add your env vars,
OPENAI_API_KEY=""
ANTHROPIC_API_KEY=""
GEMINI_API_KEY=""

etc.. (only what you use)

coming soon

t.auto(task="...", include/exclude=[...])  # autonomous agent over all tools
t.export_as_mcp(port=8000)         # instant MCP server
t.graph                            # visualize agent call graph

built on pydantic-ai

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

py_alive-0.0.2.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

py_alive-0.0.2-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file py_alive-0.0.2.tar.gz.

File metadata

  • Download URL: py_alive-0.0.2.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.0

File hashes

Hashes for py_alive-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ecdecbce05e8bbaadea95f8ea63774261d46a76a5b320a97bbe58cec7ad38011
MD5 c8eeca6cdcfceb2294e1dfd02662691f
BLAKE2b-256 f5cf4dc0e87383548358981dcf3ab8cfa1c4a3c6ab204b379d5d4bc14a032169

See more details on using hashes here.

File details

Details for the file py_alive-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: py_alive-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.0

File hashes

Hashes for py_alive-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bcfac19716e2a5978d24849400eb695a15d75c24b27671953d98b6cd43025e68
MD5 4415159b98ee9966a1092f1014296647
BLAKE2b-256 67a6ac56ad78dd42274ab3cbd7034f5730ed4519f82861fc16555bb78f31857b

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