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

Add validation for each provider when adding a custom model #1007

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

henryperkins
Copy link

@henryperkins henryperkins commented Jan 5, 2025

Related to #1004

Implement validation logic for each provider when adding a custom model.

  • src/settings/model.ts:

    • Add validateSettings and validateModelConfig functions to validate model configurations.
    • Implement provider-specific validation functions for OpenAI, Azure OpenAI, Anthropic, CohereAI, Google, OpenRouterAI, Groq, Ollama, LM Studio, and OpenAI Format.
    • Modify setSettings and updateSetting functions to include validation before updating settings.
  • README.md:

    • Add a troubleshooting section with common validation errors and their solutions.
  • src/settings/components/ApiSettings.tsx:

    • Add state management for validation errors and invalid fields.
    • Modify handleUpdateSetting function to handle validation and update settings.
    • Display validation error messages and highlight invalid fields in the UI.

For more details, open the Copilot Workspace session.

Related to logancyang#1004

Implement validation logic for each provider when adding a custom model.

* **`src/settings/model.ts`**:
  - Add `validateSettings` and `validateModelConfig` functions to validate model configurations.
  - Implement provider-specific validation functions for OpenAI, Azure OpenAI, Anthropic, CohereAI, Google, OpenRouterAI, Groq, Ollama, LM Studio, and OpenAI Format.
  - Modify `setSettings` and `updateSetting` functions to include validation before updating settings.

* **`README.md`**:
  - Add a troubleshooting section with common validation errors and their solutions.

* **`src/settings/components/ApiSettings.tsx`**:
  - Add state management for validation errors and invalid fields.
  - Modify `handleUpdateSetting` function to handle validation and update settings.
  - Display validation error messages and highlight invalid fields in the UI.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/logancyang/obsidian-copilot/issues/1004?shareId=XXXX-XXXX-XXXX-XXXX).
@henryperkins henryperkins marked this pull request as draft January 5, 2025 15:30
* **Validation and Error Handling**
  - Add validation logic to `setSettings` and `updateSetting` functions in `src/settings/model.ts`
  - Add error logging and user feedback for validation errors in `setSettings` and `updateSetting` functions
  - Prevent settings update if validation errors occur in `setSettings` and `updateSetting` functions

* **UI Enhancements**
  - Add `ModelSettingsComponent.tsx` to highlight invalid fields in custom model configuration UI based on validation errors
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

Successfully merging this pull request may close these issues.

1 participant