Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[fine_tuning] fix pagination for auto-generated list_events (#188) #597

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

Merged
merged 1 commit into from
Aug 31, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions openai/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down