GhostOS Moss

raw JSON →
0.3.7 verified Sat May 09 auth: no python

GhostOS Moss is a code-driven Python interface for LLMs, agents, and the GhostOS project. It provides a functional reactive programming model for building AI agents with Python code. Current version 0.3.7, requires Python >=3.10. This package is part of the GhostOS ecosystem and is under active development, with frequent releases on PyPI.

pip install ghostos-moss
error ImportError: cannot import name 'Moss' from 'ghostos'
cause Trying to import Moss directly from the top-level ghostos package instead of ghostos.moss submodule.
fix
Use from ghostos.moss import Moss instead of from ghostos import Moss.
error AttributeError: 'MyAgent' object has no attribute 'respond'
cause The agent class defined by the user does not have a respond method, or the method signature is incorrect.
fix
Ensure your agent subclass defines def respond(self, user_input: str) -> str: method.
error TypeError: 'NoneType' object is not callable when using @moss_function
cause The decorated function does not have a return type annotation, causing the decorator to return None.
fix
Add a return type annotation to the function, e.g., @moss_function def my_action() -> str:.
breaking In version 0.3.0, the API for defining actions changed: `moss_function` now requires explicit return type annotations. Without them, the function will not be recognized as an action and may silently fail.
fix Ensure all functions decorated with `@moss_function` have a return type annotation, e.g., `def my_action() -> str:`.
deprecated The `MossAction` class from `ghostos.moss.actions` is deprecated since 0.2.5 and will be removed in 0.4.0. Use `@moss_function` decorator instead.
fix Replace `class MyAction(MossAction): ...` with `@moss_function` decorator on a function.
gotcha Import `MossAgent` from `ghostos.agent`, not from `ghostos.moss`. The agent module is separate and contains the base class for agents.
fix Use `from ghostos.agent import MossAgent`.

Initialize a Moss instance, create an agent by subclassing MossAgent, and define a respond method.

from ghostos.moss import Moss
from ghostos.agent import MossAgent

# Create a Moss instance
moss = Moss()

# Define a simple agent
class MyAgent(MossAgent):
    def respond(self, user_input: str) -> str:
        return f"Echo: {user_input}"

# Instantiate and run
agent = MyAgent()
print(agent.respond("Hello"))