Files
windmill/llm/sample_answers.yaml
HugoCasa 733bfe3f14 fix: flow trigger prompt + lower temp (#2377)
* fix: flow trigger prompt + lower temp

* fix: add back await
2023-10-03 12:00:31 +02:00

668 lines
27 KiB
YAML

- answer: |-
```python
import psycopg2
from typing import TypedDict
# Define the resource type for postgresql
class postgresql(TypedDict):
host: str
port: int
user: str
dbname: str
sslmode: str
password: str
def main(postgresql_resource: postgresql):
# Connect to the PostgreSQL server
conn = psycopg2.connect(
host=postgresql_resource['host'],
port=postgresql_resource['port'],
user=postgresql_resource['user'],
dbname=postgresql_resource['dbname'],
sslmode=postgresql_resource['sslmode'],
password=postgresql_resource['password']
)
# Create a cursor
cur = conn.cursor()
# Execute a command: this creates a new table
cur.execute("SELECT * FROM orders")
# Fetch all the rows
rows = cur.fetchall()
# Close communication with the PostgreSQL database server
cur.close()
conn.close()
# Return the rows
return rows
```
description: connect to postgres and list the rows in the orders table
lang: python3
template_prompt: |-
Write a function in python called "main". The function should {description}. Specify the parameter types. Do not call the main function.
You can take as parameters resources which are dictionaries containing credentials or configuration information. Name the resource parameters like this: "{resource_type}_resource".
The resource type name has to be exactly as specified (has to be IN LOWERCASE).
<resourceTypes>
{resourceTypes}
</resourceTypes>
Only define the type for resources that are actually needed to achieve the function purpose. If the type name conflicts with the imported object, rename the imported object NOT THE TYPE.
template_system: |-
You write code as instructed by the user. Only output code. Wrap the code in a code block.
Put explanations directly in the code as comments.
Here's how interactions have to look like:
user: {sample_question}
assistant: ```language
{code}
```
type: gen
- answer: |-
```python
def main(num: int, airtable_resource: airtable) -> float:
if num == 0:
raise ValueError("The input number cannot be zero.")
return 3 / num
```
<explanation>
The error you're encountering is a "division by zero" error. This happens when the variable `num` is zero, because division by zero is undefined in mathematics and not allowed in Python.
To fix this, I added a check at the start of your function to see if `num` is zero. If it is, the function raises a `ValueError` with a descriptive message. This way, the function will stop executing before it tries to perform the division, and you'll get a helpful error message instead of a "division by zero" error.
Also, based on the contextual information you provided, I added a parameter for the `airtable_resource` of type `airtable` to the function. This is because you mentioned that the function should take resources as parameters, and the resource parameters should be named "{resource_type}_resource". However, if you don't need this resource for your function, feel free to remove this parameter.
</explanation>
code: |-
def main(num: int) -> float:
return 3 / num
error: division by zero
lang: python3
template_prompt: |-
Here's my python3 code:
```python
{code}
```
<contextual_information>
We have to export a "main" function and specify the parameter types but do not call it.
You can take as parameters resources which are dictionaries containing credentials or configuration information. Name the resource parameters like this: "{resource_type}_resource".
The resource type name has to be exactly as specified (has to be IN LOWERCASE).
<resourceTypes>
{resourceTypes}
</resourceTypes>
Only define the type for resources that are actually needed to achieve the function purpose. If the type name conflicts with the imported object, rename the imported object NOT THE TYPE.
</contextual_information>
I get the following error: {error}
Fix my code.
template_system: |-
You fix the code shared by the user. Only output code. Wrap the code in a code block.
Explain the error and the fix after generating the code inside an <explanation> tag.
Also put explanations directly in the code as comments.
Here's how interactions have to look like:
user: {sample_question}
assistant: ```language
{code}
```
<explanation>{explanation}</explanation>
type: fix
- answer: |-
```python
# This is a Python function named 'main' that takes an integer as an argument.
# The function returns the result of the division of the input number by 16.
# The return type of the function is float.
def main(num: int) -> float:
return num / 16
```
code: |-
def main(num: int) -> float:
return num / 16
description: comment my code
lang: python3
template_prompt: |-
Here's my python3 code:
```python
{code}
```
<contextual_information>
We have to export a "main" function and specify the parameter types but do not call it.
You can take as parameters resources which are dictionaries containing credentials or configuration information. Name the resource parameters like this: "{resource_type}_resource".
The resource type name has to be exactly as specified (has to be IN LOWERCASE).
<resourceTypes>
{resourceTypes}
</resourceTypes>
Only define the type for resources that are actually needed to achieve the function purpose. If the type name conflicts with the imported object, rename the imported object NOT THE TYPE.
</contextual_information>
My instructions: {description}
template_system: |-
You write code as instructed by the user. Only output code. Wrap the code in a code block.
Put explanations directly in the code as comments.
Here's how interactions have to look like:
user: {sample_question}
assistant: ```language
{code}
```
type: edit
- answer: |-
```go
package inner
import (
"errors"
"fmt"
)
func main(num float64) (float64, error) {
// Check if the number is zero to avoid division by zero error
if num == 0 {
return 0, errors.New("Cannot divide by zero")
}
// Divide the number by 16
result := num / 16
return result, nil
}
```
description: civide a number by 16
lang: go
template_prompt: |-
Write a function in go called "main". The function should {description}. Import the packages you need. The return type of the function has to be ({return_type}, error). The file package has to be "inner".
template_system: |-
You write code as instructed by the user. Only output code. Wrap the code in a code block.
Put explanations directly in the code as comments.
Here's how interactions have to look like:
user: {sample_question}
assistant: ```language
{code}
```
type: gen
- answer: |-
```typescript
// Importing the required npm library
import { toWords } from "npm:number-to-words";
// Defining the main function
export async function main(number: number): Promise<string> {
// Converting the number to words using the toWords function from the number-to-words library
const numberInWords = toWords(number);
// Returning the converted number
return numberInWords;
}
```
description: convert a number to a word
lang: deno
template_prompt: |-
Write a function in TypeScript called "main". The function should {description}. Specify the parameter types. You are in a Deno environment. You can import deno libraries or you can also import npm libraries like that: "import ... from "npm:{package}";". Export the "main" function like this: "export async function main(...)". Do not call the main function.
If needed, the standard fetch method is available globally, do not import it.
You can take as parameters resources which are dictionaries containing credentials or configuration information. Name the resource parameters like this: "{resource_type}Resource".
The resource type name has to be exactly as specified.
<resourceTypes>
{resourceTypes}
</resourceTypes>
Only define the type for resources that are actually needed to achieve the function purpose. If the type name conflicts with the imported object, rename the imported object NOT THE TYPE.
template_system: |-
You write code as instructed by the user. Only output code. Wrap the code in a code block.
Put explanations directly in the code as comments.
Here's how interactions have to look like:
user: {sample_question}
assistant: ```language
{code}
```
type: gen
- answer: |-
```typescript
// Importing the required libraries
import { Client } from "npm:https://deno.land/x/postgres/mod.ts";
// Defining the type for Postgresql resource
type Postgresql = {
host: string,
port: number,
user: string,
dbname: string,
sslmode: string,
password: string
}
// Defining the main function
export async function main(postgresqlResource: Postgresql) {
// Creating a new client with the provided resource
const client = new Client({
hostname: postgresqlResource.host,
port: postgresqlResource.port,
user: postgresqlResource.user,
database: postgresqlResource.dbname,
password: postgresqlResource.password,
tls: {
enforce: postgresqlResource.sslmode === "require",
},
});
// Connecting to the database
await client.connect();
// Querying the orders table
const result = await client.queryArray("SELECT * FROM orders;");
// Closing the connection
await client.end();
// Returning the result
return result.rows;
}
```
description: connect to postgres and list the rows in the orders table
lang: deno
template_prompt: |-
Write a function in TypeScript called "main". The function should {description}. Specify the parameter types. You are in a Deno environment. You can import deno libraries or you can also import npm libraries like that: "import ... from "npm:{package}";". Export the "main" function like this: "export async function main(...)". Do not call the main function.
If needed, the standard fetch method is available globally, do not import it.
You can take as parameters resources which are dictionaries containing credentials or configuration information. Name the resource parameters like this: "{resource_type}Resource".
The resource type name has to be exactly as specified.
<resourceTypes>
{resourceTypes}
</resourceTypes>
Only define the type for resources that are actually needed to achieve the function purpose. If the type name conflicts with the imported object, rename the imported object NOT THE TYPE.
template_system: |-
You write code as instructed by the user. Only output code. Wrap the code in a code block.
Put explanations directly in the code as comments.
Here's how interactions have to look like:
user: {sample_question}
assistant: ```language
{code}
```
type: gen
- answer: |-
```typescript
// Importing the 'numeral' library to convert numbers to words
import * as numeral from 'numeral';
export async function main(number: number): Promise<string> {
// Converting the number to a word using the 'numeral' library
const word = numeral(number).format('0,0');
// Returning the word
return word;
}
```
description: convert a number to a word
lang: bun
template_prompt: |-
Write a function in TypeScript called "main". The function should {description}. Specify the parameter types. You can import npm libraries. Export the "main" function like this: "export async function main(...)". Do not call the main function.
If needed, the standard fetch method is available globally, do not import it.
You can take as parameters resources which are dictionaries containing credentials or configuration information. Name the resource parameters like this: "{resource_type}Resource".
The resource type name has to be exactly as specified.
<resourceTypes>
{resourceTypes}
</resourceTypes>
Only define the type for resources that are actually needed to achieve the function purpose. If the type name conflicts with the imported object, rename the imported object NOT THE TYPE.
template_system: |-
You write code as instructed by the user. Only output code. Wrap the code in a code block.
Put explanations directly in the code as comments.
Here's how interactions have to look like:
user: {sample_question}
assistant: ```language
{code}
```
type: gen
- answer: |-
```sql
-- $1 email
-- $2 disabled
-- $3 is_admin
-- $4 operator
-- $5 username
-- $6 workspace_id
INSERT INTO usr (email, disabled, is_admin, operator, username, workspace_id)
VALUES ($1::varchar, $2::bool, $3::bool, $4::bool, $5::varchar, $6::varchar);
```
description: insert an a new user
lang: postgresql
template_prompt: |-
Write SQL code for a PostgreSQL that should {description}. Arguments can be obtained directly in the statement with `$1::{type}`, `$2::{type}`, etc... Name the parameters (without specifying the type) by adding comments before the statement like that: `-- $1 name1` or `-- $2 name = default` (one per row)
template_system: |-
You write code as instructed by the user. Only output code. Wrap the code in a code block.
Put explanations directly in the code as comments.
Here's how interactions have to look like:
user: {sample_question}
assistant: ```language
{code}
```
type: gen
- answer: |-
```sql
-- ? email (VARCHAR)
-- ? name (VARCHAR)
INSERT INTO users (email, name) VALUES (?, ?);
```
description: insert an email and a name in the users table
lang: mysql
template_prompt: |-
Write SQL code for MySQL that should {description}. Arguments can be obtained directly in the statement with ?. Name the parameters by adding comments before the statement like that: `-- ? name1 ({type})` or `-- ? name2 ({type}) = default` (one per row)
template_system: |-
You write code as instructed by the user. Only output code. Wrap the code in a code block.
Put explanations directly in the code as comments.
Here's how interactions have to look like:
user: {sample_question}
assistant: ```language
{code}
```
type: gen
- answer: |-
```sql
-- @email (STRING)
-- @name (STRING)
INSERT INTO users (email, name)
VALUES (@email, @name)
```
description: insert an email and a name in the users table
lang: bigquery
template_prompt: |-
Write SQL code for BigQuery that should {description}. You can define arguments by adding comments before the statement like that: `-- @name1 ({type})` or `-- @name2 ({type}) = default` (one per row). They can then be obtained directly in the statement with `@name1`, `@name2`, etc....
template_system: |-
You write code as instructed by the user. Only output code. Wrap the code in a code block.
Put explanations directly in the code as comments.
Here's how interactions have to look like:
user: {sample_question}
assistant: ```language
{code}
```
type: gen
- answer: |-
```sql
-- ? email (VARCHAR)
-- ? name (VARCHAR)
INSERT INTO users (email, name)
VALUES (?, ?);
```
description: insert an email and a name in the users table
lang: snowflake
template_prompt: |-
Write SQL code for snowflake that should {description}. Arguments can be obtained directly in the statement with ?. Name the parameters by adding comments before the statement like that: `-- ? name1 ({type})` or `-- ? name2 ({type}) = default` (one per row)
template_system: |-
You write code as instructed by the user. Only output code. Wrap the code in a code block.
Put explanations directly in the code as comments.
Here's how interactions have to look like:
user: {sample_question}
assistant: ```language
{code}
```
type: gen
- answer: |-
```graphql
mutation CreateUser($email: String!, $name: String!) {
createUser(input: {email: $email, name: $name}) {
user {
id
email
name
}
}
}
```
In this GraphQL mutation, we are creating a new user with an email and a name. The `$email` and `$name` are variables that we pass into the `CreateUser` mutation. The `!` after the variable type means that these fields are required. The `createUser` mutation takes an `input` object that contains the `email` and `name` fields. The `user` object that is returned contains the `id`, `email`, and `name` of the newly created user.
description: create a new user with an email and a name
lang: graphql
template_prompt: |-
Write a GraphQL query that should {description}. Add the needed arguments as query parameters.
template_system: |-
You write code as instructed by the user. Only output code. Wrap the code in a code block.
Put explanations directly in the code as comments.
Here's how interactions have to look like:
user: {sample_question}
assistant: ```language
{code}
```
type: gen
- answer: |-
```bash
# Assign the first argument to a variable
var1="$1"
# Divide the variable by 16 using bc (a language that supports arbitrary precision numbers)
result=$(echo "scale=2; $var1 / 16" | bc)
# Print the result
echo $result
```
description: divide a number by 16
lang: bash
template_prompt: |-
Write bash code that should {description}. Do not include "#!/bin/bash". Arguments are always string and can only be obtained with "var1="$1"", "var2="$2"", etc... You do not need to check if the arguments are present.
template_system: |-
You write code as instructed by the user. Only output code. Wrap the code in a code block.
Put explanations directly in the code as comments.
Here's how interactions have to look like:
user: {sample_question}
assistant: ```language
{code}
```
type: gen
- answer: |-
```powershell
# Define a function that accepts a number as a parameter and divides it by 16
function DivideBySixteen {
param(
[int]$Number # The number to divide
)
# Divide the number by 16 and return the result
return $Number / 16
}
```
description: divide a number by 16
lang: powershell
template_prompt: |-
Write powershell code that should {description}. Arguments can be obtained by calling the param function on the first line like that: `param($ParamName1, $ParamName2 = "default value", [{type}]$ParamName3, ...)`
template_system: |-
You write code as instructed by the user. Only output code. Wrap the code in a code block.
Put explanations directly in the code as comments.
Here's how interactions have to look like:
user: {sample_question}
assistant: ```language
{code}
```
type: gen
- answer: |-
```bash
# Assigning the arguments to variables
image_name="$1"
app_directory="$2"
# Navigate to the app directory
cd "$app_directory"
# Write the Dockerfile
echo "FROM python:3.7-slim" > Dockerfile
echo "WORKDIR /app" >> Dockerfile
echo "COPY . /app" >> Dockerfile
echo "RUN pip install --no-cache-dir -r requirements.txt" >> Dockerfile
echo "CMD [ \"python\", \"./your-daemon-or-script.py\" ]" >> Dockerfile
# Build the Docker image
docker build -t "$image_name" .
```
This script will create a Dockerfile in the specified app directory and then build a Docker image from it. The Dockerfile is set up to use the slim version of Python 3.7, copy the app files into the image, install any requirements, and then run a Python script when a container is started from the image. You should replace "your-daemon-or-script.py" with the actual script you want to run.
description: write a docker image for a python app
lang: bash
template_prompt: |-
Write bash code that should {description}. Do not include "#!/bin/bash". Arguments are always string and can only be obtained with "var1="$1"", "var2="$2"", etc... You do not need to check if the arguments are present.
template_system: |-
You write code as instructed by the user. Only output code. Wrap the code in a code block.
Put explanations directly in the code as comments.
Here's how interactions have to look like:
user: {sample_question}
assistant: ```language
{code}
```
type: gen
- answer: |-
```typescript
// Define the type for Github resource
type Github = {
token: string
}
// Define the main function
export async function main(githubResource: Github, owner: string, repo: string): Promise<number> {
// Define the url for the Github API
const url = `https://api.github.com/repos/${owner}/${repo}`;
// Fetch the data from the Github API
const response = await fetch(url, {
headers: {
'Authorization': `token ${githubResource.token}`,
'Accept': 'application/vnd.github.v3+json'
}
});
// Check if the response is ok
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
// Parse the response to JSON
const data = await response.json();
// Return the number of stars
return data.stargazers_count;
}
```
description: query the github api and return the number of stars of a repo
lang: nativets
template_prompt: |-
Write a function in TypeScript called "main". The function should {description}. Specify the parameter types. You should use fetch and are not allowed to import any libraries. Export the "main" function like this: "export async function main(...)". Do not call the main function.
You can take as parameters resources which are dictionaries containing credentials or configuration information. Name the resource parameters like this: "{resource_type}Resource".
The resource type name has to be exactly as specified.
<resourceTypes>
{resourceTypes}
</resourceTypes>
Only define the type for resources that are actually needed to achieve the function purpose. If the type name conflicts with the imported object, rename the imported object NOT THE TYPE.
template_system: |-
You write code as instructed by the user. Only output code. Wrap the code in a code block.
Put explanations directly in the code as comments.
Here's how interactions have to look like:
user: {sample_question}
assistant: ```language
{code}
```
type: gen
- answer: |-
```javascript
// Access the email from the context object
var email = ctx.email;
// Use the setValue function to set the value of the input with id 'my_field' to the email
setValue('my_field', email);
```
description: set the value of the input with id 'my_field' to the context variable
email
lang: frontend
template_prompt: |-
Write client-side javascript code that should {description}. You have access to a few helpers:
You can access the context object with the ctx global variable.
The app state is a store that can be used to store data. You can access and update the state object with the state global variable like this: state.foo = 'bar'
You can use the goto function to navigate to a specific URL: goto(path: string, newTab?: boolean)
Use the setTab function to manually set the tab of a Tab component: setTab(id: string, index: string)
Use the recompute function to recompute a component: recompute(id: string)
Use the getAgGrid function to get the ag-grid instance of a table: getAgGrid(id: string)
The setValue function is meant to set or force the value of a component: setValue(id: string, value: any).
template_system: |-
You write code as instructed by the user. Only output code. Wrap the code in a code block.
Put explanations directly in the code as comments.
Here's how interactions have to look like:
user: {sample_question}
assistant: ```language
{code}
```
type: gen
- answer: |-
-- $1 username
```sql
SELECT
EXTRACT(MONTH FROM completed_job.created_at) AS month,
EXTRACT(YEAR FROM completed_job.created_at) AS year,
COUNT(*)::DECIMAL / COUNT(DISTINCT completed_job.created_at::DATE) AS avg_jobs_per_month
FROM
completed_job
WHERE
completed_job.created_by = $1::VARCHAR
GROUP BY
year,
month
ORDER BY
year DESC,
month DESC;
```
This SQL query will compute the average number of completed jobs per month for the given username. It groups the completed jobs by year and month, and then calculates the average number of jobs per month. The result is ordered by year and month in descending order.
description: compute the average number of completed jobs per month for the given
username
lang: postgresql
template_prompt: |-
Write SQL code for a PostgreSQL that should {description}. Arguments can be obtained directly in the statement with `$1::{type}`, `$2::{type}`, etc... Name the parameters (without specifying the type) by adding comments before the statement like that: `-- $1 name1` or `-- $2 name = default` (one per row)
template_system: |-
You write code as instructed by the user. Only output code. Wrap the code in a code block.
Put explanations directly in the code as comments.
Here's how interactions have to look like:
user: {sample_question}
assistant: ```language
{code}
```
type: gen
- answer: |-
```sql
SELECT is_secret FROM variable
```
<explanation>
The error you're encountering is because you're trying to select a column "is_secret" from a table "account" where it does not exist.
Looking at your database schema, the "is_secret" column exists in the "variable" table, not in the "account" table.
So, the correct SQL statement should be `SELECT is_secret FROM variable`.
</explanation>
code: |-
SELECT is_secret FROM account
error: 'ExecutionError: db error: ERROR: column "is_secret" does not exist'
lang: postgresql
template_prompt: |-
Here's my PostgreSQL code:
```sql
{code}
```
<contextual_information>
Arguments can be obtained directly in the statement with `$1::{type}`, `$2::{type}`, etc... Name the parameters (without specifying the type) by adding comments before the statement like that: `-- $1 name1` or `-- $2 name = default` (one per row)
</contextual_information>
I get the following error: {error}
Fix my code.
template_system: |-
You fix the code shared by the user. Only output code. Wrap the code in a code block.
Explain the error and the fix after generating the code inside an <explanation> tag.
Also put explanations directly in the code as comments.
Here's how interactions have to look like:
user: {sample_question}
assistant: ```language
{code}
```
<explanation>{explanation}</explanation>
type: fix