Migrate ordered NPC and location handoff tests to native execution
This commit is contained in:
@@ -95,3 +95,19 @@ func nativeSchemaHasProperty(request promptkit.GenerateRequest, property string)
|
||||
_, found := schema.Properties[property]
|
||||
return found
|
||||
}
|
||||
|
||||
func nativeJSONInput(request promptkit.GenerateRequest, field string) ([]byte, error) {
|
||||
for _, message := range request.Prompt.Messages {
|
||||
for offset := range len(message.Content) {
|
||||
if message.Content[offset] != '{' {
|
||||
continue
|
||||
}
|
||||
decoder := json.NewDecoder(strings.NewReader(message.Content[offset:]))
|
||||
var object map[string]json.RawMessage
|
||||
if decoder.Decode(&object) == nil && object[field] != nil {
|
||||
return []byte(message.Content[offset : offset+int(decoder.InputOffset())]), nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("native request has no JSON input with field %q", field)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user