[BREAKING_CHANGES] Fix update message payload (#699)

* add custom marshaller, documentation and isolate tests

* fix linter

* wrap payload as expected from the API and update test

* modify input to accept map[string]string only
This commit is contained in:
Quest Henkart
2024-04-09 16:22:31 +08:00
committed by GitHub
parent 774fc9dd12
commit 187f4169f8
2 changed files with 9 additions and 4 deletions

View File

@@ -68,6 +68,10 @@ 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{
@@ -86,8 +90,9 @@ func TestMessages(t *testing.T) {
FileIds: nil,
AssistantID: &emptyStr,
RunID: &emptyStr,
Metadata: metadata,
Metadata: payload,
})
fmt.Fprintln(w, string(resBytes))
case http.MethodGet:
resBytes, _ := json.Marshal(
@@ -212,7 +217,7 @@ func TestMessages(t *testing.T) {
}
msg, err = client.ModifyMessage(ctx, threadID, messageID,
map[string]any{
map[string]string{
"foo": "bar",
})
checks.NoError(t, err, "ModifyMessage error")