For example, you can send requests to two random models and compare the results:
const { OpenAI } =require('openai');const { Axios } =require('axios');constmain=async () => {constBASE_URL='{{baseUrl}}';constAPI_TOKEN='{{token}}';constaxios=newAxios({ headers: { Authorization:`Bearer ${API_TOKEN}` }, baseURL:BASE_URL, });constopenai=newOpenAI({ baseURL:BASE_URL, apiKey:API_TOKEN });constvendorByModel=awaitaxios.get('/models').then((res) =>JSON.parse(res.data));constmodels=Object.keys(vendorByModel);constshuffledModels= [...models].sort(() =>Math.round(Math.random()));constselectedModels=shuffledModels.slice(0,2);constsystemPrompt=`You are an AI assistant that only responds with jokes.`;constuserPrompt=`Why is the sky blue?`;for (constmodelof selectedModels) {constcompletion=awaitopenai.chat.completions.create({ messages: [ { role:'system', content: systemPrompt }, { role:'user', content: userPrompt }, ], model, });constmessage=completion.choices[0].message.content;console.log(`--- ${model} ---`);console.log(`USER: ${userPrompt}`);console.log(`AI : ${message}`); }};main();
Will return something like this:
--- zero-one-ai/Yi-34B-Chat ---
USER: Why is the sky blue?
AI : Why is the sky blue? Because it's full of blueberries!
--- allenai/OLMo-7B-Instruct ---
USER: Why is the sky blue?
AI : Because the white sun beams enter the blue Earth's atmosphere and get dispersed, resulting in the beautiful color we call "sky blue." It's like looking at paint being blown on a canvas by the wind! Just a joke, but the real answer is physics. 😎