Spaces:
Paused
Paused
Download app/agent/factory.py from tianyajum/python-agent: direct link, hf CLI and curl.
- Browser
- Download file 575 Bytes
-
https://huggingface.co/spaces/tianyajum/python-agent/resolve/main/app/agent/factory.py
- Command line
-
hf download hf://spaces/tianyajum/python-agent/app/agent/factory.py
-
curl -L -o factory.py https://huggingface.co/spaces/tianyajum/python-agent/resolve/main/app/agent/factory.py
575 Bytes
| from langgraph.checkpoint.postgres.aio import AsyncPostgresSaver | |
| from app.services.chat_graph import workflow | |
| import logging | |
| logger = logging.getLogger(__name__) | |
| async def get_graph_runnable(conn): | |
| """ | |
| 业务逻辑 -> 用 asyncpg (SQLAlchemy) -> 高性能。 | |
| LangGraph -> 用 psycopg (官方 Saver) -> 高可靠、零维护。 | |
| Get the compiled graph runnable with checkpointer. | |
| """ | |
| # Initialize checkpointer with the connection pool | |
| checkpointer = AsyncPostgresSaver(conn) | |
| return workflow.compile(checkpointer=checkpointer) | |