Skip to content

Commit

Permalink
FIX resource manager run param asseret method.
Browse files Browse the repository at this point in the history
FIX resource manager run param asseret method.
  • Loading branch information
karminski committed Jan 23, 2024
1 parent e66657c commit f3f7c07
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/controller/flow_action_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (controller *Controller) RunFlowActionInternal(c *gin.Context) {
fmt.Printf("[DUMP] flowAction.ExportRawTemplateInMap(): %+v\n", flowAction.ExportRawTemplateInMap())
_, errInValidateActionTemplate := flowActionAssemblyLine.ValidateActionTemplate(flowAction.ExportTemplateInMap())
if errInValidateActionTemplate != nil {
controller.FeedbackBadRequest(c, ERROR_FLAG_VALIDATE_REQUEST_BODY_FAILED, "validate flowAction template error: "+errInValidate.Error())
controller.FeedbackBadRequest(c, ERROR_FLAG_VALIDATE_REQUEST_BODY_FAILED, "validate flowAction template error: "+errInValidateActionTemplate.Error())
return
}

Expand Down
2 changes: 1 addition & 1 deletion src/model/flow_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func (action *FlowAction) ExportTransformerInMap() map[string]interface{} {
}

func (action *FlowAction) ExportTemplateInMap() map[string]interface{} {
var payload map[string]interface{}
payload := make(map[string]interface{}, 0)
json.Unmarshal([]byte(action.Template), &payload)
// add resourceID, runByAnonymous, teamID field for extend action runtime info
payload["resourceID"] = action.ResourceID
Expand Down
24 changes: 15 additions & 9 deletions src/utils/illaresourcemanagersdk/run_ai_agent_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,18 @@ func assertMagicStringIDToInt(magicStringID interface{}) (int, bool) {
return idconvertor.ConvertStringToInt(magicStringIDAsserted), true
}

func assertFloatIDToInt(floatID interface{}) (int, bool) {
func assertNumberIDToInt(floatID interface{}) (int, bool) {
floatIDAsserted, assertPass := floatID.(float64)
if !assertPass {
return 0, assertPass
if assertPass {
return int(floatIDAsserted), true

}
floatIDIntAsserted, assertPassInInt := floatID.(int)
if assertPassInInt {
return floatIDIntAsserted, true

}
return int(floatIDAsserted), true
return 0, false
}

func NewRunAIAgentRequest(rawRequest map[string]interface{}) (*RunAIAgentRequest, error) {
Expand All @@ -71,28 +77,28 @@ func NewRunAIAgentRequest(rawRequest map[string]interface{}) (*RunAIAgentRequest
// accept string & float64 type id
runAIAgentRequest.TeamID, assertPass = assertMagicStringIDToInt(value)
if !assertPass {
runAIAgentRequest.TeamID, assertPass = assertFloatIDToInt(value)
runAIAgentRequest.TeamID, assertPass = assertNumberIDToInt(value)
}
case RUN_AI_AGENT_REQUEST_FIELD_RESOURCE_ID:
// accept string & float64 type id
runAIAgentRequest.AIAgentID, assertPass = assertMagicStringIDToInt(value)
if !assertPass {
runAIAgentRequest.AIAgentID, assertPass = assertFloatIDToInt(value)
runAIAgentRequest.AIAgentID, assertPass = assertNumberIDToInt(value)
}
case RUN_AI_AGENT_REQUEST_FIELD_AI_AGENT_ID:
// accept string & float64 type id
runAIAgentRequest.AIAgentID, assertPass = assertMagicStringIDToInt(value)
if !assertPass {
runAIAgentRequest.AIAgentID, assertPass = assertFloatIDToInt(value)
runAIAgentRequest.AIAgentID, assertPass = assertNumberIDToInt(value)
}
case RUN_AI_AGENT_REQUEST_FIELD_AUTHORIZATION:
runAIAgentRequest.Authorization, assertPass = value.(string)
case RUN_AI_AGENT_REQUEST_FIELD_RUN_BY_ANONYMOUS:
runAIAgentRequest.RunByAnonymous, assertPass = value.(bool)
case RUN_AI_AGENT_REQUEST_FIELD_AGENT_TYPE:
runAIAgentRequest.AgentType, assertPass = assertFloatIDToInt(value)
runAIAgentRequest.AgentType, assertPass = assertNumberIDToInt(value)
case RUN_AI_AGENT_REQUEST_FIELD_MODEL:
runAIAgentRequest.Model, assertPass = assertFloatIDToInt(value)
runAIAgentRequest.Model, assertPass = assertNumberIDToInt(value)
case RUN_AI_AGENT_REQUEST_FIELD_VARIABLES:
variablesRaw, assertPass = value.([]interface{})
for _, variableRaw := range variablesRaw {
Expand Down

0 comments on commit f3f7c07

Please sign in to comment.