Skip to content

Conversation

aderbedr
Copy link
Contributor

Adding in NewContextWithStrategy, a function to allow you to specify the strategy when initializing the context. NewContext will use this "helper" function so that users don't need to think about what strategy they're specifying by default. I'm also doing it this way (instead of a function that sets the strategy) because the basis of what parameters we populate the context with is determined by the strategy we are using, so it needs to be done in the beginning of creating the context.

Adding in NewContextWithStrategy, a function to allow you to specify the
strategy when initializing the context. NewContext will use this
"helper" function so that users don't need to think about what strategy
they're specifying by default. I'm also doing it this way (instead of a
function that sets the strategy) because the basis of what parameters we
populate the context with is determined by the strategy we are using, so
it needs to be done in the beginning of creating the context.
@aderbedr
Copy link
Contributor Author

I'm not sure if you want this, but I need to swap what strategy we use easily and figured it was useful, so I'd push it up and let you decide.

Copy link
Member

@danbev danbev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about these changes but perhaps we need to make the API more flexible. One thing I noticed is that Whisper_init does not take a whisper.Params which the java binding does. Perhaps that would be an option here as well.

return model.NewContextWithStrategy(SAMPLING_GREEDY)
}

func (model *model) NewContextWithStrategy(strategy SamplingStrategy) (Context, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps instead of passing in just the strategy to this function, it could accepts a parameter of type whisper.Params?

// Make sure model adheres to the interface
var _ Model = (*model)(nil)

type SamplingStrategy whisper.SamplingStrategy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having this and the globals might be a little confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the other option was to have clients import both versions, but figured that'd be more of a headache. Alright, no worries!

@danbev
Copy link
Member

danbev commented Apr 1, 2025

Closing this for now as I'm not sure about adding this at the moment, but feel free to re-open.

@danbev danbev closed this Apr 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants