Aller au contenu

Getting Started with Functions

Functions are Python-based Skills that extend your assistants with custom functionality. They use Forra SDK decorators to create callable functions that assistants can use during conversations.

Quick Start: Your First Function

Functions are typically built as part of an Assistant or Global Skill. Choose your deployment target first:

  • Assistants - Functions specific to a single assistant
  • Global Skills - Functions shared across multiple assistants

These guides show how to create, package, and deploy functions as part of their respective containers.

1. Install the Forra SDK

pip install forrasdk

2. Create a Simple Function

Create a file called hello_skill.py:

from pydantic import Field
from forrasdk import forra

@forra.function(description="Say hello world with the name of the user")
def hello_world_function(
    first_name: str = Field(description="The name of the person we want to write a hello world for")
):
    return f"Hello {first_name} World!"

if __name__ == "__main__":
    # Test locally
    print(hello_world_function("Mart"))

3. Test Locally

python hello_skill.py

Expected output:

Hello Mart World!

4. Deploy Your Function

Functions are automatically deployed when you deploy their container Assistants or Global Skills.

For standalone function deployment to an existing assistant:

forracli functions deploy -a {assistant_id} ./hello_skill.py

Learn more about deployment options →

What's Next?

Learn More About Functions

  • Function Types - Explore synchronous functions, async functions, and webhooks
  • Deployment - Package and deploy complex projects with dependencies

Understand Skills Architecture

Additional Topics