generated from coulomb/repo-seed
feat: WP-0001 foundation + WP-0002 core extensions
WP-0001 — Foundation & GAAF Baseline - SCOPE.md, ARCHITECTURE-LAYERS.md, contracts/ tree - .claude/rules/ stubs filled (architecture, stack, boundary) - 57 tests (pytest), pyproject.toml with ruff+mypy, CI workflow WP-0002 — Core Extensions (FR-4 + FR-3) - FR-4: BudgetTracker (thread-safe) + LLMBudgetExceededError + optional RunConfig.budget_tracker + enforcement in all adapters - FR-3: async_execute_prompt on LLMAdapter ABC (asyncio.to_thread fallback) + native asyncio.create_subprocess_exec in ClaudeCodeAdapter 81 tests passing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
Google Gemini adapter — calls the Generative Language REST API directly.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import time
|
||||
from typing import Optional, Dict, Any
|
||||
|
||||
@@ -48,6 +49,7 @@ class GeminiAdapter(LLMAdapter):
|
||||
# ── LLMAdapter interface ────────────────────────────────────────
|
||||
|
||||
def execute_prompt(self, prompt: str, config: RunConfig) -> LLMResponse:
|
||||
self._preflight_budget(config)
|
||||
model = self._model
|
||||
|
||||
# Build Gemini request
|
||||
@@ -92,7 +94,7 @@ class GeminiAdapter(LLMAdapter):
|
||||
|
||||
usage_meta = data.get("usageMetadata", {})
|
||||
|
||||
return LLMResponse(
|
||||
response = LLMResponse(
|
||||
content=content,
|
||||
model=model,
|
||||
usage={
|
||||
@@ -106,6 +108,12 @@ class GeminiAdapter(LLMAdapter):
|
||||
"latency_seconds": round(latency, 3),
|
||||
},
|
||||
)
|
||||
self._consume_budget(config, response)
|
||||
return response
|
||||
|
||||
async def async_execute_prompt(self, prompt: str, config: RunConfig) -> LLMResponse:
|
||||
"""Async wrapper — runs execute_prompt in a thread executor."""
|
||||
return await asyncio.to_thread(self.execute_prompt, prompt, config)
|
||||
|
||||
def validate_config(self, config: RunConfig) -> bool:
|
||||
if not self._api_key:
|
||||
|
||||
Reference in New Issue
Block a user