chat gpt func
Sat Oct 14 2023 07:41:48 GMT+0000 (Coordinated Universal Time)
Saved by
@jonathansdunlap
#javascript
async function gptFunctions(prompts, model, functions){
const plan = readFile("public/generated/shared_deps.md")
await openai.chat.completions.create({
messages: [{ role: "system", content: s.appSystemPrompt+"Given the prompt and the plan, return a list of strings corresponding to the new files that will be generated."}
,
{
"role": "user",
"content": " I want a:" +s.prompt,
},
{
"role": "user",
"content": " The plan we have agreed on is:"+s.plan,
},
],
model: model,
functions: [{'name': 'file_paths', 'description': 'Construct a list of file names.', 'parameters': {'type': 'object', 'properties': {'files_to_edit': {'type': 'array', 'items': {'type': 'string'}}}, 'required': ['files_to_edit']}}],
function_call:{"name":"file_paths"}
}).then((response) => {
let temp = JSON.parse(response.choices[0].message.function_call.arguments).files_to_edit;
console.log(temp);
}).catch((error) => {
console.log(error);
});
}
content_copyCOPY
Comments