Multi Agent workflow with Fastapi #1241
Replies: 2 comments 2 replies
-
We are doing similar stuff, right now we have gotten quite far by just using the endpoints you get from wrapping your application in the |
Beta Was this translation helpful? Give feedback.
-
That part has been resolved for now, but I'm currently facing a tricky issue with a database connection error. I've managed to work through several other problems, but I'm stuck on this one and could use some help. The Problem:
My Setup: DB_URL = "postgres+asyncpg://user:password@your-neon-hostname.neon.tech/neondb"
# Create a lifespan event to initialize and clean up the session service
@asynccontextmanager
async def lifespan(app: FastAPI):
# Startup code
print("Application starting up...")
# Initialize the DatabaseSessionService instance and store it in app.state
try:
app.state.session_service = DatabaseSessionService(
db_url=DB_URL,
connect_args={"ssl": "require"}
)
print("Database session service initialized successfully.")
except Exception as e:
print("Database session service initialization failed.")
print(e)
yield
# Shutdown code
print("Application shutting down...")
app = FastAPI(title="ADK Multi-Agent FastAPI Demo", lifespan=lifespan) What I've Tried: Has anyone encountered this before? It seems like there's something wrong with how I'm handling the async database initialization, but I'm not sure what the best approach is. Any suggestions or guidance would be really appreciated! Thanks in advance for any help! 🙏 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I'm currently exploring Google's Agent Developer Kit (ADK) and trying to integrate it with FastAPI to build a modular agentic system. While the Google ADK Web UI works fine for me, I get stuck every time I try to bring it into a FastAPI backend.
As a beginner in AI agents and multi-agent systems, I often find myself confused—especially about how to structure my code and manage agent lifecycles inside FastAPI routes. I’ve searched around, but haven’t found solid beginner-level resources or working examples that use FastAPI with Google ADK.
Here's my current folder structure for reference:
What I Need Help With:
If anyone here has experience with this or can help me lay the foundation for integrating FastAPI and ADK, I’d really appreciate your guidance 🙏. Even basic tips or example repo links would be super helpful.
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions