mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-14 10:30:10 +01:00
633f425206
* WIP openrouter integration * add OpenRouter options to onboarding flow and data handling * add todo to fix headers for rankings * OpenRouter LLM support complete * Fix hanging response stream with OpenRouter update tagline update comment * update timeout comment * wait for first chunk to start timer * sort OpenRouter models by organization * uppercase first letter of organization * sort grouped models by org --------- Co-authored-by: timothycarambat <rambat1010@gmail.com>
38 lines
1.0 KiB
JavaScript
38 lines
1.0 KiB
JavaScript
// OpenRouter has lots of models we can use so we use this script
|
|
// to cache all the models. We can see the list of all the models
|
|
// here: https://openrouter.ai/docs#models
|
|
|
|
// To run, cd into this directory and run `node parse.mjs`
|
|
// copy outputs into the export in ../models.js
|
|
|
|
// Update the date below if you run this again because OpenRouter added new models.
|
|
// Last Collected: Feb 23, 2024
|
|
|
|
import fs from "fs";
|
|
|
|
async function parseChatModels() {
|
|
const models = {};
|
|
const response = await fetch("https://openrouter.ai/api/v1/models");
|
|
const data = await response.json();
|
|
data.data.forEach((model) => {
|
|
models[model.id] = {
|
|
id: model.id,
|
|
name: model.name,
|
|
// capitalize first letter
|
|
organization:
|
|
model.id.split("/")[0].charAt(0).toUpperCase() +
|
|
model.id.split("/")[0].slice(1),
|
|
maxLength: model.context_length,
|
|
};
|
|
});
|
|
|
|
fs.writeFileSync(
|
|
"chat_models.json",
|
|
JSON.stringify(models, null, 2),
|
|
"utf-8"
|
|
);
|
|
return models;
|
|
}
|
|
|
|
parseChatModels();
|