Skip to content

Commit 21d422a

Browse files
authored
Merge pull request #117 from kagent-dev/istio-agent-testing
statuses + Istio agent fixes
2 parents 3146c24 + 11016df commit 21d422a

23 files changed

+1138
-282
lines changed

go/autogen/client/validate.go

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package client
22

3-
import "github.com/kagent-dev/kagent/go/autogen/api"
3+
import (
4+
"fmt"
5+
"github.com/kagent-dev/kagent/go/autogen/api"
6+
)
47

58
type ValidationRequest struct {
69
Component *api.Component `json:"component"`
@@ -18,6 +21,24 @@ type ValidationResponse struct {
1821
Warnings []*ValidationError `json:"warnings"`
1922
}
2023

24+
func (r ValidationResponse) ErrorMsg() string {
25+
var msg string
26+
for _, e := range r.Errors {
27+
msg += fmt.Sprintf("Error: %s\n [%s]\n", e.Error, e.Field)
28+
if e.Suggestion != nil {
29+
msg += fmt.Sprintf("Suggestion: %s\n", *e.Suggestion)
30+
}
31+
}
32+
for _, w := range r.Warnings {
33+
msg += fmt.Sprintf("Warning: %s\n [%s]\n", w.Error, w.Field)
34+
if w.Suggestion != nil {
35+
msg += fmt.Sprintf("Suggestion: %s\n", *w.Suggestion)
36+
}
37+
}
38+
39+
return msg
40+
}
41+
2142
func (c *Client) Validate(req *ValidationRequest) (*ValidationResponse, error) {
2243
var resp ValidationResponse
2344
err := c.doRequest("POST", "/validate", req, &resp)

go/config/crd/bases/kagent.dev_agents.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ spec:
5151
description: 'note: this implementation is due to the kubebuilder
5252
limitation https://github.com/kubernetes-sigs/controller-tools/issues/636'
5353
x-kubernetes-preserve-unknown-fields: true
54+
description:
55+
description: Description is a brief description of the tool.
56+
type: string
5457
provider:
5558
type: string
5659
type: object
@@ -59,6 +62,29 @@ spec:
5962
type: object
6063
status:
6164
description: AgentStatus defines the observed state of Agent.
65+
properties:
66+
conditions:
67+
items:
68+
properties:
69+
lastTransitionTime:
70+
format: date-time
71+
type: string
72+
reason:
73+
type: string
74+
status:
75+
type: string
76+
type:
77+
type: string
78+
required:
79+
- lastTransitionTime
80+
- reason
81+
- status
82+
- type
83+
type: object
84+
type: array
85+
observedGeneration:
86+
format: int64
87+
type: integer
6288
type: object
6389
type: object
6490
served: true

go/config/crd/bases/kagent.dev_modelconfigs.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,32 @@ spec:
5252
type: object
5353
status:
5454
description: ModelConfigStatus defines the observed state of ModelConfig.
55+
properties:
56+
conditions:
57+
items:
58+
properties:
59+
lastTransitionTime:
60+
format: date-time
61+
type: string
62+
reason:
63+
type: string
64+
status:
65+
type: string
66+
type:
67+
type: string
68+
required:
69+
- lastTransitionTime
70+
- reason
71+
- status
72+
- type
73+
type: object
74+
type: array
75+
observedGeneration:
76+
format: int64
77+
type: integer
78+
required:
79+
- conditions
80+
- observedGeneration
5581
type: object
5682
type: object
5783
served: true

go/config/crd/bases/kagent.dev_teams.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,32 @@ spec:
132132
type: object
133133
status:
134134
description: TeamStatus defines the observed state of Team.
135+
properties:
136+
conditions:
137+
items:
138+
properties:
139+
lastTransitionTime:
140+
format: date-time
141+
type: string
142+
reason:
143+
type: string
144+
status:
145+
type: string
146+
type:
147+
type: string
148+
required:
149+
- lastTransitionTime
150+
- reason
151+
- status
152+
- type
153+
type: object
154+
type: array
155+
observedGeneration:
156+
format: int64
157+
type: integer
158+
required:
159+
- conditions
160+
- observedGeneration
135161
type: object
136162
type: object
137163
served: true

go/controller/api/v1alpha1/autogenagent_types.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ import (
2222
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2323
)
2424

25-
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
26-
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
25+
const (
26+
AgentConditionTypeAccepted = "Accepted"
27+
)
2728

2829
// AgentSpec defines the desired state of Agent.
2930
type AgentSpec struct {
@@ -36,6 +37,8 @@ type AgentSpec struct {
3637

3738
type Tool struct {
3839
Provider string `json:"provider,omitempty"`
40+
// Description is a brief description of the tool.
41+
Description string `json:"description,omitempty"`
3942
// note: this implementation is due to the kubebuilder limitation https://github.com/kubernetes-sigs/controller-tools/issues/636
4043
// +kubebuilder:pruning:PreserveUnknownFields
4144
// +kubebuilder:validation:Schemaless
@@ -47,7 +50,10 @@ type AnyType struct {
4750
}
4851

4952
// AgentStatus defines the observed state of Agent.
50-
type AgentStatus struct{}
53+
type AgentStatus struct {
54+
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
55+
Conditions []metav1.Condition `json:"conditions,omitempty"`
56+
}
5157

5258
// +kubebuilder:object:root=true
5359
// +kubebuilder:subresource:status

go/controller/api/v1alpha1/autogenmodelconfig_types.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ import (
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2121
)
2222

23+
const (
24+
ModelConfigConditionTypeAccepted = "Accepted"
25+
)
26+
2327
// ModelConfigSpec defines the desired state of ModelConfig.
2428
type ModelConfigSpec struct {
2529
Model string `json:"model"`
@@ -28,7 +32,10 @@ type ModelConfigSpec struct {
2832
}
2933

3034
// ModelConfigStatus defines the observed state of ModelConfig.
31-
type ModelConfigStatus struct{}
35+
type ModelConfigStatus struct {
36+
Conditions []metav1.Condition `json:"conditions"`
37+
ObservedGeneration int64 `json:"observedGeneration"`
38+
}
3239

3340
// +kubebuilder:object:root=true
3441
// +kubebuilder:subresource:status

go/controller/api/v1alpha1/autogenteam_types.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ import (
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2121
)
2222

23-
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
24-
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
23+
const (
24+
TeamConditionTypeAccepted = "Accepted"
25+
)
2526

2627
// TeamSpec defines the desired state of Team.
2728
type TeamSpec struct {
@@ -87,7 +88,10 @@ type OrTerminationCondition struct {
8788
}
8889

8990
// TeamStatus defines the observed state of Team.
90-
type TeamStatus struct{}
91+
type TeamStatus struct {
92+
Conditions []metav1.Condition `json:"conditions"`
93+
ObservedGeneration int64 `json:"observedGeneration"`
94+
}
9195

9296
// +kubebuilder:object:root=true
9397
// +kubebuilder:subresource:status

go/controller/api/v1alpha1/zz_generated.deepcopy.go

+72-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/controller/internal/autogen/autogen_api_translator.go

+6
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ func (a *apiTranslator) translateGroupChatForTeam(
134134
Model: modelConfig.Spec.Model,
135135
APIKey: makePtr(string(modelApiKey)),
136136
},
137+
BaseURL: makePtr("http://host.docker.internal:8089/api/account/profile"),
137138
}),
138139
}
139140
modelContext := &api.Component{
@@ -326,8 +327,13 @@ func translateAssistantAgent(
326327
providerParts := strings.Split(tool.Provider, ".")
327328
toolLabel := providerParts[len(providerParts)-1]
328329

330+
var description *string
331+
if tool.Description != "" {
332+
description = makePtr(tool.Description)
333+
}
329334
tool := &api.Component{
330335
Provider: tool.Provider,
336+
Description: description,
331337
ComponentType: "tool",
332338
Version: makePtr(1),
333339
Config: api.GenericToolConfig(toolConfig),

0 commit comments

Comments
 (0)