Commit Graph
3 Commits
Author SHA1 Message Date
jpmschweitzer 958363d44e test: update test suite for PydanticAI integration
- Update conftest for lazy agent initialization
- Update chat router tests for Tatlock capabilities
- Update models router tests for tools capability
- Update responses advanced features tests
- Update main app tests
- Total: 131 tests, 81.78% coverage (up from 95 tests, 78.95%)
2025-12-07 00:13:26 +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 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