Skip to content
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

Bug in getModelNameForTiktoken method? #1872

Closed
gal-checksum opened this issue Jul 5, 2023 · 1 comment
Closed

Bug in getModelNameForTiktoken method? #1872

gal-checksum opened this issue Jul 5, 2023 · 1 comment

Comments

@gal-checksum
Copy link

I'm using the function calculateMaxTokens to understand how many tokens I have left for a given prompt.

This function is not working properly, and upon digging further I found the issue with getModelNameForTiktoken. There's an extra "-" that are added to every startWith.

What is the reason for having a trailing dash for each model?

It creates a problem because when I pass gpt-3.5-turbo-16k as the model, it doesn't match gpt-3.5-turbo-16k- because of the extra "-" but it does match gpt-3.5-turbo, which returns the wrong model name, and thus the wrong model.

Happy to create a PR to fix, but I'm unsure if I can just remove the "-".

const getModelNameForTiktoken = (modelName) => {
    if (modelName.startsWith("gpt-3.5-turbo-16k-")) {
        return "gpt-3.5-turbo-16k";
    }
    if (modelName.startsWith("gpt-3.5-turbo-")) {
        return "gpt-3.5-turbo";
    }
    if (modelName.startsWith("gpt-4-32k-")) {
        return "gpt-4-32k";
    }
    if (modelName.startsWith("gpt-4-")) {
        return "gpt-4";
    }
    return modelName;
};
@jacoblee93
Copy link
Collaborator

Should be fixed by #1931 and released in 0.0.107!

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

No branches or pull requests

2 participants