@@ -406,6 +406,9 @@ func (c *evaluationComponentImpl) OrgEvaluations(ctx context.Context, req *types
406406
407407func (c * evaluationComponentImpl ) createClawEvaluation (ctx context.Context , req types.EvaluationReq , user database.User , frame * database.RuntimeFramework ) (* types.ArgoWorkFlowRes , error ) {
408408 operatorUsername := req .Username
409+ if req .Model == "" {
410+ req .Model = req .ModelId
411+ }
409412 if req .TaskName == "" {
410413 return nil , fmt .Errorf ("task_name is required" )
411414 }
@@ -477,8 +480,27 @@ func (c *evaluationComponentImpl) createClawEvaluation(ctx context.Context, req
477480 req .TaskType = types .TaskTypeClawEval
478481
479482 clawReq := req .ToClawEvaluationReq ()
483+ var defaultAPIKey string
484+ resolveDefaultAPIKey := func () (string , error ) {
485+ if defaultAPIKey != "" {
486+ return defaultAPIKey , nil
487+ }
488+ apiKey , err := c .resolveClawEvalAIGatewayAPIKey (ctx , billingUUID , req .OwnerNamespace , operatorUsername )
489+ if err != nil {
490+ return "" , err
491+ }
492+ defaultAPIKey = apiKey
493+ return defaultAPIKey , nil
494+ }
495+ if clawReq .ApiKey == "" {
496+ apiKey , err := resolveDefaultAPIKey ()
497+ if err != nil {
498+ return nil , err
499+ }
500+ clawReq .ApiKey = apiKey
501+ }
480502 if ! req .NoJudge {
481- judgeAPIKey , err := c . resolveClawEvalJudgeAPIKey ( ctx , billingUUID , req . OwnerNamespace , operatorUsername )
503+ judgeAPIKey , err := resolveDefaultAPIKey ( )
482504 if err != nil {
483505 return nil , err
484506 }
@@ -488,7 +510,7 @@ func (c *evaluationComponentImpl) createClawEvaluation(ctx context.Context, req
488510 return c .deployer .SubmitClawEvaluation (ctx , clawReq )
489511}
490512
491- func (c * evaluationComponentImpl ) resolveClawEvalJudgeAPIKey (ctx context.Context , billingUUID , ownerNamespace , operatorUsername string ) (string , error ) {
513+ func (c * evaluationComponentImpl ) resolveClawEvalAIGatewayAPIKey (ctx context.Context , billingUUID , ownerNamespace , operatorUsername string ) (string , error ) {
492514 token , err := c .tokenStore .FindBuiltinByNsUUID (ctx , billingUUID , string (types .AccessTokenAppAIGateway ))
493515 if err == nil && token != nil && token .Token != "" {
494516 return token .Token , nil
@@ -505,10 +527,10 @@ func (c *evaluationComponentImpl) resolveClawEvalJudgeAPIKey(ctx context.Context
505527 "claw-eval" ,
506528 )
507529 if err != nil {
508- return "" , fmt .Errorf ("failed to resolve judge api key, %w" , err )
530+ return "" , fmt .Errorf ("failed to resolve claw-eval api key, %w" , err )
509531 }
510532 if apiKey == "" {
511- return "" , fmt .Errorf ("failed to resolve judge api key" )
533+ return "" , fmt .Errorf ("failed to resolve claw-eval api key" )
512534 }
513535 return apiKey , nil
514536}
0 commit comments