Skip to content

Commit

Permalink
feat: make config optional. use the playbook's resource config.
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Dec 25, 2024
1 parent 76fe6fa commit 0d9435f
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion config/schemas/playbook-spec.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"additionalProperties": false,
"type": "object",
"required": [
"config",
"prompt"
]
},
Expand Down
1 change: 0 additions & 1 deletion config/schemas/playbook.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"additionalProperties": false,
"type": "object",
"required": [
"config",
"prompt"
]
},
Expand Down
1 change: 0 additions & 1 deletion fixtures/playbooks/ai-diagnose-aws-openai.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ spec:
name: openai
key: API_KEY
prompt: '{{.params.prompt}}'
config: '{{.config.id}}'
changes:
since: 2h
analysis:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ spec:
model: llama3.1:8b
apiURL: http://localhost:11434
prompt: "{{.params.prompt}}"
config: "{{.config.id}}"
changes:
since: 2h
analysis:
Expand Down
4 changes: 2 additions & 2 deletions playbook/actions/ai.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
type AIAction struct{}

type AIActionResult struct {
Stdout string `json:"stdout"` // TODO: only naming this stdout because the frontend has proper formatted display for this field
Logs string `json:"logs,omitempty"` // TODO: only naming this "logs" because the frontend has proper formatted display for this field
}

func (t *AIAction) Run(ctx context.Context, spec v1.AIAction) (*AIActionResult, error) {
Expand All @@ -40,7 +40,7 @@ func (t *AIAction) Run(ctx context.Context, spec v1.AIAction) (*AIActionResult,
return nil, err
}

return &AIActionResult{Stdout: response}, nil
return &AIActionResult{Logs: response}, nil
}

func buildPrompt(ctx context.Context, prompt string, spec v1.AIActionContext) (string, error) {
Expand Down
1 change: 0 additions & 1 deletion playbook/runner/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ type executeActionResult struct {
// executeAction runs the executes the given palybook action.
// It should received an already templated action spec.
func executeAction(ctx context.Context, playbookID any, runID uuid.UUID, runAction models.PlaybookRunAction, actionSpec v1.PlaybookAction) (executeActionResult, error) {

if timeout, _ := actionSpec.TimeoutDuration(); timeout > 0 {
var cancel gocontext.CancelFunc
ctx, cancel = ctx.WithTimeout(timeout)
Expand Down
4 changes: 4 additions & 0 deletions playbook/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ func TemplateAndExecuteAction(ctx context.Context, spec v1.PlaybookSpec, playboo
return err
}

if step.AI != nil && step.AI.Config == "" {
step.AI.Config = run.ConfigID.String()
}

return oops.Wrap(ExecuteAndSaveAction(ctx, run.PlaybookID, action, step))
}

Expand Down

0 comments on commit 0d9435f

Please sign in to comment.