-
Notifications
You must be signed in to change notification settings - Fork 0
/
prompt.ts
45 lines (34 loc) · 1.85 KB
/
prompt.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
export const generateFunctionPrompt = <I, O>(description: string, inputs: I, output: O) => `
Generate a fully typed typescript function based on the given description, input schema and output schema to be passed into eval function.
Example:
description: 'Return a happy birthday message to the person mentioning the age.'
input: { readonly name: string; readonly age: number }
output: string
function main(person: { readonly name: string; readonly age: number }): string {
return \`Happy birthday \${person.name}. You're now \${person.age} years old\`
}
Make sure the function is called 'main'.
Make sure the response is in a text format.Not a code block.
Generate a single function with the following description, inputs and output schema:
description: ${description}
inputs: ${inputs}
output: ${output}
`;
export const retryGenerateFunctionPrompt = <I, O>(description: string, inputs: I, output: O, previousAttempts: Array<{ response: string, error: string }>) =>
`${generateFunctionPrompt(description, inputs, output)}
Generate a fully typed typescript function based on the given description, input schema and output schema to be passed into eval function.
Example:
description: 'Return a happy birthday message to the person mentioning the age.'
input: { readonly name: string; readonly age: number }
output: string
function main(person: { readonly name: string; readonly age: number }): string {
return \`Happy birthday \${person.name}. You're now \${person.age} years old\`
}
Make sure the function is called 'main'.
Make sure the response is in a text format.Not a code block.
${previousAttempts.map(attempt => `For the reponse: ${attempt.response}, the error was: ${attempt.error}`).join('\n')}
Please retry and generate a single function with the following description, inputs and output schema:
description: ${description}
inputs: ${inputs}
output: ${output}
`;