Skip to content

Commit

Permalink
Revert "[BREAKING_CHANGES] Fix update message payload (sashabaranov#699
Browse files Browse the repository at this point in the history
…)"

This reverts commit 187f416.
  • Loading branch information
jackdoe committed Apr 9, 2024
1 parent 7bff249 commit 01b53c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
4 changes: 2 additions & 2 deletions messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ func (c *Client) RetrieveMessage(
func (c *Client) ModifyMessage(
ctx context.Context,
threadID, messageID string,
metadata map[string]string,
metadata map[string]any,
) (msg Message, err error) {
urlSuffix := fmt.Sprintf("/threads/%s/%s/%s", threadID, messagesSuffix, messageID)
req, err := c.newRequest(ctx, http.MethodPost, c.fullURL(urlSuffix),
withBody(map[string]any{"metadata": metadata}), withBetaAssistantV1())
withBody(metadata), withBetaAssistantV1())
if err != nil {
return
}
Expand Down
9 changes: 2 additions & 7 deletions messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ func TestMessages(t *testing.T) {
metadata := map[string]any{}
err := json.NewDecoder(r.Body).Decode(&metadata)
checks.NoError(t, err, "unable to decode metadata in modify message call")
payload, ok := metadata["metadata"].(map[string]any)
if !ok {
t.Fatalf("metadata payload improperly wrapped %+v", metadata)
}

resBytes, _ := json.Marshal(
openai.Message{
Expand All @@ -90,9 +86,8 @@ func TestMessages(t *testing.T) {
FileIds: nil,
AssistantID: &emptyStr,
RunID: &emptyStr,
Metadata: payload,
Metadata: metadata,
})

fmt.Fprintln(w, string(resBytes))
case http.MethodGet:
resBytes, _ := json.Marshal(
Expand Down Expand Up @@ -217,7 +212,7 @@ func TestMessages(t *testing.T) {
}

msg, err = client.ModifyMessage(ctx, threadID, messageID,
map[string]string{
map[string]any{
"foo": "bar",
})
checks.NoError(t, err, "ModifyMessage error")
Expand Down

0 comments on commit 01b53c3

Please sign in to comment.