import OpenAI from 'openai'; const openai = new OpenAI({ apiKey: 'my api key', // defaults to process.env["OPENAI_API_KEY"] baseURL: 'https://hf4all-openai.hf.space', }); async function start() { const completion = await openai.chat.completions.create({ messages: [ { role: 'user', content: '鲁迅为什么打周树人' }, ], model: 'https://huggingface.co/spaces/yuntian-deng/ChatGPT4Turbo', stream: true, }); for await (const part of completion) { process.stdout.write(part.choices[0]?.delta?.content || ''); } } start()