Prefer video tutorial? Watch our 4-minute video here.
This guide outlines building a basic LLM app with langchain and agenta. By the end, you’ll have a functional LLM app and knowledge of how to use the agenta CLI.
To learn more about creating an LLM app from scratch, please visit our advanced tutorial.
Step 0: Installation
Before beginning, you need to install (or update) the agenta CLI.
pip install -U agenta
Step 1: Initialize a New Project
Create a new folder and initialize it with the following commands:
mkdir example_app; cd example_app agenta init
Start a new project using the simple_prompt template:
? Please enter the app name company_name_generator ? Are you running agenta locally? Yes ? How do you want to initialize your app? Start from template ? Which template do you want to use? simple_prompt - Simple app that uses one prompt using langchain App initialized successfully Please check the README.md for further instructions to setup the template.
The initialization creates several files, including app.py. For a detailed explanation, proceed to the next step or continue with the tutorial.
Step 2: Set up the OpenAI API Key
You’ll need to configure the OpenAI API key. Here’s how:
Visit the OpenAI API keys page, and create a new key.
Create a file
.envin your project folder and add the line:
Step 3: Run the Application in the Playground
To run your app in the playground, serve it locally using
agenta variant serve. This command:
- Creates a Docker image and starts a container.
- Starts a server exposing the endpoint /generate at
- Adds the application to the Agenta’s web UI.
agenta variant serve app.py
This will do two things:
- It will create a docker image of the application, and start a container based on this image.
- The container will start a server exposing an endpoint /generate with the same parameters we specified in the application at
- It will add the application to the web ui Agenta
Step 4: Start Experimenting
Visit http://localhost, select your app, and experiment with different parameters in the playground.
The playground lets you create new app variants and tweak application parameters.
We hope you find this guide helpful. Happy coding!