Quickstart

This page shows a simple quick start guide on how to use Fastagent with your current project.

Installation

The first step is to install the FastAgent dependency. To install the project, use pip.

pip install git+https://github.com/bastienpo/fastagent.git

Currently the project is available only on github and will soon be available on pypi.

Create a simple LangChain application

Let's create an app.py file with the simplest langchain runnable you can make, consisting of just a large language model.

myapplication/app.py
# pip install -qU langchain-mistralai and requires MISTRAL_API_KEY in to be set
from langchain_mistralai import ChatMistralAI

chain = ChatMistralAI(model="ministral-3b-latest")

Create a fastagent configuration

The first step is to create and initialize a fastagent using the cli tool or by hand. (You can also choose not to pass the argument, and you will be prompted instead.)

fastagent init --name my-first-application --template langchain

Currently only langchain is supported, but on the roadmap is support for langgraph (currently experimental) and dspy.

You will need to update the app field in the project section to match the path of your application in the form:

<module_path>:<module_attribute> in you case it would be myapplication.app:chain

Launching you server in development mode

Now that everything is set up, you can simply start the server using

fastagent dev

The development server is reloaded every time the code changes and provides some advanced logging. You should see:

╭───────────────────────────────────────────────────────╮
 Running fastagent server in development mode 🚀       
                                                       
 The application is available at http://127.0.0.1:8000 
╰───────────────────────────────────────────────────────╯
time=2024-11-17T09:51:29.401350-08:00 level=INFO msg='Starting application'

To see the available endpoint, go to http://127.0.0.1:8000/docs and you should see the documentation.

Launching you server in production mode

When you decide to move your project into production, it can be nice to disable some features, such as reloading the server. You can simply use the

fastagent run

This command is very similar to the development command under the hood, it uses exactly the same interface but disables some features of development mode.

Last updated