805 lines
34 KiB
YAML
805 lines
34 KiB
YAML
- answer: |-
|
|
```python
|
|
from typing import List, Dict
|
|
import psycopg2
|
|
|
|
# Define the resource type for PostgreSQL
|
|
class postgresql(TypedDict):
|
|
host: str
|
|
port: int
|
|
user: str
|
|
dbname: str
|
|
sslmode: str
|
|
password: str
|
|
|
|
def main(db_config: postgresql) -> List[Dict]:
|
|
# Connect to the PostgreSQL database
|
|
conn = psycopg2.connect(
|
|
host=db_config['host'],
|
|
port=db_config['port'],
|
|
user=db_config['user'],
|
|
password=db_config['password'],
|
|
dbname=db_config['dbname'],
|
|
sslmode=db_config['sslmode']
|
|
)
|
|
|
|
# Create a cursor object
|
|
cursor = conn.cursor()
|
|
|
|
# Execute the query to fetch all rows from the orders table
|
|
cursor.execute("SELECT * FROM orders")
|
|
|
|
# Fetch all rows from the executed query
|
|
rows = cursor.fetchall()
|
|
|
|
# Get column names from the cursor description
|
|
colnames = [desc[0] for desc in cursor.description]
|
|
|
|
# Convert rows to a list of dictionaries
|
|
result = [dict(zip(colnames, row)) for row in rows]
|
|
|
|
# Close the cursor and connection
|
|
cursor.close()
|
|
conn.close()
|
|
|
|
return result
|
|
```
|
|
description: connect to postgres and list the rows in the orders table
|
|
lang: python3
|
|
template_prompt: |-
|
|
<contextual_information>
|
|
You have to write a function in Python called "main". Specify the parameter types. Do not call the main function. You should generally return the result.
|
|
The "main" function cannot be async. If you need to use async code, you can use the asyncio library.
|
|
You can take as parameters resources which are dictionaries containing credentials or configuration information. For Windmill to correctly detect the resources to be passed, the resource type name has to be exactly as specified in the following list:
|
|
<resourceTypes>
|
|
{resourceTypes}
|
|
</resourceTypes>
|
|
You need to define the type of the resources that are needed before the main function, but only include them if they are actually needed to achieve the function purpose.
|
|
The resource type name has to be exactly as specified (has to be IN LOWERCASE). If the type name conflicts with any imported methods, you have to rename the imported method with the conflicting name.
|
|
<contextual_information>
|
|
My instructions: {description}
|
|
template_system: |-
|
|
You are a helpful coding assistant for Windmill, a developer platform for running scripts. You write code as instructed by the user. Each user message includes some contextual information which should guide your answer.
|
|
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) -> float:
|
|
if num == 0:
|
|
raise ValueError("Division by zero is not allowed")
|
|
return 3 / num
|
|
```
|
|
<explanation>
|
|
The error occurs because dividing by zero is not allowed in mathematics and will raise a `ZeroDivisionError` in Python. To fix this, we need to check if `num` is zero before performing the division. If `num` is zero, we raise a `ValueError` with an appropriate message.
|
|
</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>
|
|
You have to write a function in python called "main". Specify the parameter types. Do not call the main function. You should generally return the result.
|
|
The "main" function cannot be async. If you need to use async code, you can use the asyncio library.
|
|
You can take as parameters resources which are dictionaries containing credentials or configuration information. For Windmill to correctly detect the resources to be passed, the resource type name has to be exactly as specified in the following list:
|
|
<resourceTypes>
|
|
{resourceTypes}
|
|
</resourceTypes>
|
|
You need to define the type of the resources that are needed before the main function, but only include them if they are actually needed to achieve the function purpose.
|
|
The resource type name has to be exactly as specified (has to be IN LOEWRCASE). If the type name conflicts with any imported methods, you have to rename the imported method with the conflicting name.
|
|
<contextual_information>
|
|
I get the following error: {error}
|
|
Fix my code.
|
|
template_system: |-
|
|
You are a helpful coding assistant for Windmill, a developer platform for running scripts. You fix the code shared by the user. Each user message includes some contextual information which should guide your answer.
|
|
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.
|
|
Return the complete fixed code.
|
|
|
|
Here's how interactions have to look like:
|
|
user: {sample_question}
|
|
assistant: ```language
|
|
{code}
|
|
```
|
|
<explanation>{explanation}</explanation>
|
|
type: fix
|
|
- answer: |-
|
|
```python
|
|
def main(num: int) -> float:
|
|
# This function takes an integer 'num' as input and returns the result of dividing 'num' by 16.
|
|
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>
|
|
You have to write a function in python called "main". Specify the parameter types. Do not call the main function. You should generally return the result.
|
|
The "main" function cannot be async. If you need to use async code, you can use the asyncio library.
|
|
You can take as parameters resources which are dictionaries containing credentials or configuration information. For Windmill to correctly detect the resources to be passed, the resource type name has to be exactly as specified in the following list:
|
|
<resourceTypes>
|
|
{resourceTypes}
|
|
</resourceTypes>
|
|
You need to define the type of the resources that are needed before the main function, but only include them if they are actually needed to achieve the function purpose.
|
|
The resource type name has to be exactly as specified (has to be IN LOEWRCASE). If the type name conflicts with any imported methods, you have to rename the imported method with the conflicting name.
|
|
<contextual_information>
|
|
My instructions: {description}
|
|
template_system: |-
|
|
You are a helpful coding assistant for Windmill, a developer platform for running scripts. You modify code as instructed by the user. Each user message includes some contextual information which should guide your answer.
|
|
Only output code. Wrap the code in a code block.
|
|
Put explanations directly in the code as comments.
|
|
Return the complete modified code.
|
|
|
|
Here's how interactions have to look like:
|
|
user: {sample_question}
|
|
assistant: ```language
|
|
{code}
|
|
```
|
|
type: edit
|
|
- answer: |-
|
|
```go
|
|
package inner
|
|
|
|
import (
|
|
"errors"
|
|
)
|
|
|
|
// main function divides a number by 16 and returns the result and an error if any
|
|
func main(number float64) (float64, error) {
|
|
if number == 0 {
|
|
return 0, errors.New("division by zero is not allowed")
|
|
}
|
|
result := number / 16
|
|
return result, nil
|
|
}
|
|
```
|
|
description: divide a number by 16
|
|
lang: go
|
|
template_prompt: |-
|
|
Here's my go code:
|
|
```go
|
|
{code}
|
|
```
|
|
<contextual_information>
|
|
You have to write go code and export a "main" function. Import the packages you need. The return type of the function has to be ({return_type}, error). The file package has to be "inner"
|
|
</contextual_information>
|
|
My instructions: {description}
|
|
template_system: |-
|
|
You are a helpful coding assistant for Windmill, a developer platform for running scripts. You write code as instructed by the user. Each user message includes some contextual information which should guide your answer.
|
|
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 'number-to-words' npm package to convert numbers to words
|
|
import { toWords } from "npm:number-to-words";
|
|
|
|
// Define the main function with the appropriate parameter types
|
|
export async function main(number: number): Promise<string> {
|
|
// Convert the number to words and return the result
|
|
return toWords(number);
|
|
}
|
|
```
|
|
description: convert a number to a word
|
|
lang: deno
|
|
template_prompt: |-
|
|
<contextual_information>
|
|
You have to write TypeScript code and export a "main" function like this: "export async function main(...)" and specify the parameter types but do not call it. You should generally return the result.
|
|
You can import deno libraries or you can also import npm libraries like that: "import ... from "npm:{package}";". The fetch standard method is available globally.
|
|
You can take as parameters resources which are dictionaries containing credentials or configuration information. For Windmill to correctly detect the resources to be passed, the resource type name has to be exactly as specified in the following list:
|
|
<resourceTypes>
|
|
{resourceTypes}
|
|
</resourceTypes>
|
|
You need to define the type of the resources that are needed before the main function, but only include them if they are actually needed to achieve the function purpose.
|
|
The resource type name has to be exactly as specified (no resource suffix). If the type name conflicts with any imported methods, you have to rename the imported method with the conflicting name.
|
|
</contextual_information>
|
|
My instructions: {description}
|
|
template_system: |-
|
|
You are a helpful coding assistant for Windmill, a developer platform for running scripts. You write code as instructed by the user. Each user message includes some contextual information which should guide your answer.
|
|
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
|
|
import { Client } from "npm:pg";
|
|
|
|
type Postgresql = {
|
|
host: string,
|
|
port: number,
|
|
user: string,
|
|
dbname: string,
|
|
sslmode: string,
|
|
password: string
|
|
};
|
|
|
|
export async function main(postgresql: Postgresql) {
|
|
const client = new Client({
|
|
host: postgresql.host,
|
|
port: postgresql.port,
|
|
user: postgresql.user,
|
|
database: postgresql.dbname,
|
|
password: postgresql.password,
|
|
ssl: { rejectUnauthorized: postgresql.sslmode === "require" }
|
|
});
|
|
|
|
await client.connect();
|
|
|
|
try {
|
|
const res = await client.query('SELECT * FROM orders');
|
|
return res.rows;
|
|
} finally {
|
|
await client.end();
|
|
}
|
|
}
|
|
```
|
|
description: connect to postgres and list the rows in the orders table
|
|
lang: deno
|
|
template_prompt: |-
|
|
<contextual_information>
|
|
You have to write TypeScript code and export a "main" function like this: "export async function main(...)" and specify the parameter types but do not call it. You should generally return the result.
|
|
You can import deno libraries or you can also import npm libraries like that: "import ... from "npm:{package}";". The fetch standard method is available globally.
|
|
You can take as parameters resources which are dictionaries containing credentials or configuration information. For Windmill to correctly detect the resources to be passed, the resource type name has to be exactly as specified in the following list:
|
|
<resourceTypes>
|
|
{resourceTypes}
|
|
</resourceTypes>
|
|
You need to define the type of the resources that are needed before the main function, but only include them if they are actually needed to achieve the function purpose.
|
|
The resource type name has to be exactly as specified (no resource suffix). If the type name conflicts with any imported methods, you have to rename the imported method with the conflicting name.
|
|
</contextual_information>
|
|
My instructions: {description}
|
|
template_system: |-
|
|
You are a helpful coding assistant for Windmill, a developer platform for running scripts. You write code as instructed by the user. Each user message includes some contextual information which should guide your answer.
|
|
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
|
|
// No resources are needed for this function
|
|
|
|
export async function main(number: number): Promise<string> {
|
|
const units = ["", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"];
|
|
const teens = ["Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"];
|
|
const tens = ["", "", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"];
|
|
const thousands = ["", "Thousand", "Million", "Billion"];
|
|
|
|
if (number === 0) return "Zero";
|
|
|
|
let word = "";
|
|
let thousandCounter = 0;
|
|
|
|
while (number > 0) {
|
|
if (number % 1000 !== 0) {
|
|
word = convertHundreds(number % 1000) + thousands[thousandCounter] + " " + word;
|
|
}
|
|
number = Math.floor(number / 1000);
|
|
thousandCounter++;
|
|
}
|
|
|
|
return word.trim();
|
|
|
|
function convertHundreds(num: number): string {
|
|
let result = "";
|
|
if (num > 99) {
|
|
result += units[Math.floor(num / 100)] + " Hundred ";
|
|
num %= 100;
|
|
}
|
|
if (num > 19) {
|
|
result += tens[Math.floor(num / 10)] + " ";
|
|
num %= 10;
|
|
}
|
|
if (num > 9) {
|
|
result += teens[num - 10] + " ";
|
|
} else if (num > 0) {
|
|
result += units[num] + " ";
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
```
|
|
description: convert a number to a word
|
|
lang: bun
|
|
template_prompt: |-
|
|
<contextual_information>
|
|
You have to write TypeScript code and export a "main" function like this: "export async function main(...)" and specify the parameter types but do not call it. You should generally return the result.
|
|
The fetch standard method is available globally.
|
|
You can take as parameters resources which are dictionaries containing credentials or configuration information. For Windmill to correctly detect the resources to be passed, the resource type name has to be exactly as specified in the following list:
|
|
<resourceTypes>
|
|
{resourceTypes}
|
|
</resourceTypes>
|
|
You need to define the type of the resources that are needed before the main function, but only include them if they are actually needed to achieve the function purpose.
|
|
The resource type name has to be exactly as specified (no resource suffix). If the type name conflicts with any imported methods, you have to rename the imported method with the conflicting name.
|
|
</contextual_information>
|
|
My instructions: {description}
|
|
template_system: |-
|
|
You are a helpful coding assistant for Windmill, a developer platform for running scripts. You write code as instructed by the user. Each user message includes some contextual information which should guide your answer.
|
|
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 role
|
|
-- $2 email
|
|
-- $3 disabled = false
|
|
-- $4 is_admin = false
|
|
-- $5 operator = false
|
|
-- $6 username
|
|
-- $7 workspace_id
|
|
|
|
INSERT INTO usr (role, email, disabled, is_admin, operator, username, created_at, workspace_id)
|
|
VALUES ($1::varchar, $2::varchar, $3::bool, $4::bool, $5::bool, $6::varchar, now(), $7::varchar);
|
|
```
|
|
description: insert an a new user
|
|
lang: postgresql
|
|
template_prompt: |-
|
|
<contextual_information>
|
|
You have to write a statement for PostgreSQL. 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>
|
|
My instructions: {description}
|
|
template_system: |-
|
|
You are a helpful coding assistant for Windmill, a developer platform for running scripts. You write code as instructed by the user. Each user message includes some contextual information which should guide your answer.
|
|
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: |-
|
|
<contextual_information>
|
|
You have to write a statement for MySQL. 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)
|
|
</contextual_information>
|
|
My instructions: {description}
|
|
template_system: |-
|
|
You are a helpful coding assistant for Windmill, a developer platform for running scripts. You write code as instructed by the user. Each user message includes some contextual information which should guide your answer.
|
|
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: |-
|
|
<contextual_information>
|
|
You have to write a statement for BigQuery. 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....
|
|
</contextual_information>
|
|
My instructions: {description}
|
|
template_system: |-
|
|
You are a helpful coding assistant for Windmill, a developer platform for running scripts. You write code as instructed by the user. Each user message includes some contextual information which should guide your answer.
|
|
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 (?, ?);
|
|
```
|
|
description: insert an email and a name in the users table
|
|
lang: snowflake
|
|
template_prompt: |-
|
|
<contextual_information>
|
|
You have to write a statement for Snowflake. 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)
|
|
</contextual_information>
|
|
My instructions: {description}
|
|
template_system: |-
|
|
You are a helpful coding assistant for Windmill, a developer platform for running scripts. You write code as instructed by the user. Each user message includes some contextual information which should guide your answer.
|
|
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(email: $email, name: $name) {
|
|
id
|
|
email
|
|
name
|
|
}
|
|
}
|
|
```
|
|
description: create a new user with an email and a name
|
|
lang: graphql
|
|
template_prompt: |-
|
|
<contextual_information>
|
|
You have to write a query for GraphQL. Add the needed arguments as query parameters.
|
|
</contextual_information>
|
|
My instructions: {description}
|
|
template_system: |-
|
|
You are a helpful coding assistant for Windmill, a developer platform for running scripts. You write code as instructed by the user. Each user message includes some contextual information which should guide your answer.
|
|
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
|
|
# Get the first argument
|
|
var1="$1"
|
|
|
|
# Divide the number by 16
|
|
result=$((var1 / 16))
|
|
|
|
# Print the result
|
|
echo "$result"
|
|
```
|
|
description: divide a number by 16
|
|
lang: bash
|
|
template_prompt: |-
|
|
<contextual_information>
|
|
You have to write bash code. 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.
|
|
</contextual_information>
|
|
My instructions: {description}
|
|
template_system: |-
|
|
You are a helpful coding assistant for Windmill, a developer platform for running scripts. You write code as instructed by the user. Each user message includes some contextual information which should guide your answer.
|
|
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
|
|
param(
|
|
[int]$Number # Define the parameter to accept an integer input
|
|
)
|
|
|
|
# Divide the number by 16 and store the result
|
|
$Result = $Number / 16
|
|
|
|
# Output the result
|
|
$Result
|
|
```
|
|
description: divide a number by 16
|
|
lang: powershell
|
|
template_prompt: |-
|
|
<contextual_information>
|
|
You have to write Powershell code. Arguments can be obtained by calling the param function on the first line like that: `param($ParamName1, $ParamName2 = "default value", [{type}]$ParamName3, ...)`
|
|
</contextual_information>
|
|
My instructions: {description}
|
|
template_system: |-
|
|
You are a helpful coding assistant for Windmill, a developer platform for running scripts. You write code as instructed by the user. Each user message includes some contextual information which should guide your answer.
|
|
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
|
|
# Get the arguments
|
|
app_name="$1"
|
|
python_version="$2"
|
|
|
|
# Create a Dockerfile
|
|
cat <<EOF > Dockerfile
|
|
# Use the specified Python version as the base image
|
|
FROM python:$python_version
|
|
|
|
# Set the working directory in the container
|
|
WORKDIR /usr/src/app
|
|
|
|
# Copy the current directory contents into the container at /usr/src/app
|
|
COPY . .
|
|
|
|
# Install any needed packages specified in requirements.txt
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Make port 80 available to the world outside this container
|
|
EXPOSE 80
|
|
|
|
# Define environment variable
|
|
ENV NAME $app_name
|
|
|
|
# Run app.py when the container launches
|
|
CMD ["python", "app.py"]
|
|
EOF
|
|
```
|
|
description: write a docker image for a python app
|
|
lang: bash
|
|
template_prompt: |-
|
|
<contextual_information>
|
|
You have to write bash code. 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.
|
|
</contextual_information>
|
|
My instructions: {description}
|
|
template_system: |-
|
|
You are a helpful coding assistant for Windmill, a developer platform for running scripts. You write code as instructed by the user. Each user message includes some contextual information which should guide your answer.
|
|
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 the Github resource
|
|
type Github = {
|
|
token: string
|
|
};
|
|
|
|
// Define the main function
|
|
export async function main(github: Github, owner: string, repo: string): Promise<number> {
|
|
const url = `https://api.github.com/repos/${owner}/${repo}`;
|
|
|
|
const response = await fetch(url, {
|
|
headers: {
|
|
'Authorization': `token ${github.token}`,
|
|
'Accept': 'application/vnd.github.v3+json'
|
|
}
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`Error fetching repository data: ${response.statusText}`);
|
|
}
|
|
|
|
const data = await response.json();
|
|
return data.stargazers_count;
|
|
}
|
|
```
|
|
description: query the github api and return the number of stars of a repo
|
|
lang: nativets
|
|
template_prompt: |-
|
|
<contextual_information>
|
|
You have to write TypeScript code and export a "main" function like this: "export async function main(...)" and specify the parameter types but do not call it. You should generally return the result.
|
|
You should use fetch and are not allowed to import any libraries.
|
|
You can take as parameters resources which are dictionaries containing credentials or configuration information. For Windmill to correctly detect the resources to be passed, the resource type name has to be exactly as specified in the following list:
|
|
<resourceTypes>
|
|
{resourceTypes}
|
|
</resourceTypes>
|
|
You need to define the type of the resources that are needed before the main function, but only include them if they are actually needed to achieve the function purpose.
|
|
The resource type name has to be exactly as specified (no resource suffix).
|
|
</contextual_information>
|
|
My instructions: {description}
|
|
template_system: |-
|
|
You are a helpful coding assistant for Windmill, a developer platform for running scripts. You write code as instructed by the user. Each user message includes some contextual information which should guide your answer.
|
|
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
|
|
// Set the value of the input with id 'my_field' to the context variable email
|
|
document.getElementById('my_field').value = ctx.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}.
|
|
|
|
<contextual_information>
|
|
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)
|
|
You can use the openModal and closeModal functions to open and close a modal: openModal(id: string), closeModal(id: string)
|
|
You can use the setTab function to manually set the tab of a Tab component: setTab(id: string, index: string)
|
|
You can use the recompute function to recompute a component: recompute(id: string)
|
|
You can use the getAgGrid function to get the ag-grid instance of a table: getAgGrid(id: string)
|
|
You can use the setSelectedIndex function to select a row in a table or an AG Grid table: setSelectedIndex(id: string, index: number)
|
|
The setValue function is meant to set or force the value of a component: setValue(id: string, value: any)
|
|
You can validate a specific field of a form: validate(id: string, key: string)
|
|
You can validate all fields of a form: validateAll(id: string, key: string)
|
|
You can invalidate a specific field of a form: invalidate(id: string, key: string, error: string)
|
|
</contextual_information>
|
|
template_system: |-
|
|
You are a helpful coding assistant for Windmill, a developer platform for running scripts. You write code as instructed by the user. Each user message includes some contextual information which should guide your answer.
|
|
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 username
|
|
SELECT AVG(job_count) AS average_jobs_per_month
|
|
FROM (
|
|
SELECT DATE_TRUNC('month', created_at) AS month, COUNT(*) AS job_count
|
|
FROM completed_job
|
|
WHERE created_by = $1::varchar
|
|
GROUP BY month
|
|
) AS monthly_jobs;
|
|
```
|
|
description: compute the average number of completed jobs per month for the given
|
|
username
|
|
lang: postgresql
|
|
template_prompt: |-
|
|
<contextual_information>
|
|
You have to write a statement for PostgreSQL. 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>
|
|
My instructions: {description}
|
|
template_system: |-
|
|
You are a helpful coding assistant for Windmill, a developer platform for running scripts. You write code as instructed by the user. Each user message includes some contextual information which should guide your answer.
|
|
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 owner
|
|
SELECT is_secret FROM variable WHERE owner = $1::varchar
|
|
```
|
|
<explanation>
|
|
The error occurred because the column "is_secret" does not exist in the "account" table. According to the provided database schema, the "is_secret" column is in the "variable" table. The fixed code selects "is_secret" from the correct table and includes a parameter for filtering by the "owner" column.
|
|
</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 are a helpful coding assistant for Windmill, a developer platform for running scripts. You fix the code shared by the user. Each user message includes some contextual information which should guide your answer.
|
|
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.
|
|
Return the complete fixed code.
|
|
|
|
Here's how interactions have to look like:
|
|
user: {sample_question}
|
|
assistant: ```language
|
|
{code}
|
|
```
|
|
<explanation>{explanation}</explanation>
|
|
type: fix
|
|
- answer: |-
|
|
```php
|
|
<?php
|
|
|
|
// require:
|
|
// stripe/stripe-php
|
|
|
|
if (!class_exists('Stripe')) {
|
|
class Stripe {
|
|
public string $token;
|
|
}
|
|
}
|
|
|
|
function main(Stripe $stripe): array {
|
|
\Stripe\Stripe::setApiKey($stripe->token);
|
|
|
|
$customers = \Stripe\Customer::all();
|
|
|
|
return $customers->data;
|
|
}
|
|
```
|
|
description: list all customers from stripe
|
|
lang: php
|
|
template_prompt: |-
|
|
<contextual_information>
|
|
You have to write a function in php called "main". Specify the parameter types. Do not call the main function. You should generally return the result. The script must start with `<?php`.
|
|
You can take as parameters resources which are classes containing credentials or configuration information. For Windmill to correctly detect the resources to be passed, the resource type name has to be exactly as specified in the following list:
|
|
<resourceTypes>
|
|
{resourceTypes}
|
|
</resourceTypes>
|
|
You need to define the type of the resources that are needed before the main function, but only include them if they are actually needed to achieve the function purpose.
|
|
Before defining each type, check if the class already exists using class_exists.
|
|
The resource type name has to be exactly as specified.
|
|
If you need to import libraries, you need to specify them as comments in the following manner before the main function:
|
|
```
|
|
// require:
|
|
// mylibrary/mylibrary
|
|
// myotherlibrary/myotherlibrary@optionalversion
|
|
```
|
|
No need to require autoload, it is already done.
|
|
<contextual_information>
|
|
My instructions: {description}
|
|
template_system: |-
|
|
You are a helpful coding assistant for Windmill, a developer platform for running scripts. You write code as instructed by the user. Each user message includes some contextual information which should guide your answer.
|
|
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
|