Skip to content

Commit cf58a54

Browse files
Stefan ErnstStefan Ernst
authored andcommitted
Fixes for llm returns
1 parent ae0ecc1 commit cf58a54

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

internal/llm/gbnf.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (g *gbnfGenerator) uniqueName(base string) string {
5656
}
5757

5858
func (g *gbnfGenerator) String() string {
59-
var lines []string
59+
lines := make([]string, 0, len(g.ruleOrder))
6060

6161
// Add common rules first
6262
g.addCommonRules()
@@ -143,7 +143,7 @@ func (g *gbnfGenerator) generateObject(name string, s *jsonSchema) string {
143143
}
144144

145145
// Determine which properties to include
146-
var props []string
146+
props := make([]string, 0, len(s.Properties))
147147
requiredSet := make(map[string]bool)
148148
for _, r := range s.Required {
149149
requiredSet[r] = true
@@ -158,11 +158,9 @@ func (g *gbnfGenerator) generateObject(name string, s *jsonSchema) string {
158158

159159
// If additionalProperties is false, only include defined properties
160160
// For GBNF we always only include defined properties
161-
for _, propName := range propNames {
162-
// For simplicity, include all defined properties
163-
// (In a full implementation, we'd handle optional vs required differently)
164-
props = append(props, propName)
165-
}
161+
// For simplicity, include all defined properties
162+
// (In a full implementation, we'd handle optional vs required differently)
163+
props = append(props, propNames...)
166164

167165
if len(props) == 0 {
168166
return `"{" ws "}"`

internal/llm/openai.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (c *openaiClient) ChatCompletion(ctx context.Context, req ChatCompletionReq
5858
"type": "json_schema",
5959
"json_schema": map[string]interface{}{
6060
"name": req.StructuredOutput.SchemaName,
61-
"schema": json.RawMessage(req.StructuredOutput.Schema),
61+
"schema": req.StructuredOutput.Schema,
6262
"strict": req.StructuredOutput.Strict,
6363
},
6464
}

0 commit comments

Comments
 (0)