docs(04-01): complete AI client abstraction plan
- Add 04-01-SUMMARY.md with plan completion details - Update STATE.md with Phase 4 progress and decisions - Update ROADMAP.md with plan count and status Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
e04ce4eeeb
commit
f1a001f923
3 changed files with 111 additions and 13 deletions
|
|
@ -50,7 +50,7 @@ None
|
||||||
**Depends on**: Phase 3
|
**Depends on**: Phase 3
|
||||||
**Research**: Likely (external AI API integration)
|
**Research**: Likely (external AI API integration)
|
||||||
**Research topics**: Requesty API documentation, OpenRouter API, async HTTP patterns with httpx/aiohttp
|
**Research topics**: Requesty API documentation, OpenRouter API, async HTTP patterns with httpx/aiohttp
|
||||||
**Plans**: TBD
|
**Plans**: 3 (04-01 AI client, 04-02 /ask command, 04-03 error handling)
|
||||||
|
|
||||||
### Phase 5: Multi-Model Discussions
|
### Phase 5: Multi-Model Discussions
|
||||||
**Goal**: Open mode (parallel), discuss mode (sequential rounds), and @mention direct messages
|
**Goal**: Open mode (parallel), discuss mode (sequential rounds), and @mention direct messages
|
||||||
|
|
@ -74,6 +74,6 @@ Phases execute in numeric order: 1 → 2 → 3 → 4 → 5 → 6
|
||||||
| 1. Foundation | 3/3 | Complete | 2026-01-16 |
|
| 1. Foundation | 3/3 | Complete | 2026-01-16 |
|
||||||
| 2. Bot Core | 2/2 | Complete | 2026-01-16 |
|
| 2. Bot Core | 2/2 | Complete | 2026-01-16 |
|
||||||
| 3. Project CRUD | 3/3 | Complete | 2026-01-16 |
|
| 3. Project CRUD | 3/3 | Complete | 2026-01-16 |
|
||||||
| 4. Single Model Q&A | 0/TBD | Not started | - |
|
| 4. Single Model Q&A | 1/3 | In progress | - |
|
||||||
| 5. Multi-Model Discussions | 0/TBD | Not started | - |
|
| 5. Multi-Model Discussions | 0/TBD | Not started | - |
|
||||||
| 6. Consensus & Export | 0/TBD | Not started | - |
|
| 6. Consensus & Export | 0/TBD | Not started | - |
|
||||||
|
|
|
||||||
|
|
@ -5,23 +5,23 @@
|
||||||
See: .planning/PROJECT.md (updated 2026-01-16)
|
See: .planning/PROJECT.md (updated 2026-01-16)
|
||||||
|
|
||||||
**Core value:** Get richer, more diverse AI insights through structured multi-model discussions—ask a team of AIs instead of just one.
|
**Core value:** Get richer, more diverse AI insights through structured multi-model discussions—ask a team of AIs instead of just one.
|
||||||
**Current focus:** Phase 3 — Project CRUD (complete)
|
**Current focus:** Phase 4 — Single Model Q&A (in progress)
|
||||||
|
|
||||||
## Current Position
|
## Current Position
|
||||||
|
|
||||||
Phase: 3 of 6 (Project CRUD)
|
Phase: 4 of 6 (Single Model Q&A)
|
||||||
Plan: 3 of 3 in current phase
|
Plan: 1 of 3 in current phase
|
||||||
Status: Phase complete
|
Status: In progress
|
||||||
Last activity: 2026-01-16 — Completed 03-03-PLAN.md (project models/delete)
|
Last activity: 2026-01-16 — Completed 04-01-PLAN.md (AI client abstraction)
|
||||||
|
|
||||||
Progress: █████░░░░░ ~50%
|
Progress: █████▓░░░░ ~55%
|
||||||
|
|
||||||
## Performance Metrics
|
## Performance Metrics
|
||||||
|
|
||||||
**Velocity:**
|
**Velocity:**
|
||||||
- Total plans completed: 8
|
- Total plans completed: 9
|
||||||
- Average duration: 4 min
|
- Average duration: 4 min
|
||||||
- Total execution time: 0.5 hours
|
- Total execution time: 0.6 hours
|
||||||
|
|
||||||
**By Phase:**
|
**By Phase:**
|
||||||
|
|
||||||
|
|
@ -30,9 +30,10 @@ Progress: █████░░░░░ ~50%
|
||||||
| 01-foundation | 3 | 15 min | 5 min |
|
| 01-foundation | 3 | 15 min | 5 min |
|
||||||
| 02-bot-core | 2 | 4 min | 2 min |
|
| 02-bot-core | 2 | 4 min | 2 min |
|
||||||
| 03-project-crud | 3 | 11 min | 4 min |
|
| 03-project-crud | 3 | 11 min | 4 min |
|
||||||
|
| 04-single-model-qa | 1 | 5 min | 5 min |
|
||||||
|
|
||||||
**Recent Trend:**
|
**Recent Trend:**
|
||||||
- Last 5 plans: 02-02 (2 min), 03-01 (3 min), 03-02 (3 min), 03-03 (5 min)
|
- Last 5 plans: 03-01 (3 min), 03-02 (3 min), 03-03 (5 min), 04-01 (5 min)
|
||||||
- Trend: Fast
|
- Trend: Fast
|
||||||
|
|
||||||
## Accumulated Context
|
## Accumulated Context
|
||||||
|
|
@ -58,6 +59,8 @@ Recent decisions affecting current work:
|
||||||
- **03-02:** user_data dict for storing selected_project_id
|
- **03-02:** user_data dict for storing selected_project_id
|
||||||
- **03-03:** Explicit project ID required for delete (safety)
|
- **03-03:** Explicit project ID required for delete (safety)
|
||||||
- **03-03:** Comma-separated model list parsing
|
- **03-03:** Comma-separated model list parsing
|
||||||
|
- **04-01:** OpenAI SDK for router abstraction (Requesty/OpenRouter compatible)
|
||||||
|
- **04-01:** Module-level singleton for AI client (matches database pattern)
|
||||||
|
|
||||||
### Deferred Issues
|
### Deferred Issues
|
||||||
|
|
||||||
|
|
@ -69,6 +72,6 @@ None yet.
|
||||||
|
|
||||||
## Session Continuity
|
## Session Continuity
|
||||||
|
|
||||||
Last session: 2026-01-16T18:55:00Z
|
Last session: 2026-01-16T19:05:00Z
|
||||||
Stopped at: Completed 03-03-PLAN.md (project models/delete) - Phase 3 complete
|
Stopped at: Completed 04-01-PLAN.md (AI client abstraction)
|
||||||
Resume file: None
|
Resume file: None
|
||||||
|
|
|
||||||
95
.planning/phases/04-single-model-qa/04-01-SUMMARY.md
Normal file
95
.planning/phases/04-single-model-qa/04-01-SUMMARY.md
Normal file
|
|
@ -0,0 +1,95 @@
|
||||||
|
---
|
||||||
|
phase: 04-single-model-qa
|
||||||
|
plan: 01
|
||||||
|
subsystem: api
|
||||||
|
tags: [openai, ai-client, requesty, openrouter, async]
|
||||||
|
|
||||||
|
# Dependency graph
|
||||||
|
requires:
|
||||||
|
- phase: 03-project-crud
|
||||||
|
provides: BotConfig pattern, project context
|
||||||
|
provides:
|
||||||
|
- AIClient class for AI model interactions
|
||||||
|
- MODEL_MAP with claude/gpt/gemini short names
|
||||||
|
- Module-level init_ai_client/get_ai_client functions
|
||||||
|
- Config extended with AI router settings
|
||||||
|
affects: [04-02, 04-03, 05-multi-model, discussion handlers]
|
||||||
|
|
||||||
|
# Tech tracking
|
||||||
|
tech-stack:
|
||||||
|
added: [openai]
|
||||||
|
patterns: [async-client-singleton, model-routing-abstraction]
|
||||||
|
|
||||||
|
key-files:
|
||||||
|
created: [src/moai/core/ai_client.py]
|
||||||
|
modified: [pyproject.toml, src/moai/bot/config.py]
|
||||||
|
|
||||||
|
key-decisions:
|
||||||
|
- "OpenAI SDK for router abstraction (both Requesty and OpenRouter are OpenAI-compatible)"
|
||||||
|
- "Module-level singleton pattern for AI client (matches database pattern)"
|
||||||
|
- "Short model names (claude/gpt/gemini) mapped to full identifiers"
|
||||||
|
|
||||||
|
patterns-established:
|
||||||
|
- "AI client abstraction: all AI calls go through AIClient.complete()"
|
||||||
|
- "Model name resolution: short names in code, full identifiers to routers"
|
||||||
|
|
||||||
|
issues-created: []
|
||||||
|
|
||||||
|
# Metrics
|
||||||
|
duration: 5min
|
||||||
|
completed: 2026-01-16
|
||||||
|
---
|
||||||
|
|
||||||
|
# Phase 04-01: AI Client Abstraction Summary
|
||||||
|
|
||||||
|
**OpenAI SDK-based AI client with Requesty/OpenRouter routing and claude/gpt/gemini model mappings**
|
||||||
|
|
||||||
|
## Performance
|
||||||
|
|
||||||
|
- **Duration:** 5 min
|
||||||
|
- **Started:** 2026-01-16T19:00:00Z
|
||||||
|
- **Completed:** 2026-01-16T19:05:00Z
|
||||||
|
- **Tasks:** 2
|
||||||
|
- **Files modified:** 3
|
||||||
|
|
||||||
|
## Accomplishments
|
||||||
|
- Created AIClient class wrapping AsyncOpenAI for model routing
|
||||||
|
- Extended BotConfig with ai_router, ai_api_key, ai_referer settings
|
||||||
|
- Added MODEL_MAP with claude, gpt, gemini short name mappings
|
||||||
|
- Implemented module-level singleton pattern with init_ai_client/get_ai_client
|
||||||
|
|
||||||
|
## Task Commits
|
||||||
|
|
||||||
|
Each task was committed atomically:
|
||||||
|
|
||||||
|
1. **Task 1: Add openai dependency and extend config** - `3740691` (feat)
|
||||||
|
2. **Task 2: Create AI client abstraction** - `e04ce4e` (feat)
|
||||||
|
|
||||||
|
**Plan metadata:** `f8fa4e7` (docs)
|
||||||
|
|
||||||
|
## Files Created/Modified
|
||||||
|
- `src/moai/core/ai_client.py` - AIClient class, MODEL_MAP, init/get functions
|
||||||
|
- `pyproject.toml` - Added openai dependency
|
||||||
|
- `src/moai/bot/config.py` - Extended BotConfig with AI settings
|
||||||
|
|
||||||
|
## Decisions Made
|
||||||
|
- Used OpenAI SDK instead of raw httpx - both Requesty and OpenRouter are OpenAI-compatible
|
||||||
|
- Default router is "requesty" (can be changed via AI_ROUTER env var)
|
||||||
|
- Model short names (claude/gpt/gemini) resolve to specific model versions
|
||||||
|
|
||||||
|
## Deviations from Plan
|
||||||
|
|
||||||
|
None - plan executed exactly as written.
|
||||||
|
|
||||||
|
## Issues Encountered
|
||||||
|
|
||||||
|
None.
|
||||||
|
|
||||||
|
## Next Phase Readiness
|
||||||
|
- AI client foundation ready for /ask command implementation in 04-02
|
||||||
|
- Model routing abstraction enables easy addition of new models
|
||||||
|
- Singleton pattern allows handlers to access client via get_ai_client()
|
||||||
|
|
||||||
|
---
|
||||||
|
*Phase: 04-single-model-qa*
|
||||||
|
*Completed: 2026-01-16*
|
||||||
Loading…
Add table
Reference in a new issue