Conversation
WalkthroughThis set of changes includes updates across several files. The project version in Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
a08b945 to
6490769
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (5)
pyproject.toml(1 hunks)src/draive/conversation/realtime/default.py(1 hunks)src/draive/conversation/types.py(1 hunks)src/draive/openai/lmm_session.py(12 hunks)src/draive/stages/stage.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py
📄 CodeRabbit Inference Engine (CLAUDE.md)
**/*.py: Use absolute imports fromdraivepackage
Follow Ruff import ordering (standard library, third party, local)
Use Python 3.12+ type features (type unions with|, generic syntax)
Use base and abstract types likeSequenceorIterableinstead of concrete types
Use custom exceptions for specific errors
Use NumPy docstring convention for all functions, classes, and methods
Skip module-level docstrings unless explicitly requested
Include sections: Parameters, Returns, Raises, Notes (if needed) in docstrings
ALWAYS useSequence[T]instead oflist[T],Mapping[K,V]instead ofdict[K,V], andSet[T]instead ofset[T]for collections in State, Config and DataModel classes
Immutable updates to State, Config, and DataModel classes should be performed through the.updated()method
Files:
src/draive/conversation/realtime/default.pysrc/draive/stages/stage.pysrc/draive/conversation/types.pysrc/draive/openai/lmm_session.py
🧠 Learnings (7)
📓 Common learnings
Learnt from: KaQuMiQ
PR: miquido/draive#338
File: src/draive/lmm/__init__.py:1-2
Timestamp: 2025-06-16T10:28:07.434Z
Learning: The draive project requires Python 3.12+ as specified in pyproject.toml with "requires-python = ">=3.12"" and uses Python 3.12+ specific features like PEP 695 type aliases and generic syntax extensively throughout the codebase.
📚 Learning: the draive project requires python 3.12+ as specified in pyproject.toml with "requires-python = ">=3...
Learnt from: KaQuMiQ
PR: miquido/draive#338
File: src/draive/lmm/__init__.py:1-2
Timestamp: 2025-06-16T10:28:07.434Z
Learning: The draive project requires Python 3.12+ as specified in pyproject.toml with "requires-python = ">=3.12"" and uses Python 3.12+ specific features like PEP 695 type aliases and generic syntax extensively throughout the codebase.
Applied to files:
pyproject.toml
📚 Learning: the draive project uses and requires python 3.12+, so pep-695 generic syntax with square brackets (e...
Learnt from: KaQuMiQ
PR: miquido/draive#327
File: src/draive/helpers/instruction_preparation.py:28-34
Timestamp: 2025-05-28T17:41:57.460Z
Learning: The draive project uses and requires Python 3.12+, so PEP-695 generic syntax with square brackets (e.g., `def func[T: Type]()`) is valid and should be used instead of the older TypeVar approach.
Applied to files:
pyproject.toml
📚 Learning: applies to **/*.py : use absolute imports from `draive` package...
Learnt from: CR
PR: miquido/draive#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-21T11:09:57.256Z
Learning: Applies to **/*.py : Use absolute imports from `draive` package
Applied to files:
pyproject.toml
📚 Learning: applies to **/*.py : use custom exceptions for specific errors...
Learnt from: CR
PR: miquido/draive#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-21T11:09:57.256Z
Learning: Applies to **/*.py : Use custom exceptions for specific errors
Applied to files:
src/draive/stages/stage.py
📚 Learning: conversationmessage is a datamodel with built-in runtime validation. when calling methods like conve...
Learnt from: KaQuMiQ
PR: miquido/draive#338
File: src/draive/conversation/completion/state.py:61-68
Timestamp: 2025-06-16T10:01:14.014Z
Learning: ConversationMessage is a DataModel with built-in runtime validation. When calling methods like ConversationMessage.user(multimodal), the DataModel validates types at runtime and raises appropriate exceptions for invalid inputs, eliminating the need for explicit type checking in pattern matching.
Applied to files:
src/draive/conversation/types.py
📚 Learning: in the draive.commons.metadata.meta class, properties like `identifier`, `origin_identifier`, `prede...
Learnt from: KaQuMiQ
PR: miquido/draive#338
File: src/draive/conversation/types.py:123-144
Timestamp: 2025-06-16T10:09:51.508Z
Learning: In the draive.commons.metadata.Meta class, properties like `identifier`, `origin_identifier`, `predecessor_identifier`, and `successor_identifier` automatically parse stored hex strings into UUID objects when accessed, returning None if the string is missing or invalid. This means accessing `meta.identifier` returns a UUID object, not a string, even though it's stored internally as a hex string.
Applied to files:
src/draive/openai/lmm_session.py
🔇 Additional comments (7)
pyproject.toml (1)
8-8: LGTM - Appropriate version bump.The patch version increment from 0.82.0 to 0.82.1 correctly follows semantic versioning for a bug fix related to realtime message ID handling.
src/draive/stages/stage.py (1)
1744-1744: Critical bug fix - Exception type checking corrected.The change from
if exc in exceptions:toif type(exc) in exceptions:fixes a logical error where exception instances were being compared to exception types, which would never match. The fallback mechanism now correctly checks if the caught exception's type is in the allowed exceptions collection.src/draive/conversation/realtime/default.py (1)
136-136: LGTM - Improved metadata key naming.The rename from
"identifier"to"call_id"provides better semantic clarity for tool call events and aligns with the broader effort to standardize identifier management across the codebase.src/draive/conversation/types.py (1)
127-142: LGTM - Clean refactor to explicit type checking.The replacement of pattern matching with explicit
isinstancechecks maintains the same functionality while providing clear, readable type handling. The assertion ensures type safety for the else branch, and the logic correctly mapsLMMCompletionto model messages andLMMInputto user messages.src/draive/openai/lmm_session.py (3)
122-137: LGTM! Well-designed identifier management function.The
message_identifierhelper function provides a clean abstraction for UUID-based identifier generation and caching. The implementation correctly:
- Uses a closure to access
current_items- Caches identifiers to avoid regeneration for the same
item_id- Returns consistent UUID strings
- Stores metadata alongside the identifier
163-163: Consistent identifier usage - excellent standardization.All the calls to
message_identifier(event.item_id)andmessage_identifier(event.item.id)provide consistent UUID-based identifiers instead of using raw event IDs. This standardization improves identifier management across the session.Also applies to: 173-173, 183-183, 193-193, 206-206, 216-216, 280-280, 293-293, 303-303
321-322: Improved metadata structure for conversation items.The changes to explicitly store both
"item_id"and"identifier"(as UUID string) in the Meta objects provide better separation of concerns:
"item_id"maintains the original OpenAI item identifier"identifier"provides the standardized UUID for internal useThis aligns well with the new
message_identifierfunction's caching mechanism.Also applies to: 333-334
No description provided.