How kuldeepguptahub/sensei works
Purpose and Entry Points
Sensei is a Python AI learning engine that creates, teaches, assesses, and resumes personalized courses. The main user surfaces are a command-line workflow and a Streamlit dashboard. Package/command startup is rooted in src/sensei/__main__.py, with application orchestration in src/sensei/main.py and CLI commands in src/sensei/cli/app.py.
Agent Learning Lifecycle
The agent layer implements the adaptive course loop: gather learner/course context, conduct the interview and teaching conversation, evaluate performance, and advance progress. src/sensei/agent/runner.py is the likely session orchestrator; src/sensei/agent/context.py, src/sensei/agent/evaluation.py, and src/sensei/agent/progression.py define the major contextual, assessment, and advancement stages. Prompt-level behavioral rules live in src/sensei/agent/instructions.md.
Sessions, Tools, and Course Domain
Agent conversations are modeled as resumable sessions and use registered capabilities rather than directly coupling all behavior to storage or files. Key boundaries are src/sensei/agent/session.py, src/sensei/agent/registry.py, and src/sensei/agent/tools.py. Course management is split between domain-facing operations in src/sensei/courses.py and agent-accessible course skills in src/sensei/skills/courses.py.
LLM Gateway Boundary
All model-provider integration is isolated behind the gateway, supporting OpenAI-compatible and provider-specific services such as OpenRouter, OpenAI, Anthropic, Google, Ollama, and Hugging Face. src/sensei/gateway/client.py drives requests; src/sensei/gateway/provider.py and src/sensei/gateway/providers.py represent provider/model selection; src/sensei/gateway/config.py persists connection configuration. src/sensei/gateway/retry.py establishes resilience behavior around external API calls.
Persistence and Learning State
Persistent learning data is stored locally through src/sensei/persistence/database.py, with the repository containing a SQLite database artifact at sensei.db. src/sensei/state/manager.py provides the higher-level state boundary used to restore course/session progress. This supports the core resume flow independently of transient LLM conversation context.
Workspace and Artifact Capabilities
Course work is backed by filesystem-oriented skills for learner uploads, generated artifacts, and per-course workspaces. src/sensei/skills/workspace.py, src/sensei/skills/artifacts.py, and src/sensei/skills/uploads.py form the material-project boundary: the agent can guide implementation and inspect or manage learning outputs without embedding that logic in the LLM gateway.
UI and Control Flow
The CLI initiates provider setup, course lifecycle actions, and UI launch through src/sensei/cli/app.py. The Streamlit runtime is launched from src/sensei/ui/app.py; it separates course browsing/creation from interactive learning views in src/sensei/ui/views/home.py and src/sensei/ui/views/chat.py. Both interfaces should converge on shared agent, course, state, and gateway layers rather than maintaining independent learning logic.
Main entry points: runner.py Learning session runner · courses.py Course operations · app.py CLI commands · registry.py Tool registry
Components 20
Entry points
- Package startup
src/sensei/__main__.py - Application orchestration
src/sensei/main.py - CLI commands · Starts setup, course actions, and the dashboard.
src/sensei/cli/app.py
Adaptive learning
- Learning session runner · Runs the interview, teaching, assessment, and resume loop.
src/sensei/agent/runner.py - Learner context
src/sensei/agent/context.py - Assessment
src/sensei/agent/evaluation.py - Progress advancement
src/sensei/agent/progression.py - Resumable sessions
src/sensei/agent/session.py - Tool registry
src/sensei/agent/registry.py - Agent instructions
src/sensei/agent/instructions.md
Course and state
- Course operations
src/sensei/courses.py - Learning state manager · Restores persisted course and session progress.
src/sensei/state/manager.py - Local learning database
src/sensei/persistence/database.py
LLM gateway
- Model client · Executes model requests behind provider selection and retries.
src/sensei/gateway/client.py - Provider selection · Selects OpenAI-compatible and provider-specific model services.
src/sensei/gateway/providers.py
Learning workspace
- Course skills
src/sensei/skills/courses.py - Workspace and artifacts · Manages course workspaces, uploads, and generated outputs.
src/sensei/skills/workspace.py
Dashboard
- Streamlit runtime
src/sensei/ui/app.py - Course browser
src/sensei/ui/views/home.py - Learning chat
src/sensei/ui/views/chat.py
Connections 23
- Package startup → Application orchestration: boots
- Application orchestration → CLI commands: runs
- CLI commands → Streamlit runtime: launches
- Streamlit runtime → Course browser: renders
- Streamlit runtime → Learning chat: renders
- Learning chat → Learning session runner: conducts learning
- Course browser → Course operations: browses and creates
- CLI commands → Course operations: manages
- Learning session runner → Learner context: gathers
- Learning session runner → Resumable sessions: maintains
- Learning session runner → Assessment: assesses
- Assessment → Progress advancement: informs
- Learning session runner → Tool registry: uses capabilities
- Learning session runner → Agent instructions: follows
- Learning session runner → Model client: requests responses
- Model client → Provider selection: selects provider
- Tool registry → Course skills: registers
- Tool registry → Workspace and artifacts: registers
- Course skills → Course operations: accesses
- Workspace and artifacts → Local learning database: records outputs
- Learning session runner → Learning state manager: restores and saves
- Learning state manager → Local learning database: persists
- Course operations → Local learning database: stores courses