-
Notifications
You must be signed in to change notification settings - Fork 369
feat: add ai presets schema #1928
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
Conversation
WalkthroughThe changes refactor the schema generation process by consolidating multiple functions into a single, more flexible function that accepts a template and a directory parameter. The dedicated functions for generating settings and connection schemas are removed, and their logic is now handled within the new generic function. Error handling has been improved by wrapping underlying errors with more contextual information. The main function is updated to generate different types of schemas, including one for AI presets. Correspondingly, the frontend mapping is extended with an endpoint for the AI presets file, and a new JSON schema file is added to define the structure and validations for AI settings. These modifications streamline schema generation and support enhanced configuration and error reporting. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
🔇 Additional comments (4)
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
cmd/generateschema/main-generateschema.go (1)
21-33
: Generic schema generation function looks solid.
• Good use of jsonschema.Reflect and os.Stderr notifications for unchanged files.
• Error wrapping with %w facilitates improved traceability.
• Variable and parameter naming could be improved for clarity (e.g., rename "template" to "schemaTemplate").schema/aipresets.json (1)
1-54
: Comprehensive schema definition for AI presets.
• Good use of a dedicated $defs object for AiSettingsType.
• The “ai:*” property is unusual; consider using patternProperties if you intend to match partial key patterns instead of a literal name.
• Defining bounds (e.g., minimum, maximum) or examples for numeric fields such as ai:maxtokens, ai:timeoutms, etc. can further improve clarity.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
cmd/generateschema/main-generateschema.go
(1 hunks)frontend/app/view/codeeditor/schemaendpoints.ts
(1 hunks)schema/aipresets.json
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
- GitHub Check: Build for TestDriver.ai
🔇 Additional comments (4)
cmd/generateschema/main-generateschema.go (3)
19-19
: New constant is well-introduced.
This definition aligns with the existing convention for schema filenames and clearly expresses its purpose in the name.
38-41
: Settings schema generation works as expected.
The usage of generateSchema for wconfig.SettingsType matches the pattern, and error handling is straightforward.
44-47
: Connections schema generation is consistent.
Applying the same approach for connectionTemplate ensures uniformity.frontend/app/view/codeeditor/schemaendpoints.ts (1)
16-16
: New AI presets schema endpoint.
This addition is consistent with the existing pattern, mapping the new AI presets configuration file to its schema endpoint.
aiPresetsTemplate := make(map[string]wconfig.AiSettingsType) | ||
err = generateSchema(&aiPresetsTemplate, WaveSchemaAiPresetsFileName) | ||
if err != nil { | ||
log.Fatalf("connections schema error: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix incorrect error message for AI presets schema.
Currently, the failure message references “connections schema”. This is misleading and should be updated to “AI presets schema” to match the actual functionality.
Apply this diff to correct the log message:
- log.Fatalf("connections schema error: %v", err)
+ log.Fatalf("AI presets schema error: %v", err)
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
aiPresetsTemplate := make(map[string]wconfig.AiSettingsType) | |
err = generateSchema(&aiPresetsTemplate, WaveSchemaAiPresetsFileName) | |
if err != nil { | |
log.Fatalf("connections schema error: %v", err) | |
aiPresetsTemplate := make(map[string]wconfig.AiSettingsType) | |
err = generateSchema(&aiPresetsTemplate, WaveSchemaAiPresetsFileName) | |
if err != nil { | |
log.Fatalf("AI presets schema error: %v", err) |
No description provided.