Skip to main content

⚡️ actions-core

A Python library designed to simplify the development of Python actions (AI or otherwise) to be run with the Actions Runtime.

Getting started

If you have not setup Action Server already, see the 🏃‍♂️ Quickstart on how to do that.

Decorate your Python function with the @action decorator:

from actions import action

@action
def sum_numbers(a: float, b: float) -> float:
    ...

And your function is now an ⚡️Action!

You can now run and debug your action by Starting Action Server with action-server start and accessing the UI at http://localhost:8080.

Note: Action inputs and outputs support only int, float, str and bool types.

Describe your action

For an action's purpose and usage to be understood by AI models (and humans) it needs to be documented correctly.

To do that, use Google Style Docstring to write a clear and concise description on what your action does and document the action inputs and expected output:

@action
def get_weather_forecast(city: str, days: int, scale: str = "celsius") -> str:
    """
    Returns weather conditions forecast for a given city.

    Args:
        city (str): Target city to get the weather conditions for
        days: How many day forecast to return
        scale (str): Temperature scale to use, should be one of "celsius" or "fahrenheit"

    Returns:
        str: The requested weather conditions forecast
    """
    ...

Tip: Experiment with and iterate the exact documentation wording to get more predictable results when using your action with AI apps.


Consequential flag

You can explicitly provide the is_consequential flag for an action to mark it's operations as "must always prompt the user for confirmation before running" by OpenAI GPTs (and possibly by other providers). If set to False, the user will be provided with an "always allow" feature.

@action(is_consequential=True)
def get_weather_forecast(city: str, days: int, scale: str = "celsius") -> str:

Working with Secrets

Actions can work with sensitive credentials by using the Secret type from the actions library. Secrets are handled securely and will not be exposed in logs or the API documentation.

from actions import action, Secret

@action
def process_document(document_url: str, credentials: Secret) -> str:
    """Process a document using secure credentials."""
    api_key = credentials.value
    ...

For more details on secrets, including tagged secrets with SecretSpec, OAuth2 secrets, and passing secrets in development and production modes, see the Secrets Guide.

Execution

To get the full benefits of your actions, the suggested way to run them is using Action Server. But it's also possible to do that directly in command line by passing the named arguments:

actions run -- --city=Helsinki --days=3

Guides

API Reference

Explore our API for extensive documentation.

Changelog

A list of releases and corresponding changes can be found in the changelog.

Maintainer and attribution

Maintained by Joshua Yorko. Upstream copyright and license attribution is preserved in NOTICE.md and LICENSE.

Metadata

Release files for actions-core 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for actions-core 1.0.3
File Size Uploaded
actions_core-1.0.3.tar.gz 84.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for actions-core 1.0.3
File Interpreter ABI Platform
actions_core-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 188.4 kB

Release files / actions_core-1.0.3.tar.gz

Download URL actions_core-1.0.3.tar.gz
Size 84.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1df0ac65bf75103da654d7b3abe0c66da590af07bb24399613f83f20a24f0691
BLAKE2b-256 checksum
How to use checksums
37dcddb21765ddc7c471144e1ef247f1573cf1d438c0bbbe56e396120ea851a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.12.3 Linux/6.17.0-1022-azure

Release files / actions_core-1.0.3-py3-none-any.whl

Download URL actions_core-1.0.3-py3-none-any.whl
Size 103.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8e088b40c39fa3badf581e584e466d0aef3371aed220f6dc7dce130fd11c1265
BLAKE2b-256 checksum
How to use checksums
25b986adaaf08f60deb47c749f8dc2b59a0c672b9278daf917304bffd613ba90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.12.3 Linux/6.17.0-1022-azure

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page