first test

This commit is contained in:
tessmania90
2023-04-05 11:29:58 +02:00
parent f82330bc76
commit e239c56304
3 changed files with 135 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env["OPENAI_API_KEY"]
});
const openai = new OpenAIApi(configuration);
const model = process.env["OPENAI_MODEL_NAME"] ?? 'image-alpha-001'
const max_tokens = Number(process.env["OPENAI_MAX_TOKENS"] ?? 2000)
async function continueThread(messages) {
const response = await openai.generateImage({
prompt: messages,
model,
n: 1,
size: "512x512",
response_format: "b64_json",
});
return response.json?.data?.choices?.[0]?.message?.content
}
module.exports = { continueThread }