Skip to main content

Sema4AI Actions

Project description

⚡️ sema4ai-actions

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 sema4ai.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:

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:

python -m sema4ai.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.

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

sema4ai_actions-1.3.13.tar.gz (62.0 kB view details)

Uploaded Source

Built Distribution

sema4ai_actions-1.3.13-py3-none-any.whl (77.1 kB view details)

Uploaded Python 3

File details

Details for the file sema4ai_actions-1.3.13.tar.gz.

File metadata

  • Download URL: sema4ai_actions-1.3.13.tar.gz
  • Upload date:
  • Size: 62.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-1015-azure

File hashes

Hashes for sema4ai_actions-1.3.13.tar.gz
Algorithm Hash digest
SHA256 be0e7e15872226bffa8537d19b7a39a1738ca16d640e5578bac568d36e3e7adf
MD5 5feead823ea729d0ce0823cda962f7c5
BLAKE2b-256 d8bd028d6739efa6390107f1b486bc9b6bc7dee639d760f5a5841e3f0ba5cd6c

See more details on using hashes here.

File details

Details for the file sema4ai_actions-1.3.13-py3-none-any.whl.

File metadata

  • Download URL: sema4ai_actions-1.3.13-py3-none-any.whl
  • Upload date:
  • Size: 77.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-1015-azure

File hashes

Hashes for sema4ai_actions-1.3.13-py3-none-any.whl
Algorithm Hash digest
SHA256 697775efe2efcd84bdddd877c845f2c84051a8a729ee1766a2a16ce4478a0ff7
MD5 04e422ca9ff4db294e25a1cb4ef53ab5
BLAKE2b-256 207f8ddcda82d6153f5afcefd7498e37f0c6c954e9f5624e78681ad8f765dae8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page