Skip to main content

StackSpot Action AI Prompt Execution

This StackSpot Action allows you to create and execute a Quick Command using the StackSpot API. It supports creating a Quick Command execution, retrieving its details, and executing specific steps within the Quick Command.

Action:

stackspot-core/stackspot-ai-quick-command@0

Features

  • Create a Quick Command execution.
  • Retrieve details about the Quick Command execution.

Inputs

NameTypeDescriptionRequiredDefault Value
quick_command_slugStringThe slug of the Quick Command to be executed.YesN/A
conversation_idStringThe conversation ID to keep context across multiple executions.NoAutomatically generated ULID

Usage Example

Workflow Example

See example of how to use this Action in a StackSpot Workflow:

Outputs

NameTypeDescription
answerStringThe AI generated a response for the given prompt.

Context

The Action collects the following contextual information to enhance the AI's response:

  • Account Slug: Identifier of the user's account.
  • Account ID: ID of the user's account (v2).
  • Username: User's email address.
  • Operating System: Operating system of the user's environment.
  • Conversation ID: Unique identifier of the conversation.
  • Workspace: Workspace ID resolved by the CLI.
  • Platform: Platform in use (in this case, CLI).
  • Knowledge Source: List of Knowledge Sources provided as input.

Implementation

The action is implemented in Python and involves the following steps:

  1. Input Handling: It reads the prompt, knowledge_sources, and optionally the conversation_id from the input metadata.
  2. Context Creation: It builds a context dictionary using the context function, including details such as account information, OS, Workspace, and other relevant data.
  3. AI Interaction: It calls the prompt_code_buddy function from the oscli.apis.ai.codebuddy.service module, passing the prompt and the context.
  4. Output: It prints the AI's response and sets it as answer in the output metadata, making it available for other Workflow steps.

Usage Example

schema-version: v1
kind: workflow
metadata:
name: example
display-name: example
description: example
version: 0.0.1
spec:
type: reusable
label: example
inputs:
- name: prompt
label: prompt
type: text

jobs:

- id: job_1
label: Interact with AI
steps:
- id: step_1
label: Interact with AI
name: "stackspot-core/stackspot-ai@1"
type: action
inputs:
prompt: "{{ inputs.prompt }}"
conversation_id: "{{ var.STK_WORKFLOW_EXECUTION_ID }}"
agent_id: 01JSMM61QVZTSS7C03DDC5T7ME