Command class abstract
Base class for creating a command for your agent. For an agent, the command can be understood as an task (such as refactoring, code generation, code analysis, etc) the user can invoke via commanddash.
Command requires following arguments:
slug
- Unique identifier of the commandintent
- Brief description about the commandtextFieldLayout
- Phrase that will be shown to user when the command is invokedregisterInputs
-DashInput
s that will be used in the command in its lifecyclesteps
- Series of operation that needs to be performed for a command finish its task. Steps can be of the following nature: Matching docs that are shared with the command, performing a query in the user project, prompt that code/ info generation, appending the info/code at the right place in the project, many more.
Sample example of Command for demonstration purpose:
class AskCommand extends Command {
AskCommand({required this.docsSource});
final DataSource docsSource;
// Inputs
final userQuery = StringInput('Your query');
final codeAttachment = CodeInput('Code Attachment');
// Outputs
final matchingDocuments = MatchDocumentObject();
final matchingCode = MultiCodeObject();
final queryOutput = QueryOutput();
@override
String get slug => '/ask';
@override
String get intent => 'Ask me anything';
@override
List<DashInput> get registerInputs => [userQuery, codeAttachment];
@override
List<Step> get steps => [
MatchingDocumentStep(
query: '$userQuery$codeAttachment',
dataSources: [docsSource],
output: matchingDocuments),
WorkspaceQueryStep(query: '$matchingDocuments', output: matchingCode),
PromptQueryStep(
prompt:
'''You are an X agent. Here is the $userQuery, here is the $matchingCode and the document references: $matchingDocuments. Answer the user's query.''',
postProcessKind: PostProcessKind.raw,
output: queryOutput),
AppendToChatStep(
value:
'This was your query: $userQuery and here is your output: $queryOutput'),
];
@override
String get textFieldLayout =>
"Hi, I'm here to help you. $userQuery $codeAttachment";
}
Constructors
- Command()
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- intent → String
-
Intent is a brief description about the command which will be used for the
purpose giving the end dev the idea about the capability and use case of
the following command.
no setter
- minCliVersion → String
-
no setter
-
registerInputs
→ List<
DashInput> -
List of
DashInput
s that will be used in the command in its lifecycle. Learn more aboutDashInput
and available type by opening it definition.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- slug → String
-
Unique identifier of the command. For an agent having multiple commands
the slug for each command should be unique.
no setter
-
steps
→ List<
Step> -
Series of operation that needs to be performed for a command finish its
task.
no setter
- textFieldLayout → String
-
Phrase to shown when the command is invoked by the end dev. Few provide the
devs a good experiece and ease in command use. You can follow few of the good
practises:
no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
process(
) → Future< Map< String, dynamic> > -
Internal method used by dash_agent to convert the shared
Commmand
to json formated cofiguration that is deployable. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited