Closed
Conversation
Add AnyCodable helper for decoding unstructured JSON payloads. Add ToolCall, ToolCallFunction, ToolCallList for tool-calls events. Add ToolCallResult for tool-calls-result events. Add TransferUpdate and TransferDestination for transfer-update events. Add LanguageChangeDetected for language-change-detected events. Add WorkflowNodeStarted for workflow.node.started events. Co-authored-by: Sahil Suman <sahilsuman933@users.noreply.github.com>
The SDK was failing to parse messages with types not in the AppMessage.MessageType enum (e.g. assistant.started, tool-calls, transfer-update). This caused JSON decoding errors like: Error parsing app message: The data couldn't be read because it isn't in the correct format. Changes: - Replace String-backed enum with custom Codable implementation that maps raw type strings to cases and falls back to .unknown(String) for any unrecognized types, preventing parsing failures. - Add 13 missing event types from the api.vapi.ai/api-json schema: assistant.started, workflow.node.started, tool-calls, tool-calls-result, transfer-update, language-change-detected, chat.created, chat.deleted, session.created, session.updated, session.deleted, call.deleted, call.delete.failed - Add corresponding Event enum cases and switch handlers in the message processing pipeline. - Update SwiftUI example to use default case for forward compatibility. Co-authored-by: Sahil Suman <sahilsuman933@users.noreply.github.com>
|
Cursor Agent can help with this pull request. Just |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix JSON parsing errors by adding missing client-side event types and making
AppMessage.MessageTypegracefully handle unknown event types.The SDK previously failed to decode
AppMessagewhen the server sent an event type not explicitly defined in theAppMessage.MessageTypeenum, leading to "The data couldn't be read because it isn't in the correct format" errors. This PR introduces a customCodableimplementation forAppMessage.MessageTypeto allow for unknown event types, preventing parsing failures, and adds models for all currently missing event types from the API schema.