Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Conversation

@mattjohnsonpint
Copy link
Contributor

@mattjohnsonpint mattjohnsonpint commented May 21, 2025

This adds a ParseMessages function to the OpenAI model interface in the SDKs. These can be used for restoring chat messages in a conversation loop.

When restored, the original message type is not used. Rather, a RawMessage type is used instead. This preserves the JSON contents of the message for replay/round-tripping, without the overhead of rematerializing the specific message object structures.

Also updates all AssemblyScript projects to use json-as 1.0.8

@mattjohnsonpint mattjohnsonpint requested review from a team and Copilot May 21, 2025 22:51
@linear
Copy link

linear bot commented May 21, 2025

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces functions for parsing chat messages to enable message round-tripping without re-materializing the original message types. Key changes include:

  • Adding a ParseMessages function and corresponding raw message types for both Go and AssemblyScript.
  • Implementing unit tests in Go and AssemblyScript to verify the round-trip JSON representation.
  • Updating the AssemblyScript test harness and build configuration for the new functionality.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
sdk/go/pkg/models/openai/chat_test.go Adds test coverage for the ParseMessages function in Go.
sdk/go/pkg/models/openai/chat.go Implements the raw message type and ParseMessages function.
sdk/assemblyscript/src/tests/openai.run.ts Updates the instantiation setup for AssemblyScript tests.
sdk/assemblyscript/src/models/openai/chat.ts Introduces the RawMessage class and parseMessages function.
sdk/assemblyscript/src/assembly/tests/openai.spec.ts Adds a round-trip test for chat messages in AssemblyScript.
Comments suppressed due to low confidence (1)

sdk/go/pkg/models/openai/chat.go:1252

  • The rawMessage implementation uses fmt.Errorf but there is no import for the 'fmt' package. Please add 'import "fmt"' to avoid compilation errors.
return nil, fmt.Errorf("missing data in message")

@trunk-io
Copy link

trunk-io bot commented May 21, 2025

Running Code Quality on PRs by uploading data to Trunk will soon be removed. You can still run checks on your PRs using trunk-action - see the migration guide for more information.

@mattjohnsonpint mattjohnsonpint marked this pull request as draft May 21, 2025 22:53
@mattjohnsonpint
Copy link
Contributor Author

@JairusSW - please take a look at the json issue. Thanks.

@mattjohnsonpint
Copy link
Contributor Author

I have captured the JSON issue here: JairusSW/json-as#132

@mattjohnsonpint mattjohnsonpint marked this pull request as ready for review May 22, 2025 18:49
@mattjohnsonpint mattjohnsonpint enabled auto-merge (squash) May 22, 2025 18:51
@mattjohnsonpint mattjohnsonpint merged commit 80656ff into main May 22, 2025
160 checks passed
@mattjohnsonpint mattjohnsonpint deleted the mjp/hyp-3397-model-message-state-reconstruction branch May 22, 2025 18:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants