This is a mock service for multiple AI services.
import OpenAI from 'openai';
const openAIClient = new OpenAI({
baseURL: 'https://mockai.openshield.ai/openai/v1',
apiKey: '',
});
async function main() {
// @ts-ignore
const completion = await openShiedClient.chat.completions.create({
stream: true,
streamDelay: 5000,
model: 'gpt-4',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'What is the meaning of life?' },
],
});
console.log(JSON.stringify(completion, null, 2));
for await (const part of completion) {
process.stdout.write(part.choices[0]?.delta?.content || '');
}
}
main().then(() => console.log('done'));