langchainrb icon indicating copy to clipboard operation
langchainrb copied to clipboard

OpenAI#complete does not appear to allow max_tokens to be set

Open bricolage opened this issue 2 years ago • 6 comments

It looks like OpenAI#complete forces max_tokens to be the max available tokens based on the prompt / context.

I have to read more of the code to see how parameter defaults are being set, but it seems like this one might be as simple as changing the assignment to the "or-equals" operator, allowing it to be set only if it wasn't passed in as a param (that would be expected behavior, to my mind).

e.g.

parameters[:max_tokens] ||= validate_max_tokens(parameters[:messages], parameters[:model])

bricolage avatar Oct 22 '23 06:10 bricolage

@bricolage Would you be open to submitting a PR?

andreibondarev avatar Oct 30 '23 02:10 andreibondarev

@andreibondarev yeah for sure, should be able to do in the next few days

bricolage avatar Oct 30 '23 06:10 bricolage

@bricolage We probably need to fix this for all other LLMs as well?

andreibondarev avatar Nov 12 '23 22:11 andreibondarev

@andreibondarev yeah, I'm not super familiar with the other LLM APIs but am happy to tackle in another PR if we don't have any other devs who are pseudo-maintainers of the LLM wrappers.

bricolage avatar Nov 12 '23 23:11 bricolage

@andreibondarev just an update, I'll get support in the other LLM validators for their version of :max_tokens over the next few days.

bricolage avatar Nov 16 '23 14:11 bricolage

@andreibondarev just an update, I'll get support in the other LLM validators for their version of :max_tokens over the next few days.

That sounds great, thank you!

andreibondarev avatar Nov 16 '23 14:11 andreibondarev