Skip to content

Commit dae71e8

Browse files
authored
remove unnecessary yaml layer from prompts types (#580)
Signed-off-by: Nader Ziada <[email protected]>
1 parent 5623684 commit dae71e8

File tree

3 files changed

+15
-70
lines changed

3 files changed

+15
-70
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ require (
1616
github.com/stretchr/testify v1.11.1
1717
golang.org/x/oauth2 v0.34.0
1818
golang.org/x/sync v0.19.0
19-
gopkg.in/yaml.v3 v3.0.1
2019
helm.sh/helm/v3 v3.19.3
2120
k8s.io/api v0.34.3
2221
k8s.io/apiextensions-apiserver v0.34.3
@@ -134,6 +133,7 @@ require (
134133
google.golang.org/protobuf v1.36.6 // indirect
135134
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
136135
gopkg.in/inf.v0 v0.9.1 // indirect
136+
gopkg.in/yaml.v3 v3.0.1 // indirect
137137
k8s.io/apiserver v0.34.3 // indirect
138138
k8s.io/component-base v0.34.3 // indirect
139139
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect

pkg/api/prompt_serialization_test.go

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66

77
"github.com/BurntSushi/toml"
88
"github.com/stretchr/testify/suite"
9-
"gopkg.in/yaml.v3"
109
)
1110

1211
// PromptSerializationSuite tests serialization of prompt data structures
@@ -45,33 +44,6 @@ func (s *PromptSerializationSuite) TestPromptJSONSerialization() {
4544
})
4645
}
4746

