Template project for building new assistants on top of assistant_core.
- A
SingleAgentgraph built withBuilderContext.create(...). - A basic
AgentNodewith a simple system prompt. DateTimeBuilderwiring so each run has current date/time context.- A runnable CLI entrypoint with an auto-generated
thread_idper execution. - A project architecture reference in
ARCHITECTURE.md.
assistant-template/
assistant_template/
__init__.py
agent.py
main.py
.env.example
ARCHITECTURE.md
pyproject.toml
README.md
- Install dependencies:
poetry install- Configure environment:
cp .env.example .env
# edit .env and set OPENAI_API_KEY- Run the template assistant in interactive mode:
poetry run assistant-templateYou can now chat with the assistant directly from the CLI. Use /exit or /quit to end the session.
- Optional one-shot usage:
poetry run assistant-template --message "What time is it now?"The CLI generates a random thread_id automatically for each execution and reuses it for that run.
You can consume this template, or a project derived from it, directly from GitHub without publishing to PyPI.
[tool.poetry.dependencies]
my-assistant = { git = "https://github.com/your-org/your-repo.git", tag = "v0.1.0" }pip install "git+https://github.com/your-org/your-repo.git@v0.1.0"The packaged distribution includes only the runtime package under assistant_template/ plus standard package metadata.
Use Makefile commands similar to assistant and assistant_core:
make format
make lintThese run black, isort, and flake8 with project settings.
To enable observability and debugging with LangSmith, update your .env file:
LANGSMITH_TRACING=true
LANGSMITH_ENDPOINT="https://api.smith.langchain.com"
LANGSMITH_API_KEY=your_actual_api_key_here
LANGSMITH_PROJECT=your_project_name_hereLangSmith tracing is disabled by default. Set LANGSMITH_TRACING=true only if you have a LangSmith account and want to see traces in your dashboard.
This template commits poetry.lock.
- Why: reproducible installs, stable CI, and a consistent starting point for new projects.
- When to update: only when intentionally changing dependencies (for example, bumping
assistant_coretag or adding/removing packages). - For derived projects: keep the lock file for reproducibility, or regenerate it intentionally if your project needs a different dependency baseline.
Use build_assistant_graph(openai_api_key, checkpointer=None, store=None, agent_factory=None) from assistant_template.agent to obtain a compiled LangGraph app:
from assistant_template.agent import build_assistant_graph
# Use defaults (MemorySaver and InMemoryStore)
graph = build_assistant_graph("your-openai-api-key")Provide custom implementations for persistent storage:
from langgraph.checkpoint.postgres import PostgresCheckpointer
from langgraph.store.postgres import PostgresStore
checkpointer = PostgresCheckpointer(conn_string="...")
store = PostgresStore(conn_string="...")
graph = build_assistant_graph(
"your-openai-api-key",
checkpointer=checkpointer,
store=store,
)Parameters:
openai_api_key(str): Required. OpenAI API key for the model.checkpointer(optional): Custom checkpointer for conversation state persistence. Defaults toMemorySaver(in-memory).store(optional): Custom store for long-term data persistence. Defaults toInMemoryStore(in-memory).agent_factory(optional): Custom agent factory callable used to create theAgentNode. Defaults to the template's internal factory.
- Add custom builders and register them on
SingleAgentinassistant_template/agent.py. - Group related tools in builder classes by domain.
- Keep builder logic in
build(context)and avoid runtime state in builders.