Sample Workflows

Adding Context to Your Requests

Leverage Context Files in Your Prompts

You can use Brilliant to automatically include context in each of your LLM requests. Here, we'll expand upon a previously created prompt by including context in our LLM request via the {file:relative/path.txt}} SpecialContextData. Any file within your workspace can be included in your request with this ContextData element, and it can be called within your prompt template, another ContextData elements, or event directly within the chatbox. For this workflow, we'll create a new ContextData element to reference multiple files.

Creating Your ContextData Element

Within the ContextData tab in Brilliant, select Create New ContextData and specify the key to your liking.

Key:

sampleWorkflowContext

In the Value field, specify the files from your workspace that you'd like to include as context. In this example, we'll use a code styling file and comment guildeline file we've previously saved to our active workspace to include as context in our request.

Value:

{{file:commentContext.txt}}

{{file:styleGuidelines.md}}

Call Your New ContextData Element

By calling our new ContextData element via {{sampleWorkflowContext}}, Brilliant will automatically include your context files in your LLM request. We'll reference it in our previously created system prompt template.

System prompt template:

Always respond with two code blocks.

The first code block should always code, even when the user request is
nonsensical or seems to not require any code - your output will be
automatically written to a file and executed. If there is no code required
to satisfy the request, consider writing code that merely prints a helpful
message explaining why there's no actual code to run. 
    
Your generated code should always follow best practice guidelines as
specified in these context files: {{sampleWorkflowContext}}.

The second code block should only contain a terminal command that will
automatically be run to execute the code from the first code block.

Use the programming language implied by the filename {{arg:filename}} if
the user does not specify a language or runtime themselves. Assume your
code block will be written to a file as its entire contents, so make sure
it includes any necesary "imports" or the equivalent in your chosen
language.

Upon running our updated prompt, our best practice styling and guidelines should be referenced in our response.

Create and Run Unit Tests

Creating Unit Tests from Existing Code

By combining Brilliant's write to file and run in terminal actions as well as the {{file:relative/path.txt}} or {{selection}} SpecialContextDatas, we can quickly generate and run unit tests within your codebase.

Add a Prompt to Generate a Unit Test File

We'll create a workflow from scratch that generates and runs a unit test from a specific selection of your codebase. After setting the prompt information fields to your liking, we'll want to leverage the {{selection}} Special ContextData to indicate which portion of the codebase we want to generate and run a unit test for.

User prompt template:

I have the following code:

```{{ft}}
{{selection}}```

You are tasked with generating a unit test.

System prompt template:

Always respond with two code blocks.

The first code block will be automatically written to a new file
{{arg:filename}}. This file should include the generated code for the
unit test.

The second code block should include an invocation command for running
the unit test file from code block one. Your output will be automatically
parsed and executed in the user terminal.

Insertion method:

write to file

Prompt Response Block Number:

1

File Path:

{{arg:filename}}

Insertion method:

run in terminal

Prompt Response Block Number:

2

Run Your Prompt

Your prompt is now configured to generate a new file containing code for a unit test and run it. To specifcy the portion of your codebase in which you want the unit test to apply, simply highlight the desired code within the code window and run your new prompt.

Create and Run a Script

Creating a Bash Script Workflow

Now we'll create a generate and run a simple shell script. Although the contents of the file we generate isn't similar to the previous unit test workflow, since this workflow follows the same general structure (i.e. writing a new file and running it in terminal), we can modify our previous unit test prompt and leave the insertion methods as is.

Modifying our Extisting Unit Test Prompt

Click the edit button on your previously created unit test prompt. As always, set the prompt information to your liking. To reference a specific code file we want to generate a script for, we'll leverage the {{file}} Special ContextData. This will automatically reference the contents of your most recently opened file.

User prompt template:

I have the following code:

```{{file}}```

You are tasked with generating a script to install any dependencies and
run the code.

System prompt template:

Always respond with two code blocks.

The first code block will be automatically written to a new file
{{arg:filename}}. This file should include shell code to install any
dependencies needed to build/test/run the relevant code. It should also
include a bash/terminal command that builds and runs the generated code in
a simple happy-path scenario.

The second code block should include an invocation command to run the
script generated in code block one.

Use the Save as New Prompt option to avoid overwriting your previously created prompt.

Run Your Prompt

When running your prompt, Brilliant will prompt you to specify a filename for your scipt. Since we want to generate a shell script, we'll want to specify it as such.

filename:

testScript.sh

Translate Code to Google Cloud Functions Framework and Deploy

Update Prompts to Fit Your Needs

With your new code file, you can leverage Brilliant's default ContextData elements to easily deploy your function via GCP. For this demonstration, we'll modify the existing Create Google Cloud Function prompt to deploy our already generated code.

Modifying the Default Prompt

Click the edit button on the default Create Google Cloud Function prompt. Modifying the prompt's template will allow you to automatically save your modified prompt without updating the original prompt you're modifying.

Title:

Translate to GCF Framework and Deploy

Since we want to use our existing code file as the base for our Google Cloud Function, we can modify the user prompt template to translate our code into the GCP framework.

User prompt template:

Translate the following {{language}} code into the Google Cloud Function
framework:

```{{ft}}
{{selection}}```

Output files will be written to the sub directory code/ within current
directory {{arg:dir}}. The specific files written will be
{{gcf{{arg:runtime}}Codefile}} and {{gcf{{arg:runtime}}Deps}}, in that
order.

### Run Your Prompt

Since we're using the {{selection}} Special ContextData, we'll want to
highlight the specific code we want translated and dployed in our Google
Cloud Function. Once your selection is made, simply click your new
Translate to GCF Framework and Deploy prompt and let Brilliant handle the
rest.

</details>