48-
func (s *PromptSerializationSuite) TestPromptYAMLSerialization() {
49-
s.Run("marshals and unmarshals Prompt correctly", func() {
50-
original := Prompt{
51-
Name: "test-prompt",
52-
Title: "Test Prompt",
53-
Description: "A test prompt",
54-
Arguments: []PromptArgument{
55-
{Name: "arg1", Description: "First argument", Required: true},
56-
},
57-
Templates: []PromptTemplate{
58-
{Role: "user", Content: "Hello {{arg1}}"},
59-
},
60-
}
61-
62-
data, err := yaml.Marshal(original)
63-
s.Require().NoError(err, "failed to marshal Prompt to YAML")
64-
65-
var unmarshaled Prompt
66-
err = yaml.Unmarshal(data, &unmarshaled)
67-
s.Require().NoError(err, "failed to unmarshal Prompt from YAML")
68-
69-
s.Equal(original.Name, unmarshaled.Name)
70-
s.Equal(original.Title, unmarshaled.Title)
71-
s.Equal(original.Description, unmarshaled.Description)
72-
})
73-
}
74-
7547
func (s *PromptSerializationSuite) TestPromptTOMLSerialization() {
7648
s.Run("unmarshals Prompt from TOML correctly", func() {
7749
tomlData := `
@@ -152,15 +124,6 @@ func (s *PromptSerializationSuite) TestPromptArgumentSerialization() {
152124
s.Require().NoError(err)
153125
s.Equal(arg.Name, jsonArg.Name)
154126
s.True(jsonArg.Required)
155-
156-
// YAML
157-
yamlData, err := yaml.Marshal(arg)
158-
s.Require().NoError(err)
159-
var yamlArg PromptArgument
160-
err = yaml.Unmarshal(yamlData, &yamlArg)
161-
s.Require().NoError(err)
162-
s.Equal(arg.Name, yamlArg.Name)
163-
s.True(yamlArg.Required)
164127
})
165128

166129
s.Run("serializes optional argument", func() {
@@ -227,15 +190,6 @@ func (s *PromptSerializationSuite) TestPromptMessageSerialization() {
227190
s.Equal(msg.Role, jsonMsg.Role)
228191
s.Equal(msg.Content.Type, jsonMsg.Content.Type)
229192
s.Equal(msg.Content.Text, jsonMsg.Content.Text)
230-
231-
// YAML
232-
yamlData, err := yaml.Marshal(msg)
233-
s.Require().NoError(err)
234-
var yamlMsg PromptMessage
235-
err = yaml.Unmarshal(yamlData, &yamlMsg)
236-
s.Require().NoError(err)
237-
s.Equal(msg.Role, yamlMsg.Role)
238-
s.Equal(msg.Content.Text, yamlMsg.Content.Text)
239193
})
240194
}
241195

@@ -254,15 +208,6 @@ func (s *PromptSerializationSuite) TestPromptContentSerialization() {
254208
s.Require().NoError(err)
255209
s.Equal(content.Type, jsonContent.Type)
256210
s.Equal(content.Text, jsonContent.Text)
257-
258-
// YAML
259-
yamlData, err := yaml.Marshal(content)
260-
s.Require().NoError(err)
261-
var yamlContent PromptContent
262-
err = yaml.Unmarshal(yamlData, &yamlContent)
263-
s.Require().NoError(err)
264-
s.Equal(content.Type, yamlContent.Type)
265-
s.Equal(content.Text, yamlContent.Text)
266211
})
267212
}
268213

pkg/api/prompts.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,40 +28,40 @@ func (s *ServerPrompt) IsClusterAware() bool {
2828
// Prompt represents the metadata and content of an MCP prompt.
2929
// See MCP specification: https://spec.modelcontextprotocol.io/specification/server/prompts/
3030
type Prompt struct {
31-
Name string `yaml:"name" json:"name" toml:"name"`
32-
Title string `yaml:"title,omitempty" json:"title,omitempty" toml:"title,omitempty"`
33-
Description string `yaml:"description,omitempty" json:"description,omitempty" toml:"description,omitempty"`
34-
Arguments []PromptArgument `yaml:"arguments,omitempty" json:"arguments,omitempty" toml:"arguments,omitempty"`
35-
Templates []PromptTemplate `yaml:"messages,omitempty" json:"messages,omitempty" toml:"messages,omitempty"`
31+
Name string `json:"name" toml:"name"`
32+
Title string `json:"title,omitempty" toml:"title,omitempty"`
33+
Description string `json:"description,omitempty" toml:"description,omitempty"`
34+
Arguments []PromptArgument `json:"arguments,omitempty" toml:"arguments,omitempty"`
35+
Templates []PromptTemplate `json:"messages,omitempty" toml:"messages,omitempty"`
3636
}
3737

3838
// PromptArgument defines a parameter that can be passed to a prompt.
3939
// See MCP specification: https://spec.modelcontextprotocol.io/specification/server/prompts/
4040
type PromptArgument struct {
41-
Name string `yaml:"name" json:"name" toml:"name"`
42-
Description string `yaml:"description,omitempty" json:"description,omitempty" toml:"description,omitempty"`
43-
Required bool `yaml:"required" json:"required" toml:"required"`
41+
Name string `json:"name" toml:"name"`
42+
Description string `json:"description,omitempty" toml:"description,omitempty"`
43+
Required bool `json:"required" toml:"required"`
4444
}
4545

4646
// PromptTemplate represents a message template from configuration with placeholders like {{arg}}.
4747
// This is used for configuration parsing and gets rendered into PromptMessage at runtime.
4848
type PromptTemplate struct {
49-
Role string `yaml:"role" json:"role" toml:"role"`
50-
Content string `yaml:"content" json:"content" toml:"content"`
49+
Role string `json:"role" toml:"role"`
50+
Content string `json:"content" toml:"content"`
5151
}
5252

5353
// PromptMessage represents a single message in a prompt response.
5454
// See MCP specification: https://spec.modelcontextprotocol.io/specification/server/prompts/
5555
type PromptMessage struct {
56-
Role string `yaml:"role" json:"role" toml:"role"`
57-
Content PromptContent `yaml:"content" json:"content" toml:"content"`
56+
Role string `json:"role" toml:"role"`
57+
Content PromptContent `json:"content" toml:"content"`
5858
}
5959

6060
// PromptContent represents the content of a prompt message.
6161
// See MCP specification: https://spec.modelcontextprotocol.io/specification/server/prompts/
6262
type PromptContent struct {
63-
Type string `yaml:"type" json:"type" toml:"type"`
64-
Text string `yaml:"text,omitempty" json:"text,omitempty" toml:"text,omitempty"`
63+
Type string `json:"type" toml:"type"`
64+
Text string `json:"text,omitempty" toml:"text,omitempty"`
6565
}
6666

6767
// PromptCallRequest interface for accessing prompt call arguments

0 commit comments

Comments
 (0)