Skip to main content

Description

agenta variant serve app_name.py

The serve command deploys the code of an app to the agenta platform. The command packages the code in the .py file along with any additional files in the same directory and deploy them on the agenta platform. Once deployed, the variant becomes accessible the web UI. It can ehtn be further deployed to a staging or production environment as an API endpoint.

In the agenta UI, the deployed variant is initially named app_name.default where app_name is the name of the python file deployed and default the default configuration. Creating a new configuration someconfig (either from the UI or from CLI), will result in the creation of corresponding new variant, named app_name.someconfig.

caution

The code in app_name.py needs to include an entrypoint function. This function should be marked with the @agenta.entrypoint decorator.

Below is a brief example of a valid app_name.py file:


import agenta as ag

ag.config.register_default(prompt="Translate {sentence} to {language})

@ag.entrypoint
def translate(sentence:str, language:str):
### add here openai call logic
caution

The variant serve command can only be run in a directory where the config.toml generated by agenta init is present.