Skip to content

Commit

Permalink
ADD new type assert for AI agent variable.
Browse files Browse the repository at this point in the history
ADD new type assert for AI agent variable.
  • Loading branch information
karminski committed Jan 24, 2024
1 parent 4079c8d commit e79b138
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions src/utils/illaresourcemanagersdk/run_ai_agent_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func NewRunAIAgentRequest(rawRequest map[string]interface{}) (*RunAIAgentRequest
runAIAgentRequest := &RunAIAgentRequest{}
assertPass := true
var variablesRaw []interface{}
var variablesRawWarrped []map[string]interface{}
var modelConfigRaw map[string]interface{}
var errInNewModelConfig error
for key, value := range rawRequest {
Expand Down Expand Up @@ -101,16 +102,29 @@ func NewRunAIAgentRequest(rawRequest map[string]interface{}) (*RunAIAgentRequest
runAIAgentRequest.Model, assertPass = assertNumberIDToInt(value)
case RUN_AI_AGENT_REQUEST_FIELD_VARIABLES:
variablesRaw, assertPass = value.([]interface{})
for _, variableRaw := range variablesRaw {
variableAsserted, assertPass := variableRaw.(map[string]interface{})
if assertPass {
for _, variableRaw := range variablesRaw {
variableAsserted, assertPass := variableRaw.(map[string]interface{})
if assertPass {
variable, errInNewVariable := NewAIAgentPromptVariableByMap(variableAsserted)
if errInNewVariable != nil {
return nil, errInNewVariable
}
runAIAgentRequest.Variables = append(runAIAgentRequest.Variables, variable)
} else {
break
}
}
} else {
variablesRawWarrped, assertPass = value.([]map[string]interface{})
if assertPass {
variable, errInNewVariable := NewAIAgentPromptVariableByMap(variableAsserted)
if errInNewVariable != nil {
return nil, errInNewVariable
for _, variableRaw := range variablesRawWarrped {
variable, errInNewVariable := NewAIAgentPromptVariableByMap(variableRaw)
if errInNewVariable != nil {
return nil, errInNewVariable
}
runAIAgentRequest.Variables = append(runAIAgentRequest.Variables, variable)
}
runAIAgentRequest.Variables = append(runAIAgentRequest.Variables, variable)
} else {
break
}
}
case RUN_AI_AGENT_REQUEST_FIELD_MODEL_CONFIG:
Expand All @@ -127,7 +141,7 @@ func NewRunAIAgentRequest(rawRequest map[string]interface{}) (*RunAIAgentRequest

}
if !assertPass {
return nil, errors.New(fmt.Sprintf("assert request field %s with value \"%s\"for RunAIAgentRequest", key, value))
return nil, errors.New(fmt.Sprintf("assert request field '%s' with value '%s' for RunAIAgentRequest", key, value))
}
}
return runAIAgentRequest, nil
Expand Down

0 comments on commit e79b138

Please sign in to comment.