From 1be14ee34a0f8e42d3f9aa5451aa4cb161f1781f Mon Sep 17 00:00:00 2001 From: John Allard Date: Thu, 31 Aug 2023 15:56:09 -0700 Subject: [PATCH 1/2] [fine_tuning] fix pagination for auto-generated list_events (#188) (#597) --- .../abstract/nested_resource_class_methods.py | 4 ++-- openai/cli.py | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/openai/api_resources/abstract/nested_resource_class_methods.py b/openai/api_resources/abstract/nested_resource_class_methods.py index 2f2dd45e40..f171737b17 100644 --- a/openai/api_resources/abstract/nested_resource_class_methods.py +++ b/openai/api_resources/abstract/nested_resource_class_methods.py @@ -127,11 +127,11 @@ def list_nested_resources(cls, id, **params): elif operation == "paginated_list": def paginated_list_nested_resources( - cls, id, limit=None, cursor=None, **params + cls, id, limit=None, after=None, **params ): url = getattr(cls, resource_url_method)(id) return getattr(cls, resource_request_method)( - "get", url, limit=limit, cursor=cursor, **params + "get", url, limit=limit, after=after, **params ) list_method = "list_%s" % resource_plural diff --git a/openai/cli.py b/openai/cli.py index c272d0b8d8..99d171a849 100644 --- a/openai/cli.py +++ b/openai/cli.py @@ -779,15 +779,17 @@ def results(cls, args): @classmethod def events(cls, args): - seen, has_more = 0, True + seen, has_more, after = 0, True, None while has_more: - resp = openai.FineTuningJob.list_events(id=args.id) # type: ignore + resp = openai.FineTuningJob.list_events(id=args.id, after=after) # type: ignore for event in resp["data"]: print(event) seen += 1 if args.limit is not None and seen >= args.limit: return - has_more = resp["has_more"] + has_more = resp.get("has_more", False) + if resp["data"]: + after = resp["data"][-1]["id"] @classmethod def follow(cls, args): From 075ab0349a5a7d94528bfef0fd7adc8e2baf7c5d Mon Sep 17 00:00:00 2001 From: jhallard Date: Thu, 31 Aug 2023 15:57:02 -0700 Subject: [PATCH 2/2] [release] Update version to v0.28.0 for new release --- openai/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openai/version.py b/openai/version.py index 51f3ce82ff..f62542b1ed 100644 --- a/openai/version.py +++ b/openai/version.py @@ -1 +1 @@ -VERSION = "0.27.9" +VERSION = "0.28.0"