-
Notifications
You must be signed in to change notification settings - Fork 415
Feature: UI dynamic provider model discovery #1274
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
Merged
EItanya
merged 17 commits into
kagent-dev:main
from
nujragan93:feature/provider-model-discovery
Feb 19, 2026
+3,044
−277
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
cf5ca24
Add model discovery feature for UI
772d4a2
Merge branch 'kagent-dev:main' into feature/provider-model-discovery
nujragan93 2833040
default envpoints and fix manager
68df742
more fixes
bb38ad2
Merge branch 'feature/provider-model-discovery' of https://github.com…
1de291b
Merge branch 'main' into feature/provider-model-discovery
nujragan93 d870da4
Merge branch 'main' into feature/provider-model-discovery
nujragan93 1b302d7
Merge branch 'main' into feature/provider-model-discovery
nujragan93 3269e81
Merge branch 'feature/provider-model-discovery' of https://github.com…
68c4da8
rename provider to modelconfigprovider
110cc9a
Merge branch 'kagent-dev:main' into feature/provider-model-discovery
nujragan93 4b78a5e
Merge branch 'kagent-dev:main' into feature/provider-model-discovery
nujragan93 174b6a3
Merge branch 'feature/provider-model-discovery' of https://github.com…
5de541b
remove key from secretRef
28a5989
Fix go fmt issues and crd linting
07336b3
fix e2e tests and nil pointer references
1c802bf
Merge branch 'main' into feature/provider-model-discovery
nujragan93 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| /* | ||
| Copyright 2025. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package v1alpha2 | ||
|
|
||
| import ( | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| const ( | ||
| // ModelProviderConfigConditionTypeReady indicates whether the model provider config is ready for use | ||
| ModelProviderConfigConditionTypeReady = "Ready" | ||
|
|
||
| // ModelProviderConfigConditionTypeSecretResolved indicates whether the model provider config's secret reference is valid | ||
| ModelProviderConfigConditionTypeSecretResolved = "SecretResolved" | ||
|
|
||
| // ModelProviderConfigConditionTypeModelsDiscovered indicates whether model discovery has succeeded | ||
| ModelProviderConfigConditionTypeModelsDiscovered = "ModelsDiscovered" | ||
| ) | ||
|
|
||
| // DefaultModelProviderEndpoint returns the default API endpoint for a given model provider type. | ||
| // Returns empty string if no default is defined. | ||
| func DefaultModelProviderEndpoint(providerType ModelProvider) string { | ||
| switch providerType { | ||
| case ModelProviderOpenAI: | ||
| return "https://api.openai.com/v1" | ||
| case ModelProviderAnthropic: | ||
| return "https://api.anthropic.com" | ||
| case ModelProviderGemini: | ||
| return "https://generativelanguage.googleapis.com" | ||
| case ModelProviderOllama: | ||
| return "http://localhost:11434" | ||
| default: | ||
| // Azure, Bedrock, Vertex AI require user-specific endpoints | ||
| return "" | ||
| } | ||
| } | ||
|
|
||
| // SecretReference references a Kubernetes Secret that must contain exactly one data key | ||
| // holding the API key or credential. | ||
| type SecretReference struct { | ||
| // Name is the name of the secret in the same namespace as the ModelProviderConfig. | ||
| // +required | ||
| Name string `json:"name"` | ||
| } | ||
|
|
||
| // ModelProviderConfigSpec defines the desired state of ModelProviderConfig. | ||
| // | ||
| // +kubebuilder:validation:XValidation:message="endpoint must be a valid URL starting with http:// or https://",rule="!has(self.endpoint) || size(self.endpoint) == 0 || self.endpoint.startsWith('http://') || self.endpoint.startsWith('https://')" | ||
| // +kubebuilder:validation:XValidation:message="secretRef is required for providers that need authentication (not Ollama)",rule="self.type == 'Ollama' || (has(self.secretRef) && has(self.secretRef.name) && size(self.secretRef.name) > 0)" | ||
| type ModelProviderConfigSpec struct { | ||
| // Type is the model provider type (OpenAI, Anthropic, etc.) | ||
| // +required | ||
| // +kubebuilder:validation:Required | ||
| Type ModelProvider `json:"type"` | ||
|
|
||
| // Endpoint is the API endpoint URL for the provider. | ||
| // If not specified, the default endpoint for the provider type will be used. | ||
| // +optional | ||
| // +kubebuilder:validation:Pattern=`^https?://.*` | ||
| Endpoint string `json:"endpoint,omitempty"` | ||
|
|
||
| // SecretRef references the Kubernetes Secret containing the API key. | ||
| // Optional for providers that don't require authentication (e.g., local Ollama). | ||
| // +optional | ||
| SecretRef *SecretReference `json:"secretRef,omitempty"` | ||
| } | ||
|
|
||
| // GetEndpoint returns the endpoint, or the default endpoint if not specified. | ||
| func (p *ModelProviderConfigSpec) GetEndpoint() string { | ||
| if p.Endpoint != "" { | ||
| return p.Endpoint | ||
| } | ||
| return DefaultModelProviderEndpoint(p.Type) | ||
| } | ||
|
|
||
| // RequiresSecret returns true if this model provider type requires a secret for authentication. | ||
| func (p *ModelProviderConfigSpec) RequiresSecret() bool { | ||
| return p.Type != ModelProviderOllama | ||
| } | ||
|
|
||
| // ModelProviderConfigStatus defines the observed state of ModelProviderConfig. | ||
| type ModelProviderConfigStatus struct { | ||
| // ObservedGeneration reflects the generation of the most recently observed ModelProviderConfig spec | ||
| // +optional | ||
| ObservedGeneration int64 `json:"observedGeneration,omitempty"` | ||
|
|
||
| // Conditions represent the latest available observations of the ModelProviderConfig's state | ||
| // +optional | ||
| // +listType=map | ||
| // +listMapKey=type | ||
| Conditions []metav1.Condition `json:"conditions,omitempty"` | ||
|
|
||
| // DiscoveredModels is the cached list of model IDs available from this model provider | ||
| // +optional | ||
| DiscoveredModels []string `json:"discoveredModels,omitempty"` | ||
|
|
||
| // ModelCount is the number of discovered models (for kubectl display) | ||
| // +optional | ||
| ModelCount int `json:"modelCount,omitempty"` | ||
|
|
||
| // LastDiscoveryTime is the timestamp of the last successful model discovery | ||
| // +optional | ||
| LastDiscoveryTime *metav1.Time `json:"lastDiscoveryTime,omitempty"` | ||
|
|
||
| // SecretHash is a hash of the referenced secret data, used to detect secret changes | ||
| // +optional | ||
| SecretHash string `json:"secretHash,omitempty"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:resource:categories=kagent,shortName=mprov | ||
| // +kubebuilder:subresource:status | ||
| // +kubebuilder:printcolumn:name="Type",type="string",JSONPath=".spec.type" | ||
| // +kubebuilder:printcolumn:name="Endpoint",type="string",JSONPath=".spec.endpoint" | ||
| // +kubebuilder:printcolumn:name="Models",type="integer",JSONPath=".status.modelCount" | ||
| // +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" | ||
| // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" | ||
| // +kubebuilder:storageversion | ||
|
|
||
| // ModelProviderConfig is the Schema for the modelproviderconfigs API. | ||
| // It represents a model provider configuration with automatic model discovery. | ||
| type ModelProviderConfig struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
|
||
| Spec ModelProviderConfigSpec `json:"spec,omitempty"` | ||
| Status ModelProviderConfigStatus `json:"status,omitempty"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
|
|
||
| // ModelProviderConfigList contains a list of ModelProviderConfig. | ||
| type ModelProviderConfigList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ListMeta `json:"metadata,omitempty"` | ||
| Items []ModelProviderConfig `json:"items"` | ||
| } | ||
|
|
||
| func init() { | ||
| SchemeBuilder.Register(&ModelProviderConfig{}, &ModelProviderConfigList{}) | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.