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 Sema4.ai Action Server.

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

actions_core-1.0.0.tar.gz (83.0 kB view details)

Uploaded Source

Built Distribution

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

actions_core-1.0.0-py3-none-any.whl (101.6 kB view details)

Uploaded Python 3

File details

Details for the file actions_core-1.0.0.tar.gz.

File metadata

  • Download URL: actions_core-1.0.0.tar.gz
  • Upload date:
  • Size: 83.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for actions_core-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2fba52fa79b2a74b369c30a1336d686d728ecda0b486c1945e7a5468a0b8626f
MD5 cee75c9519ae7989fd6c34fb39db1f42
BLAKE2b-256 991ef99d1ee3e805e464732fab289bb31f58849d9dd54c76a1022ca406b63d1b

See more details on using hashes here.

File details

Details for the file actions_core-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: actions_core-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 101.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for actions_core-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e413f55b377adaccf9c832841c7bc41e8294eff97247c8d6cc03693144ff11bf
MD5 bb24ce4a0e807ca2a1cdef15e42f563d
BLAKE2b-256 482f2c538c47fbdfb98b4a00dd227fbdeead56aaf27c2e9fd82b77a7f82e442f

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.1

2 files

This release

1.0.0 This release

2 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