Skip to content
The Chat Archive
o1-preview-2024-09-12· OpenAIAi2 WildChat-4.8M (AI2)

Below, you'll find a set of examples displaying how to use a certain Domain Specific…

  1. User

    Below, you'll find a set of examples displaying how to use a certain Domain Specific Language. Your job is to work backwards from the examples, infer what the purpose of the DSL may be, define any additional functionality (with examples), and define a comprehensive PRD covering the DSL in question. It's a novel language so do not try to define it as any existing language.

    Subsequently, define in pseudocode the language syntax / grammar.

    Example 1: `>write path/to/my/file.ext <<EOF This is content from the file: path/to/my/file.ext

    EOF`

    EXAMPLE 2: `# Read from a file descriptor until EOF

    read '/my/hand le/path' - MyVariableName

    Write the value to a new prompt

    prepare prompt as MyExamplePrompt << $MyVariableName

    Associate the prompt with an agent (create a job)

    assign MyExampleAgentMyExampleAgent MyExamplePrompt as MyExampleJob

    Execute the job

    execute $MyExampleJob`

  2. Assistant

    Product Requirements Document (PRD)


    Product Name: Agent Interaction Scripting Language (AISL)

    Introduction

    The Agent Interaction Scripting Language (AISL) is a domain-specific language designed to facilitate automation and interaction with software agents (such as AI models, services, or scripts). It provides a straightforward syntax for performing file operations, managing variables and prompts, assigning tasks to agents, and executing jobs. AISL enables users to script complex workflows involving the manipulation of files and data, preparation of dynamic prompts, and orchestration of agent activities in an efficient and readable manner.


    Purpose and Scope

    AISL is intended for users who need to automate tasks that involve:

    • Reading from and writing to files.
    • Managing variables and incorporating them into content.
    • Preparing prompts or messages for agents.
    • Assigning agents to perform jobs based on prepared prompts.
    • Executing and managing jobs.
    • Incorporating control flow mechanisms (conditions, loops, functions) into their scripts.

    Features

    1. File Operations

      • Write to a File

        • Syntax: > write [filepath] <<EOF ... EOF
        • Description: Writes the specified content into the file at the given path. If the file does not exist, it will be created.
        • Example:
          > write 'output.txt' <<EOF
          This is the output file content.
          EOF
          
      • Read from a File

        • Syntax: > read [filepath] - [VariableName]
        • Description: Reads the content of the specified file into a variable.
        • Example:
          > read 'data/input.txt' - InputData
          
      • Append to a File

        • Syntax: > append [filepath] <<EOF ... EOF
        • Description: Appends the specified content to the end of the file.
        • Example:
          > append 'log.txt' <<EOF
          New log entry at $Timestamp
          EOF
          
      • Delete a File

        • Syntax: > delete [filepath]
        • Description: Deletes the specified file.
        • Example:
          > delete 'temp/output.tmp'
          
      • Directory Operations

        • Create a Directory
          • Syntax: > mkdir [directorypath]
          • Example:
            > mkdir 'results/data'
            
        • List Directory Contents
          • Syntax: > ls [directorypath] - [VariableName]
          • Description: Lists the contents of the directory and stores them in a variable.
          • Example:
            > ls 'data/' - DataFiles
            
    2. Variable Management

      • Assigning Values

        • Syntax: > set [VariableName] = [Value]
        • Description: Assigns a value to a variable. Values can be strings, numbers, or the result of expressions.
        • Example:
          > set UserName = 'Alice'
          > set Counter = 0
          
      • Referencing Variables

        • Syntax: Use $VariableName to reference a variable's value.
        • Example:
          > write 'greeting.txt' <<EOF
          Hello, $UserName!
          EOF
          
      • Arithmetic Operations

        • Syntax supports basic arithmetic operations.
        • Example:
          > set Counter = $Counter + 1
          
    3. Prompt Management

      • Prepare a Prompt
        • Syntax: > prepare prompt as [PromptName] <<EOF ... EOF
        • Description: Creates a prompt with the specified content and assigns it a name for later use.
        • Example:
          > prepare prompt as WelcomePrompt <<EOF
          Welcome, $UserName! How can I assist you today?
          EOF
          
    4. Agent Management

      • Assign an Agent and Prompt to Create a Job
        • Syntax: > assign $AgentName $PromptName as [JobName]
        • Description: Combines an agent and a prompt into a job, assigning a unique job name.
        • Example:
          > assign $CustomerServiceAgent $WelcomePrompt as WelcomeJob
          
    5. Job Execution

      • Execute a Job
        • Syntax: > execute $JobName
        • Description: Executes the specified job.
        • Example:
          > execute $WelcomeJob
          
    6. Control Flow

      • Conditional Statements

        • Syntax:
          > if [Condition]
          > then
              [Commands]
          > else
              [Commands]
          > endif
          
        • Description: Executes commands based on a condition.
        • Example:
          > if $UserName == 'Admin'
          > then
              > set AccessLevel = 'Full'
          > else
              > set AccessLevel = 'Limited'
          > endif
          
      • Loops

        • For Loop

          • Syntax:
            > for $Item in $ItemList
            > do
                [Commands]
            > done
            
          • Description: Iterates over items in a list variable.
          • Example:
            > for $File in $DataFiles
            > do
                > read 'data/$File' - FileContent
                > process $FileContent
            > done
            
        • While Loop

          • Syntax:
            > while [Condition]
            > do
                [Commands]
            > done
            
          • Description: Repeats commands while a condition is true.
          • Example:
            > while $Counter < 10
            > do
                > set Counter = $Counter + 1
            > done
            
    7. Functions

      • Define a Function

        • Syntax:
          > function [FunctionName] [Parameters]
          > do
              [Commands]
          > endfunction
          
        • Description: Defines a reusable set of commands.
        • Example:
          > function greetUser $Name
          > do
              > write 'greeting.txt' <<EOF
              Hello, $Name!
              EOF
          > endfunction
          
      • Call a Function

        • Syntax: > [FunctionName] [Arguments]
        • Example:
          > greetUser 'Bob'
          
    8. Comments

      • Single-Line Comments
        • Syntax: # Comment text
        • Description: Any text following # is considered a comment and ignored during execution.
        • Example:
          # This is a comment explaining the following command
          > set Counter = $Counter + 1
          

    Additional Functionality Examples

    1. Appending to a File

      > append 'notes.txt' <<EOF
      Remember to check the logs.
      EOF
      
    2. Deleting a File

      > delete 'old_report.txt'
      
    3. Conditional Execution

      > if $UserInput == 'yes'
      > then
          > execute $ConfirmationJob
      > endif
      
    4. Looping Over a List

      > read 'users.txt' - UserList
      
      > for $User in $UserList
      > do
          > prepare prompt as UserPrompt <<EOF
          Dear $User, your account has been updated.
          EOF
          > assign $NotificationAgent $UserPrompt as NotificationJob
          > execute $NotificationJob
      > done
      
    5. Using Functions

      > function logMessage $Message
      > do
          > append 'logfile.txt' <<EOF
          [$Timestamp] $Message
          EOF
      > endfunction
      
      > set Timestamp = '2023-10-01 12:00:00'
      > logMessage 'Job started'
      
    6. Error Handling (Try-Catch Block)

      • Note: Error handling mechanisms can be designed as per the language capabilities.
      > try
          > read 'critical_data.txt' - CriticalData
      > catch FileNotFoundError
          > write 'error.log' <<EOF
          Critical data file not found.
          EOF
      > endtry
      

    Language Syntax / Grammar (Pseudocode)

    Below is the pseudocode representation of the AISL syntax and grammar.

    Tokens

    • COMMAND_PREFIX = >
    • COMMENT_SYMBOL = #
    • VARIABLE_PREFIX = $
    • STRING_LITERAL = '...' or "..."
    • IDENTIFIER = [a-zA-Z_][a-zA-Z0-9_]*
    • NUMBER = [0-9]+(\.[0-9]+)?
    • NEWLINE = End of line character
    • EOF_MARKER = EOF

    Grammar Rules

    1. Script Structure

      Script ::= (CommandLine | BlankLine | CommentLine)*
      
      CommandLine ::= COMMAND_PREFIX Command NEWLINE
      
      CommentLine ::= COMMENT_SYMBOL Text NEWLINE
      
      BlankLine ::= NEWLINE
      
    2. Commands

      Command ::= FileCommand
                | VariableCommand
                | PromptCommand
                | AgentCommand
                | JobCommand
                | ControlFlowCommand
                | FunctionCommand
                | ExecutionCommand
                | OtherCommand
      
    3. File Commands

      FileCommand ::= 'write' StringLiteral '<<' EOF_MARKER NEWLINE Content EOF_MARKER NEWLINE
                    | 'read' StringLiteral '-' VariableName
                    | 'append' StringLiteral '<<' EOF_MARKER NEWLINE Content EOF_MARKER NEWLINE
                    | 'delete' StringLiteral
                    | 'mkdir' StringLiteral
                    | 'ls' StringLiteral '-' VariableName
      
      Content ::= (Text | VariableReference)*
      
      StringLiteral ::= STRING_LITERAL
      
      Text ::= Any sequence of characters excluding NEWLINE
      
    4. Variable Commands

      VariableCommand ::= 'set' VariableName '=' Expression
      
      VariableName ::= IDENTIFIER
      
      VariableReference ::= VARIABLE_PREFIX VariableName
      
      Expression ::= StringLiteral
                   | Number
                   | VariableReference
                   | Expression Operator Expression
      
      Operator ::= '+' | '-' | '*' | '/' | '%'
      
    5. Prompt Commands

      PromptCommand ::= 'prepare' 'prompt' 'as' PromptName '<<' EOF_MARKER NEWLINE Content EOF_MARKER NEWLINE
      
      PromptName ::= IDENTIFIER
      
    6. Agent Commands

      AgentCommand ::= 'assign' VariableReference PromptReference 'as' JobName
      
      PromptReference ::= VariableReference
      
    7. Job Commands

      JobCommand ::= 'execute' VariableReference
      
      JobName ::= IDENTIFIER
      
    8. Control Flow Commands

      ControlFlowCommand ::= IfStatement
                           | ForLoop
                           | WhileLoop
      
      IfStatement ::= 'if' Condition NEWLINE
                      INDENT 'then' NEWLINE
                      INDENT CommandBlock
                      [INDENT 'else' NEWLINE
                      INDENT CommandBlock]
                      INDENT 'endif'
      
      ForLoop ::= 'for' VariableReference 'in' VariableReference NEWLINE
                  INDENT 'do' NEWLINE
                  INDENT CommandBlock
                  INDENT 'done'
      
      WhileLoop ::= 'while' Condition NEWLINE
                    INDENT 'do' NEWLINE
                    INDENT CommandBlock
                    INDENT 'done'
      
      Condition ::= Expression ComparisonOperator Expression
      
      ComparisonOperator ::= '==' | '!=' | '<' | '>' | '<=' | '>='
      
      CommandBlock ::= (CommandLine | CommentLine | BlankLine)*
      
      INDENT ::= (Space or Tab characters)
      
    9. Function Commands

      FunctionCommand ::= 'function' FunctionName [ParameterList] NEWLINE
                          INDENT 'do' NEWLINE
                          INDENT CommandBlock
                          INDENT 'endfunction'
      
      ParameterList ::= ParameterName (',' ParameterName)*
      
      FunctionName ::= IDENTIFIER
      
      FunctionCall ::= FunctionName [ArgumentList]
      
      ArgumentList ::= Argument (',' Argument)*
      
      Argument ::= Expression
      
    10. Execution Commands

      ExecutionCommand ::= FunctionCall
                         | OtherCommand
      
    11. Other Commands

      OtherCommand ::= Any command defined by extensions or custom implementations
      

    Explanation of Syntax Elements

    • Commands: Each command begins with > and specifies an action.
    • Variables: Declared using set and referenced with $VariableName.
    • Strings: Enclosed in single or double quotes.
    • Comments: Start with # and continue to the end of the line.
    • Control Structures: Use if, for, and while blocks for flow control.
    • Functions: Defined using function and invoked by their names.
    • Indentation: Used for readability within blocks but not mandatory; do and done mark block boundaries.

    Notes

    • Variable Scope: Variables are global unless specifically managed within functions.
    • Error Handling: Implementations can extend the language with error handling constructs such as try and catch.
    • Extensibility: The language can be extended with additional commands and functionalities as needed.

    Conclusion

    The AISL provides a comprehensive set of commands and structures to enable users to script automated interactions with agents, manage files and variables, and control the execution flow of tasks. By offering a clear and consistent syntax, AISL simplifies the process of writing scripts for complex workflows involving agents and data manipulation.