Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 46 additions & 16 deletions go/autogen/api/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ type ModelInfo struct {
Family string `json:"family"`
}

type CreateArgumentsConfig struct {
type OpenAICreateArgumentsConfig struct {
FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
LogitBias map[string]float64 `json:"logit_bias,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
N *int `json:"n,omitempty"`
PresencePenalty *float64 `json:"presence_penalty,omitempty"`
ResponseFormat interface{} `json:"response_format,omitempty"`
Seed *int `json:"seed,omitempty"`
Stop interface{} `json:"stop,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
User *string `json:"user,omitempty"`
Expand All @@ -28,14 +26,13 @@ type StreamOptions struct {

type BaseOpenAIClientConfig struct {
// Base OpenAI fields
Model string `json:"model"`
APIKey *string `json:"api_key,omitempty"`
Timeout *int `json:"timeout,omitempty"`
MaxRetries *int `json:"max_retries,omitempty"`
ModelCapabilities interface{} `json:"model_capabilities,omitempty"`
ModelInfo *ModelInfo `json:"model_info,omitempty"`
StreamOptions *StreamOptions `json:"stream_options,omitempty"`
CreateArgumentsConfig
Model string `json:"model"`
APIKey *string `json:"api_key,omitempty"`
Timeout *int `json:"timeout,omitempty"`
MaxRetries *int `json:"max_retries,omitempty"`
ModelInfo *ModelInfo `json:"model_info,omitempty"`
StreamOptions *StreamOptions `json:"stream_options,omitempty"`
OpenAICreateArgumentsConfig
}

type OpenAIClientConfig struct {
Expand All @@ -58,11 +55,11 @@ type AzureOpenAIClientConfig struct {
BaseOpenAIClientConfig

// AzureOpenAIClientConfig specific fields
AzureEndpoint *string `json:"azure_endpoint,omitempty"`
AzureDeployment *string `json:"azure_deployment,omitempty"`
APIVersion *string `json:"api_version,omitempty"`
AzureADToken *string `json:"azure_ad_token,omitempty"`
AzureADTokenProvider interface{} `json:"azure_ad_token_provider,omitempty"`
AzureEndpoint *string `json:"azure_endpoint,omitempty"`
AzureDeployment *string `json:"azure_deployment,omitempty"`
APIVersion *string `json:"api_version,omitempty"`
AzureADToken *string `json:"azure_ad_token,omitempty"`
Stream *bool `json:"stream,omitempty"`
}

func (c *AzureOpenAIClientConfig) ToConfig() (map[string]interface{}, error) {
Expand All @@ -72,3 +69,36 @@ func (c *AzureOpenAIClientConfig) ToConfig() (map[string]interface{}, error) {
func (c *AzureOpenAIClientConfig) FromConfig(config map[string]interface{}) error {
return fromConfig(c, config)
}

type AnthropicCreateArguments struct {
MaxTokens *int `json:"max_tokens,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
TopK *int `json:"top_k,omitempty"`
StopSequences []string `json:"stop_sequences,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}

type BaseAnthropicClientConfiguration struct {
APIKey *string `json:"api_key,omitempty"`
BaseURL *string `json:"base_url,omitempty"`
Model string `json:"model"`
ModelCapabilities *ModelInfo `json:"model_capabilities,omitempty"`
ModelInfo *ModelInfo `json:"model_info,omitempty"`
Timeout *float64 `json:"timeout,omitempty"`
MaxRetries *int `json:"max_retries,omitempty"`
DefaultHeaders map[string]string `json:"default_headers,omitempty"`
AnthropicCreateArguments
}

type AnthropicClientConfiguration struct {
BaseAnthropicClientConfiguration
}

func (c *AnthropicClientConfiguration) ToConfig() (map[string]interface{}, error) {
return toConfig(c)
}

func (c *AnthropicClientConfiguration) FromConfig(config map[string]interface{}) error {
return fromConfig(c, config)
}
6 changes: 6 additions & 0 deletions go/config/crd/bases/kagent.dev_agents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ spec:
jsonPath: .status.conditions[0].status
name: Accepted
type: string
- description: The ModelConfig resource referenced by this agent.
jsonPath: .spec.modelConfigRef
name: ModelConfig
type: string
name: v1alpha1
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -46,6 +50,8 @@ spec:
properties:
description:
type: string
modelConfigRef:
type: string
systemMessage:
minLength: 1
type: string
Expand Down
104 changes: 103 additions & 1 deletion go/config/crd/bases/kagent.dev_modelconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ spec:
singular: modelconfig
scope: Namespaced
versions:
- name: v1alpha1
- additionalPrinterColumns:
- jsonPath: .spec.provider
name: Provider
type: string
- jsonPath: .spec.model
name: Model
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: ModelConfig is the Schema for the modelconfigs API.
Expand All @@ -39,16 +46,111 @@ spec:
spec:
description: ModelConfigSpec defines the desired state of ModelConfig.
properties:
anthropicC:
description: Anthropic-specific configuration
properties:
baseUrl:
description: Base URL for the Anthropic API (overrides default)
type: string
maxTokens:
description: Maximum tokens to generate
type: integer
temperature:
description: Temperature for sampling
type: string
topK:
description: Top-k sampling parameter
type: integer
topP:
description: Top-p sampling parameter
type: string
type: object
apiKeySecretKey:
type: string
apiKeySecretName:
type: string
azureOpenAI:
description: Azure OpenAI-specific configuration
properties:
apiVersion:
description: API version for the Azure OpenAI API
type: string
azureAdToken:
description: Azure AD token for authentication
type: string
azureDeployment:
description: Deployment name for the Azure OpenAI API
type: string
azureEndpoint:
description: Endpoint for the Azure OpenAI API
type: string
maxTokens:
description: Maximum tokens to generate
type: integer
temperature:
description: Temperature for sampling
type: string
topP:
description: Top-p sampling parameter
type: string
required:
- apiVersion
- azureEndpoint
type: object
model:
type: string
openAI:
description: OpenAI-specific configuration
properties:
baseUrl:
description: Base URL for the OpenAI API (overrides default)
type: string
frequencyPenalty:
description: Frequency penalty
type: string
maxTokens:
description: Maximum tokens to generate
type: integer
"n":
description: N value
type: integer
organization:
description: Organization ID for the OpenAI API
type: string
presencePenalty:
description: Presence penalty
type: string
seed:
description: Seed value
type: integer
temperature:
description: Temperature for sampling
type: string
timeout:
description: Timeout
type: integer
topP:
description: Top-p sampling parameter
type: string
type: object
provider:
allOf:
- enum:
- Anthropic
- OpenAI
- AzureOpenAI
- enum:
- Anthropic
- OpenAI
- AzureOpenAI
default: OpenAI
description: The provider of the model
type: string
required:
- apiKeySecretKey
- apiKeySecretName
- model
- provider
type: object
status:
description: ModelConfigStatus defines the observed state of ModelConfig.
Expand Down
3 changes: 3 additions & 0 deletions go/controller/api/v1alpha1/autogenagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ type AgentSpec struct {
Description string `json:"description,omitempty"`
// +kubebuilder:validation:MinLength=1
SystemMessage string `json:"systemMessage,omitempty"`
// +optional
ModelConfigRef string `json:"modelConfigRef"`
// +kubebuilder:validation:MaxItems=20
Tools []*Tool `json:"tools,omitempty"`
}
Expand Down Expand Up @@ -58,6 +60,7 @@ type AgentStatus struct {
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Accepted",type="string",JSONPath=".status.conditions[0].status",description="Whether or not the agent has been accepted by the system."
// +kubebuilder:printcolumn:name="ModelConfig",type="string",JSONPath=".spec.modelConfigRef",description="The ModelConfig resource referenced by this agent."

// Agent is the Schema for the agents API.
type Agent struct {
Expand Down
Loading