-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Custom Providers #3967
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
Custom Providers #3967
Conversation
Move hardcoded prompts from router_tool_selector.rs and permission_judge.rs
into reusable .md template files using the MiniJinja template system.
Changes:
- Add router_tool_selector.md template with {{tools}} and {{query}} variables
- Add permission_judge.md template for read-only operation detection
- Update router_tool_selector.rs to use render_global_file()
- Update permission_judge.rs to use render_global_file() with fallback
- Add proper error handling for template rendering failures
- All existing tests continue to pass
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
| .placeholder("https://api.example.com/v1/messages") | ||
| .validate(|input: &String| { | ||
| if !input.starts_with("http://") && !input.starts_with("https://") { | ||
| Err("Inputed URL must start with either http:// or https://") |
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.
| Err("Inputed URL must start with either http:// or https://") | |
| Err("URL must start with either http:// or https://") |
| verify_secret_key(&headers, &state)?; | ||
|
|
||
| let key = name_to_key(&name); | ||
| let key = goose::config::extensions::name_to_key(&name); |
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.
why the import change?
| .clone() | ||
| .unwrap_or_else(|| { | ||
| format!( | ||
| "Custom {} provider", |
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.
| "Custom {} provider", | |
| "{} (custom)", |
| .to_uppercase() | ||
| .replace(" ", "_") | ||
| .replace("-", "_") | ||
| ); |
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.
some duplication between here and the CLI, maybe that could be reduced?
| /// custom providers | ||
| #[derive(Debug, Clone, Serialize, Deserialize)] | ||
| #[serde(rename_all = "lowercase")] | ||
| pub enum ProviderEngine { |
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.
I think we call this "format" elsewhere
| .map_err(|e| anyhow::anyhow!("Failed to parse {}: {}", path.display(), e))?; | ||
|
|
||
| configs.push(config); | ||
| } else { |
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.
empty else block
| } | ||
| } | ||
|
|
||
| /// load custom providers |
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.
| /// load custom providers |
| } | ||
|
|
||
| /// load custom providers | ||
| pub fn load_custom_providers(dir: &Path) -> Result<Vec<CustomProviderConfig>> { |
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.
this also duplicates a bit I think from routes/config_management
| REGISTRY.read().unwrap().all_metadata() | ||
| } | ||
|
|
||
| pub fn refresh_custom_providers() -> Result<()> { |
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.
any path here that actually returns an error?
|
closing in favor of #3824 |
fixing: #3824