Agenta is an assembly of four integral components:
- Python SDK: This is a library necessary for implementing Agenta in your Python apps. The code for the sdk is under
- Command Line Interface: A tool for serving and deploying your apps with Agenta. The code for the cli is under
- Backend: Handles tasks like deployment, app management, and data management. The code for the backend is under
agenta-backend. We use FastAPI for the backend.
- Frontend: The code for the frontend is under
agenta-web. We use React and nextjs for the frontend.
In addition, we use
mongodb for our database.
Before we delve into how these Agenta components interact, let’s understand the user’s perspective of creating and deploying a app.
Apps, are Large Language Model (llm)-powered applications that can be deployed through Agenta. Each app can encompass multiple variants, which are either created by committing new code or by tweaking parameters of an existing variant in the user interface. The key point about the variants within a single app is their consistent inputs and outputs, albeit with potential variation in parameters.
For example, if we’re creating an llm-app to summarize YouTube videos, we could generate two variants for this app, each employing a unique summarization pipeline. Each variant might have different parameters; variant A could have four prompt templates, while variant B uses only two. However, Agenta’s only requirement is that both variants should have the same input (a YouTube video URL) and output (a video summary).
In addition to these code-created variants, users can generate new variants by forking an existing one and altering its parameters, leading to the creation of sub-variants for the app.
Agenta provides two paths to app creation: initiating with code or utilizing a pre-defined template. Let’s explore both methods.
Initiating with Code
The user first sets up a new app using the agenta init command in the CLI. This action generates a config.toml file storing essential app information, such as the app name and existing variants.
The agenta init command offers the user an option to start with a blank app or use a template code. If the latter is chosen, the CLI will replicate the code from the
template/ directory to the user’s working directory.
To incorporate their code into Agenta, users need to import the Agenta SDK and append the @post decorator to a function named generate in their code. This function, acting as the entry point, accepts the app’s inputs and optional parameters and returns the application’s output.
Applying the @post decorator automatically makes the function’s inputs, outputs, and parameters accessible to the command line. Users can locally test their code using python script.py.
To serve the code locally as an API, users can execute the
agenta variant serve command in the CLI. Upon successful serving, the user receives the URL of their API. The API, created automatically, includes a single endpoint
/generate with the same inputs, outputs, and parameters as the
generate function in the code.