Andrewcpu/elevenlabs-api

History.getLastHistoryItemId does not return latest history item id

Closed this issue · 7 comments

Maybe I am understanding the method wrong, but I would assume that "getLastHistoryItemId" returns the id of the last history item that was generated.
But instead, it returns entry number 99 from history.getHistoryItems()

image

Is this correct?

I'll take a look later today.. If it's not working correctly, they may have paginated the history list via the API. I will have to check it out.

Apparently, History.getHistoryItems only returns the last 100 items.
I just implemented pagination, could you give me permission to create a branch and push to it?
Or how does that work? :)

Also: getLastHistoryItemID actually gives the ID of the last item from the current pagination, to use as the offset for future requests.

Yup, all good. I just released an update of the library (2.7.8) which includes pagination + new builders for S2S / T2S.. Going forward, you can make a pull request.. I think if you clone the repo locally, you can make PR to this repo and I can review / approve.

Check this: https://stackoverflow.com/questions/14906187/how-to-submit-a-pull-request-from-a-cloned-repo

Also, let me know if you're able to see 2.7.8 and if it works for your use case.

New pagination docs:

    History history = History.get(); // the latest history object
    Optional<History> hist = Optional.of(history);
    List<HistoryItem> items = new ArrayList();
    do {
        items.addAll(hist.get().getHistoryItems());
        hist = hist.get().next();
    } while(hist.isPresent() && hist.hasMore());

Having issues actually deploying to Maven Central, they're having some serious delays. Will let you know when 2.7.8 is available

@Dustinhoefer Ok, 2.7.8 should be released and ready for use. Not sure what was up at Maven Central yesterday, but I could not get a version to deploy.

Works like a charm, thank you so much!

No problem, glad you're enjoying! Have fun