Alimjan
using OpenAI npm in Deno deploy playground:
i don't know how to return the resualt , now this just return [object Object]
i don't how to use async await
this is my code:
import OpenAI from "npm:openai";
const openai = new OpenAI();
openai.baseURL = "https://cn.gptapi.asia/v1"
console.log(openai.baseURL)
async function main() {
const completion = await openai.chat.completions.create({
messages: [{ role: "system", content: "You are a helpful assistant." }],
model: "gpt-3.5-turbo",
});
console.log(completion.choices[0]);
return completion.choices[0]
}
const resualt = await main();
Deno.serve((req) => new Response(resualt));
4 replies