first test
This commit is contained in:
@@ -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 }
|
||||
Reference in New Issue
Block a user