Commit Graph
5 Commits
Author SHA1 Message Date
jpmschweitzerandClaude 8b6cff2920 Add application setup and test infrastructure
Application Configuration:
- FastAPI application factory pattern
- CORS middleware for cross-origin support
- Global exception handlers for consistent error responses
  - AppException handler for custom errors
  - RequestValidationError handler for Pydantic validation
  - General exception handler for unexpected errors
- Lifespan management for startup/shutdown events
- Router registration for all API endpoints
- OpenAPI schema with interactive documentation

Models Service:
- Integration with ModelRegistry
- List available models endpoint
- Model capability discovery

Test Infrastructure:
- Pytest configuration with async support
- Test client fixtures for sync and async testing
- Comprehensive main application tests (14 tests):
  - App creation and metadata
  - Router registration verification
  - CORS middleware and functionality
  - Exception handler registration and behavior
  - Lifespan event handling
  - OpenAPI schema generation
  - Documentation accessibility
  - Validation error handling
- Models API tests (2 tests)
- Total: 95 tests, 78.95% coverage

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 19:39:02 +01:00
jpmschweitzerandClaude 5e40704d91 Add Chat Completions wrapper with reasoning conversion
Implements Phase 5: OpenAI Chat Completions compatibility layer

Features:
- Wraps Responses API for single source of truth
- Automatically enables reasoning generation
- Converts reasoning items to <think> tags for Open WebUI
- Maintains OpenAI-compatible chat completion format
- Supports both streaming and non-streaming modes
- Pipeline prefix preservation for model names
- System message handling

Architecture:
- Service layer calls Responses API internally
- Streams word-by-word for smooth UX
- Reasoning displayed in thought bubbles (Open WebUI)
- Main response shown separately from thinking

Error Handling:
- Enhanced exception types (RateLimitError, ContextLengthError)
- OpenAI-compatible error format
- Graceful error propagation from Responses API

Testing:
- 6 unit tests for chat router functionality
- 6 unit tests for streaming wrapper behavior
- Total: 12 tests with comprehensive coverage

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 19:38:35 +01:00
jpmschweitzerandClaude ff6c3cf1b5 Add Responses API with streaming, history, and advanced features
Implements Phases 2, 3, and 6: Complete Responses API implementation

Core API (Phase 2):
- OpenAI Responses API format with structured output items
- Streaming and non-streaming support via SSE-Starlette
- Reasoning items (thinking summaries)
- Function call items (tool execution)
- Message items (assistant responses)
- Router, schemas, service, and streaming coordinator

Conversation History (Phase 3):
- Hybrid client/server approach
- Auto-generated deterministic conversation IDs
- Configurable max turns with automatic trimming
- Context window management with token counting
- Token usage statistics
- Placeholder for future vector memory integration

Advanced Features (Phase 6):
- Parameter validation with Pydantic field validators:
  - Temperature: 0.0-2.0 range enforcement
  - Reasoning effort: 6 levels (none to xhigh)
  - Max output tokens: positive integer enforcement
  - Stop sequences: up to 4, non-empty strings
- Real-time stop sequence detection during streaming
- Real-time max tokens enforcement with token counting
- Graceful error handling and OpenAI-compatible error format

Testing:
- 9 unit tests for API endpoints and streaming
- 11 unit tests for error handling
- 13 unit tests for conversation history and context
- 12 unit tests for advanced features and validation
- Total: 45 tests with comprehensive coverage

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 19:38:00 +01:00
jpmschweitzerandClaude 4e6ca4466b Add agent interface and model implementations
Implements Phase 1: Agent abstraction layer with multiple model support

Features:
- Abstract AgentInterface base class with standard contract
- LoremTesterAgent: Full-featured mock agent with realistic behavior
  - Configurable reasoning effort levels (none to xhigh)
  - Random tool/function call generation
  - Error triggers for testing (rate_limit, context_overflow)
  - Temperature-based response variation
- TatlockAgent: Placeholder for future PydanticAI integration
- ModelRegistry: Centralized model management and discovery

Testing:
- 9 unit tests for lorem-tester agent behavior
- 9 unit tests for registry operations
- Coverage: Agent abstraction fully tested

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 19:36:53 +01:00
jpmschweitzerandClaude c50f7eefcb Add comprehensive testing infrastructure
Implement test suite with 62% coverage and 12 passing tests.
Async testing support, fixtures, and SSE streaming tests.

Test Configuration (pytest.ini):
- Async mode configured
- Coverage reporting enabled
- Test markers (unit, integration)
- Warning filters
- Async fixtures with session scope

Test Fixtures (tests/conftest.py):
- TestClient for sync requests
- AsyncClient for streaming tests
- Mock request fixtures
- Shared test application instance

Core Tests (tests/core/):
- Health endpoint testing
- Root endpoint testing
- Exception handler testing
- 100% coverage of core routes

Chat Tests (tests/chat/test_router.py):
- Non-streaming completion tests
- Streaming with SSE and 20s timeout
- Temperature validation
- Message role validation
- Invalid request handling
- Comprehensive edge case coverage

Models Tests (tests/models/):
- Model listing endpoint tests
- Response format validation
- OpenAI compatibility verification

Streaming Tests:
- Proper SSE format parsing
- [DONE] marker handling
- Chunk structure verification
- 20-second timeout protection
- asyncio.wait_for() timeout handling

Test Coverage:
- Overall: 62.14%
- src/chat/: High coverage
- src/models/: High coverage
- src/core/: 100% coverage
- 12 tests passing

Following Best Practices:
- Async test support
- Fixture-based setup
- Isolated test cases
- Comprehensive assertions
- Timeout protection

Status: Production-ready test suite

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 10:52:18 +01:00