What are the best practices for creating an agent in a FastAPI project? #6041
Unanswered
telecomshy
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
According to the official documentation, the way to create and use a PostgresSaver and an Agent is as follows:
However, I cannot do this within a route function because creating a new checkpointer instance on every request prevents retrieving the stored conversation history via the config.
My question is: Can I create the checkpointer within a lifespan function instead? For example:
In this case, would the entire FastAPI app use only a single connection, and would this connection remain unreleased until the app shuts down?
Based on this article: #1357, I think that using a connection pool is a good approach, but besides that, are there any other alternatives? What are the best practices for creating an agent in a FastAPI project?
Beta Was this translation helpful? Give feedback.
All reactions