Skip to content
New issue

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

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

Already on GitHub? # to your account

Feat add generate builder #127

Merged
merged 6 commits into from
Jan 1, 2025
Merged

Conversation

DumiJDev
Copy link
Contributor

@DumiJDev DumiJDev commented Dec 2, 2024

No description provided.

@DumiJDev
Copy link
Contributor Author

DumiJDev commented Dec 2, 2024

A method with many params can be verbose, flow API is more flexible and params can be passed calling the setter method, like:

Old method (verbose):

    Generator.Response r = m.generate(UUID.randomUUID(), ctx, 0.0f, 256, (s, f) -> {});

Flow API:

Generator.Response r = m.generateBuilder()
            .session(UUID.randomUUID()) //By default, UUID.randomUUID()
            .promptContext(ctx)
            .ntokens(256) //By default, 256
            .temperature(0.0f) //By default, 0.0f
            .onTokenWithTimings((s, aFloat) -> {}) //By default, (s, aFloat) -> {}, nothing
            .generate();
Generator.Response r = m.generateBuilder()
            .promptContext(ctx) //Required or can use prompt(String)
            .generate();

In first time, it appears verbose, but is very flexible, some params has a default value.

@tjake tjake merged commit d77ae59 into tjake:main Jan 1, 2025
4 checks passed
@tjake tjake linked an issue Jan 1, 2025 that may be closed by this pull request
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Flow API to generate
2 participants