Created
April 21, 2024 19:22
-
-
Save v0xel1337/08c4d9d9b0876718c7aa0a9401d4be2f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = { | |
method: "POST", | |
headers: { | |
"Content-Type": "application/json", | |
"Authorization": "Bearer " + config.chatGpt.secret | |
}, | |
body: JSON.stringify({ | |
model: "gpt-3.5-turbo", | |
messages: [{ | |
role: "user", | |
content: getDialoguePrompt(index).replace("<topic>", req[0].topic) | |
}], | |
temperature: 0.7 | |
}) | |
}; | |
console.log("Generating script for topic: " + req[0].topic); | |
var response = await fetch("https://api.openai.com/v1/chat/completions", request); | |
var jsonResponse = await response.json(); | |
try { | |
var preProcessed = processText(jsonResponse.choices[0].message.content); | |
var messages = validateCharacters(preProcessed); | |
} catch (e) { | |
console.log("Chat GPT failed to respond. Re-generating script"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment