feat(chat): add multi-provider chat/LLM abstraction (#285) - #317
codeforstartups merged 3 commits into
Conversation
|
Ready for review! |
|
Reviewed in depth — this is a strong foundation for the dynaflow model layer (closes #285). 🎯 Design — the Optional deps done right — provider SDKs ( Tests — 6 genuine offline tests with per-provider fakes, async delegation, exports, and missing-dependency guards. Verified locally (6 passed) and all 4 CI checks pass incl. strict mypy on 3.9/3.11/3.12. Two non-blocking follow-ups for later (not needed to merge):
Merging — excellent work @Kaap10! |
Description
Implements a unified multi-provider chat/LLM abstraction layer mirroring Dynavec's embedder architecture. This provides a single consistent interface to interact with multiple LLM backends (OpenAI, Anthropic, and AWS Bedrock) with full support for message formatting, function/tool calling, structured output schemas, and token streaming.
Related issue
Fixes #285
Changes
src/dynavec/chat/base.py):Message,Role,Tool,ToolCall,ChatResult, andChatChunk.ChatModelproviding sync (invoke,stream) and async (ainvoke,astream) execution interfaces.src/dynavec/chat/openai.py: AddedOpenAIChatModelwith OpenAI function/tool calling and streaming delta support.src/dynavec/chat/anthropic.py: AddedAnthropicChatModelmapping conversation roles to Anthropic content blocks, handling system prompts, tool uses, and event streaming.src/dynavec/chat/bedrock.py: AddedBedrockChatModelpowered by the unified AWS Bedrock Converse and ConverseStream APIs.src/dynavec/chat/__init__.py):openai,anthropic,boto3) optional.tests/test_chat_models.py):Testing
Checklist