Often, there are repetitive tasks that require same kind of prompting or flows. Agent can optionally have commands that auto executes the task by accepting certain inputs.

Adding a Command

Let's continue working with the Gemini agent from quickstart. We can add a command /prompt that is expert at generating prompts for the users.

Create a new file lib/commands/prompt.dart and define the PromptCommand:

 import 'package:dash_agent/configuration/command.dart';
 import 'package:dash_agent/steps/steps.dart';
 import 'package:dash_agent/variables/dash_input.dart';
 import 'package:dash_agent/variables/dash_output.dart';
 import 'package:gemini/data_sources.dart';
 /// [PromptCommand] generates a prompt based on user input.
 class PromptCommand extends Command {
     /// [Data source that contains blogs/guidelines specific to prompting techniques]
     final PromptDataSource promptDataSource;
     final promptGuidelines = StringInput('Prompt Guidelines');
     String get slug => '/prompt';
     String get intent => 'Generate perfect prompt';
     String get textFieldLayout =>
         "Enter your desired prompt guidelines: $promptGuidelines";
     List<DashInput> get registerInputs => [promptGuidelines];
     List<Step> get steps {
         final matchingDocs = MatchDocumentOuput();
         final promptOutput = PromptOutput();
         return [
         // [Find the right guidelines for the users's requirement]
                 'Documenation helpful to generate prompt for guidelines $promptGuidelines',
             dataSources: [promptDataSource],
             output: matchingDocs),
         // [LLM request using user inputs + matched prompt guidelines]
             prompt: '''
                 You are a prompting expert helping use generate new prompts for their LLM requests.
                 Here is the guidelines for which the user wants to generate or edit the prompt: $promptGuidelines 
                 Here is documentation on prompting strategies with some examples from an official guide on writing good quality prompts:
                 Generate, review or refine the prompt for user based on their guidelines, currrent prompt and the references and documentation provided.''',
             promptOutput: promptOutput,
         // [Append the result to the chat]
         AppendToChatStep(value: '$promptOutput')


class PromptDataSource extends DataSource {
 List<FileDataObject> get fileObjects => [];
 List<ProjectDataObject> get projectObjects => [];
 List<WebDataObject> get webObjects => [
  • slug, intent and textFieldLayout helps to choose and understand the usage of a command.
Rendered textFieldLayout in the Dash Panel

User can provide inputs on the kind of prompts they want to create and a perfect one will be crafted for them.