Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Relax modelconfig name restrictions#64161

Merged
chrsmith merged 3 commits into
mainfrom
chrsmith/PRIME-451/relax-modelconfig-naming
Jul 30, 2024
Merged

Relax modelconfig name restrictions#64161
chrsmith merged 3 commits into
mainfrom
chrsmith/PRIME-451/relax-modelconfig-naming

Conversation

@chrsmith

Copy link
Copy Markdown
Contributor

This PR greatly relaxes the naming restrictions for resource IDs when using the new modelconfig LLM model configuration system.

The original intent was to set a high bar for how we would allow users to refer to LLM providers, API versions, or models. So that we could have use those names in URLs and/or display them if no human-friendly name was supplied. e.g. opanai::v1::gpt-3.5-turbo.

However, in practice, this was just a bit too optimistic. We already had carved out an exception for "API versions" to be less strict, since there were some cases where we saw those included slashes and things. And one of our trusted testers immediately ran into problems because the model name had an @ in it. (See the linked issue.)

In order to avoid perpetually trying to work around LLM providers and whatever IDs they use for things, it seemed preferable to just relax our rules.

With this PR, we will constraint Provider, API Versions, and Model IDs to only be URL-safe(*). So previously characters like []@/+;! were prohibited, they are now allowed.) However, we still restrict names to only include a-zA-Z and no unicode characters, and curly braces are not allowed. (But [] and () are.

Pedantically, we do not want to say they are exactly URL safe. Because we don't perform any sort of escaping (e.g. "%20" -> " ", etc.) Nor do we allow the : which is allowed by the RFC, since we are using that to delimit parts of the model ref.

Anyways, this should provide enough flexibility to avoid most (hopefully all) problems users would encounter. While still enforcing some type of standards with regard to how models are defined.

Fixes PRIME-451 : invalid ModelID (claude-3-5-sonnet@20240620) after upgrading to 5.5.2463.)

Test plan

Added tests.

Changelog

NA.

@chrsmith chrsmith requested a review from emidoots July 30, 2024 20:22
@cla-bot cla-bot Bot added the cla-signed label Jul 30, 2024
func SanitizeResourceName(name string) string {
// Start by just converting everything to lower-case, so that
// the result doesn't look too awkward.
name = strings.ToLower(name)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This wasn't exactly called out in the bug, but seemed like a good change to make.

If we were automatically converting things to lower case as part of the sanitization process, it would lead to confusion. e.g. "I put 'FOO' in the site config but the model ID is 'foo'".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, definitely helpful!

@emidoots emidoots left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, test cases also look good - thank you!

@chrsmith chrsmith merged commit 3272026 into main Jul 30, 2024
@chrsmith chrsmith deleted the chrsmith/PRIME-451/relax-modelconfig-naming branch July 30, 2024 22:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants