chore(knowledgebase): clean collection names (no spaces,no uppercase) - #385
Merged
Merged
Conversation
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to sanitize collection names in the knowledge base by removing spaces and converting to lowercase to ensure consistent naming conventions.
Changes:
- Modified
NewWrappedClientfunction to sanitize collection names by trimming spaces and converting to lowercase - Added import for
stringspackage
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| func NewWrappedClient(baseURL, apiKey, collection string) *WrappedClient { | ||
| func NewWrappedClient(baseURL, apiKey, c string) *WrappedClient { | ||
| collection := strings.TrimSpace(strings.ToLower(c)) |
There was a problem hiding this comment.
The implementation only removes leading and trailing spaces using TrimSpace, but according to the PR title "no spaces", all spaces (including internal ones) should be removed. For example, a collection name "My Collection Name" would become "my collection name" instead of "mycollectionname". Consider using strings.ReplaceAll to remove all spaces from the collection name.
Suggested change
| collection := strings.TrimSpace(strings.ToLower(c)) | |
| collection := strings.ReplaceAll(strings.ToLower(strings.TrimSpace(c)), " ", "") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
collection names can't contain upper characters or spaces (breaks pgsql indexes)