Commit Graph
4 Commits
Author SHA1 Message Date
jpmschweitzerandClaude Opus 4.6 f49c5ac02c fix: use exclude_unset for SSE streaming chunk serialization
Build and Push / test (push) Failing after 1m46s
Build and Push / build (push) Has been skipped
Build and Push / release (push) Has been skipped
exclude_none was too aggressive — it stripped finish_reason: null from
intermediate chunks (which OpenAI includes). exclude_unset correctly
omits only fields never passed to the constructor (like reasoning_content
on content-only chunks) while preserving explicitly-set finish_reason: null.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 21:18:20 +01:00
jpmschweitzerandClaude Opus 4.5 8092740fa4 fix: exclude null fields from streaming chunks for Open WebUI compatibility
Build and Push / release (push) Successful in 3s
Build and Push / build (push) Successful in 1m24s
OpenAI's API omits null fields in streaming chunks, but Tatlock was
including them (content: null, reasoning_content: null). This caused
parsing issues in Open WebUI's streaming handler.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 15:36:37 +01:00
jpmschweitzerandClaude Opus 4.5 e469746f75 fix: use StreamingResponse for chat completions SSE
Build and Push / release (push) Successful in 2s
Build and Push / build (push) Successful in 1m22s
sse_starlette's EventSourceResponse added \r\n line endings that
Open WebUI couldn't parse. Switched to plain StreamingResponse with
manual SSE formatting matching OpenAI's exact format.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:29:08 +01:00
jpmschweitzerandClaude cf6aa9a5e7 Implement chat completions domain with mock responses
Add OpenAI-compatible chat completions endpoint with streaming support.
Currently returns mock lorem ipsum responses (Ollama integration pending).

Chat Router (src/chat/router.py):
- POST /v1/chat/completions endpoint
- Streaming and non-streaming support
- SSE format with EventSourceResponse
- 20-second timeout protection
- OpenAI-compatible response format

Chat Schemas (src/chat/schemas.py):
- ChatMessage, ChatCompletionRequest
- ChatCompletionResponse, ChatCompletionChoice
- ChatCompletionChunk for streaming
- Full OpenAI API compatibility

Chat Service (src/chat/service.py):
- create_chat_completion() - non-streaming
- create_chat_completion_stream() - streaming word-by-word
- Mock lorem ipsum responses
- Token usage calculation

Chat Constants (src/chat/constants.py):
- OpenAI API constants for consistency
- Object types, roles, finish reasons

Following Best Practices:
- Business logic in service layer
- Router only handles HTTP concerns
- Async generators for streaming
- Type hints throughout

Model: mistral-nemo:latest
Status: Mock implementation (ready for Ollama integration)

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

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