Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter messages by the run ID that generated them. (run_id string Optional) #855

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .zshrc
Empty file.
2 changes: 1 addition & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func TestClientReturnsRequestBuilderErrors(t *testing.T) {
return client.CreateMessage(ctx, "", MessageRequest{})
}},
{"ListMessage", func() (any, error) {
return client.ListMessage(ctx, "", nil, nil, nil, nil)
return client.ListMessage(ctx, "", nil, nil, nil, nil, nil)
}},
{"RetrieveMessage", func() (any, error) {
return client.RetrieveMessage(ctx, "", "")
Expand Down
5 changes: 5 additions & 0 deletions messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func (c *Client) ListMessage(ctx context.Context, threadID string,
order *string,
after *string,
before *string,
runID *string,
) (messages MessagesList, err error) {
urlValues := url.Values{}
if limit != nil {
Expand All @@ -114,6 +115,10 @@ func (c *Client) ListMessage(ctx context.Context, threadID string,
if before != nil {
urlValues.Add("before", *before)
}
if runID != nil {
urlValues.Add("run_id", *runID)
}

encodedValues := ""
if len(urlValues) > 0 {
encodedValues = "?" + urlValues.Encode()
Expand Down
5 changes: 3 additions & 2 deletions messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func TestMessages(t *testing.T) {
}

var msgs openai.MessagesList
msgs, err = client.ListMessage(ctx, threadID, nil, nil, nil, nil)
msgs, err = client.ListMessage(ctx, threadID, nil, nil, nil, nil, nil)
checks.NoError(t, err, "ListMessages error")
if len(msgs.Messages) != 1 {
t.Fatalf("unexpected length of fetched messages")
Expand All @@ -219,7 +219,8 @@ func TestMessages(t *testing.T) {
order := "desc"
after := "obj_foo"
before := "obj_bar"
msgs, err = client.ListMessage(ctx, threadID, &limit, &order, &after, &before)
runID := "run_abc123"
msgs, err = client.ListMessage(ctx, threadID, &limit, &order, &after, &before, &runID)
checks.NoError(t, err, "ListMessages error")
if len(msgs.Messages) != 1 {
t.Fatalf("unexpected length of fetched messages")
Expand Down
Loading