Compare commits

...

7 Commits

Author SHA1 Message Date
timothycarambat
914a80e77b sort grouped models by org 2024-02-23 17:14:58 -08:00
shatfield4
9963edbe3e uppercase first letter of organization 2024-02-23 15:50:15 -08:00
shatfield4
9bd5bb9896 sort OpenRouter models by organization 2024-02-23 15:43:14 -08:00
timothycarambat
4713bfb3ee wait for first chunk to start timer 2024-02-23 14:28:48 -08:00
timothycarambat
912d8d142b update timeout comment 2024-02-23 14:19:37 -08:00
timothycarambat
8d9d6cc50f Fix hanging response stream with OpenRouter
update tagline
update comment
2024-02-23 14:17:51 -08:00
shatfield4
0222347b92 OpenRouter LLM support complete 2024-02-23 13:18:30 -08:00
11 changed files with 842 additions and 59 deletions

View File

@ -72,6 +72,7 @@ Some cool features of AnythingLLM
- [LocalAi (all models)](https://localai.io/)
- [Together AI (chat models)](https://www.together.ai/)
- [Perplexity (chat models)](https://www.perplexity.ai/)
- [OpenRouter (chat models)](https://openrouter.ai/)
- [Mistral](https://mistral.ai/)
**Supported Embedding models:**

View File

@ -25,20 +25,29 @@ export default function OpenRouterOptions({ settings }) {
}
function OpenRouterModelSelection({ settings }) {
const [customModels, setCustomModels] = useState([]);
const [groupedModels, setGroupedModels] = useState({});
const [loading, setLoading] = useState(true);
useEffect(() => {
async function findCustomModels() {
setLoading(true);
const { models } = await System.customModels("openrouter");
setCustomModels(models || []);
if (models?.length > 0) {
const modelsByOrganization = models.reduce((acc, model) => {
acc[model.organization] = acc[model.organization] || [];
acc[model.organization].push(model);
return acc;
}, {});
setGroupedModels(modelsByOrganization);
}
setLoading(false);
}
findCustomModels();
}, []);
if (loading || customModels.length == 0) {
if (loading || Object.keys(groupedModels).length === 0) {
return (
<div className="flex flex-col w-60">
<label className="text-white text-sm font-semibold block mb-4">
@ -67,21 +76,21 @@ function OpenRouterModelSelection({ settings }) {
required={true}
className="bg-zinc-900 border border-gray-500 text-white text-sm rounded-lg block w-full p-2.5"
>
{customModels.length > 0 && (
<optgroup label="Available OpenRouter Models">
{customModels.map((model) => {
return (
{Object.keys(groupedModels)
.sort()
.map((organization) => (
<optgroup key={organization} label={organization}>
{groupedModels[organization].map((model) => (
<option
key={model.id}
value={model.id}
selected={settings?.OpenRouterModelPref === model.id}
selected={settings.OpenRouterModelPref === model.id}
>
{model.id}
{model.name}
</option>
);
})}
</optgroup>
)}
))}
</optgroup>
))}
</select>
</div>
);

View File

@ -76,19 +76,21 @@ function TogetherAiModelSelection({ settings }) {
required={true}
className="bg-zinc-900 border border-gray-500 text-white text-sm rounded-lg block w-full p-2.5"
>
{Object.entries(groupedModels).map(([organization, models]) => (
<optgroup key={organization} label={organization}>
{models.map((model) => (
<option
key={model.id}
value={model.id}
selected={settings.TogetherAiModelPref === model.id}
>
{model.name}
</option>
))}
</optgroup>
))}
{Object.keys(groupedModels)
.sort()
.map((organization) => (
<optgroup key={organization} label={organization}>
{groupedModels[organization].map((model) => (
<option
key={model.id}
value={model.id}
selected={settings.OpenRouterModelPref === model.id}
>
{model.name}
</option>
))}
</optgroup>
))}
</select>
</div>
);

View File

@ -171,7 +171,7 @@ export default function GeneralLLMPreference() {
value: "openrouter",
logo: OpenRouterLogo,
options: <OpenRouterOptions settings={settings} />,
description: "Run any model from OpenRouter.",
description: "A unified interface for LLMs.",
},
{
name: "Native",

View File

@ -122,6 +122,7 @@ const LLM_SELECTION_PRIVACY = {
openrouter: {
name: "OpenRouter",
description: [
"Your chats will not be used for training",
"Your prompts and document text used in response creation are visible to OpenRouter",
],
logo: OpenRouterLogo,

View File

@ -145,7 +145,7 @@ export default function LLMPreference({
value: "openrouter",
logo: OpenRouterLogo,
options: <OpenRouterOptions settings={settings} />,
description: "Run any model from OpenRouter.",
description: "A unified interface for LLMs.",
},
{
name: "Native",

View File

@ -1,24 +1,11 @@
const { NativeEmbedder } = require("../../EmbeddingEngines/native");
const { chatPrompt } = require("../../chats");
const { handleDefaultStreamResponse } = require("../../helpers/chat/responses");
const { v4: uuidv4 } = require("uuid");
const { writeResponseChunk } = require("../../helpers/chat/responses");
async function openRouterModels() {
try {
const response = await fetch("https://openrouter.ai/api/v1/models");
const data = await response.json();
let MODELS = {};
data.data.forEach((model) => {
MODELS[model.id] = {
id: model.id,
name: model.name,
maxLength: model.context_length,
};
});
return MODELS;
} catch (e) {
console.error(e);
return {};
}
function openRouterModels() {
const { MODELS } = require("./models.js");
return MODELS || {};
}
class OpenRouterLLM {
@ -30,10 +17,11 @@ class OpenRouterLLM {
const config = new Configuration({
basePath: "https://openrouter.ai/api/v1",
apiKey: process.env.OPENROUTER_API_KEY,
// TODO: not working to update usage dashboard
defaultHeaders: {
"HTTP-Referer": "https://useanything.com",
"X-Title": "AnythingLLM",
baseOptions: {
headers: {
"HTTP-Referer": "https://useanything.com",
"X-Title": "AnythingLLM",
},
},
});
this.openai = new OpenAIApi(config);
@ -61,8 +49,8 @@ class OpenRouterLLM {
);
}
async allModelInformation() {
return await openRouterModels();
allModelInformation() {
return openRouterModels();
}
streamingEnabled() {
@ -70,15 +58,13 @@ class OpenRouterLLM {
}
promptWindowLimit() {
// TODO: get from openRouterModels()
// const availableModels = this.allModelInformation();
// return availableModels[this.model]?.maxLength || 4096;
return 4096;
const availableModels = this.allModelInformation();
return availableModels[this.model]?.maxLength || 4096;
}
async isValidChatCompletionModel(model = "") {
// TODO: get from openRouterModels()
return true;
const availableModels = this.allModelInformation();
return availableModels.hasOwnProperty(model);
}
constructPrompt({
@ -201,7 +187,130 @@ class OpenRouterLLM {
}
handleStream(response, stream, responseProps) {
return handleDefaultStreamResponse(response, stream, responseProps);
const timeoutThresholdMs = 500;
const { uuid = uuidv4(), sources = [] } = responseProps;
return new Promise((resolve) => {
let fullText = "";
let chunk = "";
let lastChunkTime = null; // null when first token is still not received.
// NOTICE: Not all OpenRouter models will return a stop reason
// which keeps the connection open and so the model never finalizes the stream
// like the traditional OpenAI response schema does. So in the case the response stream
// never reaches a formal close state we maintain an interval timer that if we go >=timeoutThresholdMs with
// no new chunks then we kill the stream and assume it to be complete. OpenRouter is quite fast
// so this threshold should permit most responses, but we can adjust `timeoutThresholdMs` if
// we find it is too aggressive.
const timeoutCheck = setInterval(() => {
if (lastChunkTime === null) return;
const now = Number(new Date());
const diffMs = now - lastChunkTime;
if (diffMs >= timeoutThresholdMs) {
console.log(
`OpenRouter stream did not self-close and has been stale for >${timeoutThresholdMs}ms. Closing response stream.`
);
writeResponseChunk(response, {
uuid,
sources,
type: "textResponseChunk",
textResponse: "",
close: true,
error: false,
});
clearInterval(timeoutCheck);
resolve(fullText);
}
}, 500);
stream.data.on("data", (data) => {
const lines = data
?.toString()
?.split("\n")
.filter((line) => line.trim() !== "");
for (const line of lines) {
let validJSON = false;
const message = chunk + line.replace(/^data: /, "");
// JSON chunk is incomplete and has not ended yet
// so we need to stitch it together. You would think JSON
// chunks would only come complete - but they don't!
try {
JSON.parse(message);
validJSON = true;
} catch {}
if (!validJSON) {
// It can be possible that the chunk decoding is running away
// and the message chunk fails to append due to string length.
// In this case abort the chunk and reset so we can continue.
// ref: https://github.com/Mintplex-Labs/anything-llm/issues/416
try {
chunk += message;
} catch (e) {
console.error(`Chunk appending error`, e);
chunk = "";
}
continue;
} else {
chunk = "";
}
if (message == "[DONE]") {
lastChunkTime = Number(new Date());
writeResponseChunk(response, {
uuid,
sources,
type: "textResponseChunk",
textResponse: "",
close: true,
error: false,
});
clearInterval(timeoutCheck);
resolve(fullText);
} else {
let finishReason = null;
let token = "";
try {
const json = JSON.parse(message);
token = json?.choices?.[0]?.delta?.content;
finishReason = json?.choices?.[0]?.finish_reason || null;
} catch {
continue;
}
if (token) {
fullText += token;
lastChunkTime = Number(new Date());
writeResponseChunk(response, {
uuid,
sources: [],
type: "textResponseChunk",
textResponse: token,
close: false,
error: false,
});
}
if (finishReason !== null) {
lastChunkTime = Number(new Date());
writeResponseChunk(response, {
uuid,
sources,
type: "textResponseChunk",
textResponse: "",
close: true,
error: false,
});
clearInterval(timeoutCheck);
resolve(fullText);
}
}
}
});
});
}
// Simple wrapper for dynamic embedder & normalize interface for all LLM implementations

View File

@ -0,0 +1,622 @@
const MODELS = {
"nousresearch/nous-capybara-34b": {
id: "nousresearch/nous-capybara-34b",
name: "Nous: Capybara 34B",
organization: "Nousresearch",
maxLength: 32768,
},
"openrouter/auto": {
id: "openrouter/auto",
name: "Auto (best for prompt)",
organization: "Openrouter",
maxLength: 128000,
},
"nousresearch/nous-capybara-7b:free": {
id: "nousresearch/nous-capybara-7b:free",
name: "Nous: Capybara 7B (free)",
organization: "Nousresearch",
maxLength: 4096,
},
"mistralai/mistral-7b-instruct:free": {
id: "mistralai/mistral-7b-instruct:free",
name: "Mistral 7B Instruct (free)",
organization: "Mistralai",
maxLength: 8192,
},
"gryphe/mythomist-7b:free": {
id: "gryphe/mythomist-7b:free",
name: "MythoMist 7B (free)",
organization: "Gryphe",
maxLength: 32768,
},
"undi95/toppy-m-7b:free": {
id: "undi95/toppy-m-7b:free",
name: "Toppy M 7B (free)",
organization: "Undi95",
maxLength: 4096,
},
"openrouter/cinematika-7b:free": {
id: "openrouter/cinematika-7b:free",
name: "Cinematika 7B (alpha) (free)",
organization: "Openrouter",
maxLength: 8000,
},
"google/gemma-7b-it:free": {
id: "google/gemma-7b-it:free",
name: "Google: Gemma 7B (free)",
organization: "Google",
maxLength: 8000,
},
"jondurbin/bagel-34b": {
id: "jondurbin/bagel-34b",
name: "Bagel 34B v0.2",
organization: "Jondurbin",
maxLength: 8000,
},
"jebcarter/psyfighter-13b": {
id: "jebcarter/psyfighter-13b",
name: "Psyfighter 13B",
organization: "Jebcarter",
maxLength: 4096,
},
"koboldai/psyfighter-13b-2": {
id: "koboldai/psyfighter-13b-2",
name: "Psyfighter v2 13B",
organization: "Koboldai",
maxLength: 4096,
},
"neversleep/noromaid-mixtral-8x7b-instruct": {
id: "neversleep/noromaid-mixtral-8x7b-instruct",
name: "Noromaid Mixtral 8x7B Instruct",
organization: "Neversleep",
maxLength: 8000,
},
"nousresearch/nous-hermes-llama2-13b": {
id: "nousresearch/nous-hermes-llama2-13b",
name: "Nous: Hermes 13B",
organization: "Nousresearch",
maxLength: 4096,
},
"meta-llama/codellama-34b-instruct": {
id: "meta-llama/codellama-34b-instruct",
name: "Meta: CodeLlama 34B Instruct",
organization: "Meta-llama",
maxLength: 8192,
},
"phind/phind-codellama-34b": {
id: "phind/phind-codellama-34b",
name: "Phind: CodeLlama 34B v2",
organization: "Phind",
maxLength: 4096,
},
"intel/neural-chat-7b": {
id: "intel/neural-chat-7b",
name: "Neural Chat 7B v3.1",
organization: "Intel",
maxLength: 4096,
},
"mistralai/mixtral-8x7b-instruct": {
id: "mistralai/mixtral-8x7b-instruct",
name: "Mistral: Mixtral 8x7B Instruct",
organization: "Mistralai",
maxLength: 32768,
},
"nousresearch/nous-hermes-2-mixtral-8x7b-dpo": {
id: "nousresearch/nous-hermes-2-mixtral-8x7b-dpo",
name: "Nous: Hermes 2 Mixtral 8x7B DPO",
organization: "Nousresearch",
maxLength: 32000,
},
"nousresearch/nous-hermes-2-mixtral-8x7b-sft": {
id: "nousresearch/nous-hermes-2-mixtral-8x7b-sft",
name: "Nous: Hermes 2 Mixtral 8x7B SFT",
organization: "Nousresearch",
maxLength: 32000,
},
"haotian-liu/llava-13b": {
id: "haotian-liu/llava-13b",
name: "Llava 13B",
organization: "Haotian-liu",
maxLength: 2048,
},
"nousresearch/nous-hermes-2-vision-7b": {
id: "nousresearch/nous-hermes-2-vision-7b",
name: "Nous: Hermes 2 Vision 7B (alpha)",
organization: "Nousresearch",
maxLength: 4096,
},
"meta-llama/llama-2-13b-chat": {
id: "meta-llama/llama-2-13b-chat",
name: "Meta: Llama v2 13B Chat",
organization: "Meta-llama",
maxLength: 4096,
},
"migtissera/synthia-70b": {
id: "migtissera/synthia-70b",
name: "Synthia 70B",
organization: "Migtissera",
maxLength: 8192,
},
"pygmalionai/mythalion-13b": {
id: "pygmalionai/mythalion-13b",
name: "Pygmalion: Mythalion 13B",
organization: "Pygmalionai",
maxLength: 8192,
},
"undi95/remm-slerp-l2-13b-6k": {
id: "undi95/remm-slerp-l2-13b-6k",
name: "ReMM SLERP 13B 6k",
organization: "Undi95",
maxLength: 6144,
},
"gryphe/mythomax-l2-13b": {
id: "gryphe/mythomax-l2-13b",
name: "MythoMax 13B",
organization: "Gryphe",
maxLength: 4096,
},
"xwin-lm/xwin-lm-70b": {
id: "xwin-lm/xwin-lm-70b",
name: "Xwin 70B",
organization: "Xwin-lm",
maxLength: 8192,
},
"gryphe/mythomax-l2-13b-8k": {
id: "gryphe/mythomax-l2-13b-8k",
name: "MythoMax 13B 8k",
organization: "Gryphe",
maxLength: 8192,
},
"alpindale/goliath-120b": {
id: "alpindale/goliath-120b",
name: "Goliath 120B",
organization: "Alpindale",
maxLength: 6144,
},
"neversleep/noromaid-20b": {
id: "neversleep/noromaid-20b",
name: "Noromaid 20B",
organization: "Neversleep",
maxLength: 8192,
},
"gryphe/mythomist-7b": {
id: "gryphe/mythomist-7b",
name: "MythoMist 7B",
organization: "Gryphe",
maxLength: 32768,
},
"mancer/weaver": {
id: "mancer/weaver",
name: "Mancer: Weaver (alpha)",
organization: "Mancer",
maxLength: 8000,
},
"nousresearch/nous-hermes-llama2-70b": {
id: "nousresearch/nous-hermes-llama2-70b",
name: "Nous: Hermes 70B",
organization: "Nousresearch",
maxLength: 4096,
},
"nousresearch/nous-capybara-7b": {
id: "nousresearch/nous-capybara-7b",
name: "Nous: Capybara 7B",
organization: "Nousresearch",
maxLength: 4096,
},
"codellama/codellama-70b-instruct": {
id: "codellama/codellama-70b-instruct",
name: "Meta: CodeLlama 70B Instruct",
organization: "Codellama",
maxLength: 2048,
},
"teknium/openhermes-2-mistral-7b": {
id: "teknium/openhermes-2-mistral-7b",
name: "OpenHermes 2 Mistral 7B",
organization: "Teknium",
maxLength: 4096,
},
"teknium/openhermes-2.5-mistral-7b": {
id: "teknium/openhermes-2.5-mistral-7b",
name: "OpenHermes 2.5 Mistral 7B",
organization: "Teknium",
maxLength: 4096,
},
"undi95/remm-slerp-l2-13b": {
id: "undi95/remm-slerp-l2-13b",
name: "ReMM SLERP 13B",
organization: "Undi95",
maxLength: 4096,
},
"undi95/toppy-m-7b": {
id: "undi95/toppy-m-7b",
name: "Toppy M 7B",
organization: "Undi95",
maxLength: 4096,
},
"openrouter/cinematika-7b": {
id: "openrouter/cinematika-7b",
name: "Cinematika 7B (alpha)",
organization: "Openrouter",
maxLength: 8000,
},
"01-ai/yi-34b-chat": {
id: "01-ai/yi-34b-chat",
name: "Yi 34B Chat",
organization: "01-ai",
maxLength: 4096,
},
"01-ai/yi-34b": {
id: "01-ai/yi-34b",
name: "Yi 34B (base)",
organization: "01-ai",
maxLength: 4096,
},
"01-ai/yi-6b": {
id: "01-ai/yi-6b",
name: "Yi 6B (base)",
organization: "01-ai",
maxLength: 4096,
},
"togethercomputer/stripedhyena-nous-7b": {
id: "togethercomputer/stripedhyena-nous-7b",
name: "StripedHyena Nous 7B",
organization: "Togethercomputer",
maxLength: 32768,
},
"togethercomputer/stripedhyena-hessian-7b": {
id: "togethercomputer/stripedhyena-hessian-7b",
name: "StripedHyena Hessian 7B (base)",
organization: "Togethercomputer",
maxLength: 32768,
},
"mistralai/mixtral-8x7b": {
id: "mistralai/mixtral-8x7b",
name: "Mistral: Mixtral 8x7B (base)",
organization: "Mistralai",
maxLength: 32768,
},
"nousresearch/nous-hermes-yi-34b": {
id: "nousresearch/nous-hermes-yi-34b",
name: "Nous: Hermes 2 Yi 34B",
organization: "Nousresearch",
maxLength: 4096,
},
"nousresearch/nous-hermes-2-mistral-7b-dpo": {
id: "nousresearch/nous-hermes-2-mistral-7b-dpo",
name: "Nous: Hermes 2 Mistral 7B DPO",
organization: "Nousresearch",
maxLength: 8192,
},
"open-orca/mistral-7b-openorca": {
id: "open-orca/mistral-7b-openorca",
name: "Mistral OpenOrca 7B",
organization: "Open-orca",
maxLength: 8192,
},
"huggingfaceh4/zephyr-7b-beta": {
id: "huggingfaceh4/zephyr-7b-beta",
name: "Hugging Face: Zephyr 7B",
organization: "Huggingfaceh4",
maxLength: 4096,
},
"openai/gpt-3.5-turbo": {
id: "openai/gpt-3.5-turbo",
name: "OpenAI: GPT-3.5 Turbo",
organization: "Openai",
maxLength: 4095,
},
"openai/gpt-3.5-turbo-0125": {
id: "openai/gpt-3.5-turbo-0125",
name: "OpenAI: GPT-3.5 Turbo 16k",
organization: "Openai",
maxLength: 16385,
},
"openai/gpt-3.5-turbo-1106": {
id: "openai/gpt-3.5-turbo-1106",
name: "OpenAI: GPT-3.5 Turbo 16k (older v1106)",
organization: "Openai",
maxLength: 16385,
},
"openai/gpt-3.5-turbo-0613": {
id: "openai/gpt-3.5-turbo-0613",
name: "OpenAI: GPT-3.5 Turbo (older v0613)",
organization: "Openai",
maxLength: 4095,
},
"openai/gpt-3.5-turbo-0301": {
id: "openai/gpt-3.5-turbo-0301",
name: "OpenAI: GPT-3.5 Turbo (older v0301)",
organization: "Openai",
maxLength: 4095,
},
"openai/gpt-3.5-turbo-16k": {
id: "openai/gpt-3.5-turbo-16k",
name: "OpenAI: GPT-3.5 Turbo 16k",
organization: "Openai",
maxLength: 16385,
},
"openai/gpt-4-turbo-preview": {
id: "openai/gpt-4-turbo-preview",
name: "OpenAI: GPT-4 Turbo (preview)",
organization: "Openai",
maxLength: 128000,
},
"openai/gpt-4-1106-preview": {
id: "openai/gpt-4-1106-preview",
name: "OpenAI: GPT-4 Turbo (older v1106)",
organization: "Openai",
maxLength: 128000,
},
"openai/gpt-4": {
id: "openai/gpt-4",
name: "OpenAI: GPT-4",
organization: "Openai",
maxLength: 8191,
},
"openai/gpt-4-0314": {
id: "openai/gpt-4-0314",
name: "OpenAI: GPT-4 (older v0314)",
organization: "Openai",
maxLength: 8191,
},
"openai/gpt-4-32k": {
id: "openai/gpt-4-32k",
name: "OpenAI: GPT-4 32k",
organization: "Openai",
maxLength: 32767,
},
"openai/gpt-4-32k-0314": {
id: "openai/gpt-4-32k-0314",
name: "OpenAI: GPT-4 32k (older v0314)",
organization: "Openai",
maxLength: 32767,
},
"openai/gpt-4-vision-preview": {
id: "openai/gpt-4-vision-preview",
name: "OpenAI: GPT-4 Vision (preview)",
organization: "Openai",
maxLength: 128000,
},
"openai/gpt-3.5-turbo-instruct": {
id: "openai/gpt-3.5-turbo-instruct",
name: "OpenAI: GPT-3.5 Turbo Instruct",
organization: "Openai",
maxLength: 4095,
},
"google/palm-2-chat-bison": {
id: "google/palm-2-chat-bison",
name: "Google: PaLM 2 Chat",
organization: "Google",
maxLength: 36864,
},
"google/palm-2-codechat-bison": {
id: "google/palm-2-codechat-bison",
name: "Google: PaLM 2 Code Chat",
organization: "Google",
maxLength: 28672,
},
"google/palm-2-chat-bison-32k": {
id: "google/palm-2-chat-bison-32k",
name: "Google: PaLM 2 Chat 32k",
organization: "Google",
maxLength: 131072,
},
"google/palm-2-codechat-bison-32k": {
id: "google/palm-2-codechat-bison-32k",
name: "Google: PaLM 2 Code Chat 32k",
organization: "Google",
maxLength: 131072,
},
"google/gemini-pro": {
id: "google/gemini-pro",
name: "Google: Gemini Pro (preview)",
organization: "Google",
maxLength: 131040,
},
"google/gemini-pro-vision": {
id: "google/gemini-pro-vision",
name: "Google: Gemini Pro Vision (preview)",
organization: "Google",
maxLength: 65536,
},
"perplexity/pplx-70b-online": {
id: "perplexity/pplx-70b-online",
name: "Perplexity: PPLX 70B Online",
organization: "Perplexity",
maxLength: 4096,
},
"perplexity/pplx-7b-online": {
id: "perplexity/pplx-7b-online",
name: "Perplexity: PPLX 7B Online",
organization: "Perplexity",
maxLength: 4096,
},
"perplexity/pplx-7b-chat": {
id: "perplexity/pplx-7b-chat",
name: "Perplexity: PPLX 7B Chat",
organization: "Perplexity",
maxLength: 8192,
},
"perplexity/pplx-70b-chat": {
id: "perplexity/pplx-70b-chat",
name: "Perplexity: PPLX 70B Chat",
organization: "Perplexity",
maxLength: 4096,
},
"meta-llama/llama-2-70b-chat": {
id: "meta-llama/llama-2-70b-chat",
name: "Meta: Llama v2 70B Chat",
organization: "Meta-llama",
maxLength: 4096,
},
"jondurbin/airoboros-l2-70b": {
id: "jondurbin/airoboros-l2-70b",
name: "Airoboros 70B",
organization: "Jondurbin",
maxLength: 4096,
},
"austism/chronos-hermes-13b": {
id: "austism/chronos-hermes-13b",
name: "Chronos Hermes 13B v2",
organization: "Austism",
maxLength: 4096,
},
"mistralai/mistral-7b-instruct": {
id: "mistralai/mistral-7b-instruct",
name: "Mistral 7B Instruct",
organization: "Mistralai",
maxLength: 8192,
},
"openchat/openchat-7b": {
id: "openchat/openchat-7b",
name: "OpenChat 3.5",
organization: "Openchat",
maxLength: 8192,
},
"lizpreciatior/lzlv-70b-fp16-hf": {
id: "lizpreciatior/lzlv-70b-fp16-hf",
name: "lzlv 70B",
organization: "Lizpreciatior",
maxLength: 4096,
},
"cognitivecomputations/dolphin-mixtral-8x7b": {
id: "cognitivecomputations/dolphin-mixtral-8x7b",
name: "Dolphin 2.6 Mixtral 8x7B 🐬",
organization: "Cognitivecomputations",
maxLength: 32000,
},
"rwkv/rwkv-5-world-3b": {
id: "rwkv/rwkv-5-world-3b",
name: "RWKV v5 World 3B",
organization: "Rwkv",
maxLength: 10000,
},
"recursal/rwkv-5-3b-ai-town": {
id: "recursal/rwkv-5-3b-ai-town",
name: "RWKV v5 3B AI Town",
organization: "Recursal",
maxLength: 10000,
},
"recursal/eagle-7b": {
id: "recursal/eagle-7b",
name: "RWKV v5: Eagle 7B",
organization: "Recursal",
maxLength: 10000,
},
"google/gemma-7b-it": {
id: "google/gemma-7b-it",
name: "Google: Gemma 7B",
organization: "Google",
maxLength: 8000,
},
"anthropic/claude-2": {
id: "anthropic/claude-2",
name: "Anthropic: Claude v2",
organization: "Anthropic",
maxLength: 200000,
},
"anthropic/claude-2.1": {
id: "anthropic/claude-2.1",
name: "Anthropic: Claude v2.1",
organization: "Anthropic",
maxLength: 200000,
},
"anthropic/claude-2.0": {
id: "anthropic/claude-2.0",
name: "Anthropic: Claude v2.0",
organization: "Anthropic",
maxLength: 100000,
},
"anthropic/claude-instant-1": {
id: "anthropic/claude-instant-1",
name: "Anthropic: Claude Instant v1",
organization: "Anthropic",
maxLength: 100000,
},
"anthropic/claude-instant-1.2": {
id: "anthropic/claude-instant-1.2",
name: "Anthropic: Claude Instant v1.2",
organization: "Anthropic",
maxLength: 100000,
},
"anthropic/claude-1": {
id: "anthropic/claude-1",
name: "Anthropic: Claude v1",
organization: "Anthropic",
maxLength: 100000,
},
"anthropic/claude-1.2": {
id: "anthropic/claude-1.2",
name: "Anthropic: Claude (older v1)",
organization: "Anthropic",
maxLength: 100000,
},
"anthropic/claude-instant-1.0": {
id: "anthropic/claude-instant-1.0",
name: "Anthropic: Claude Instant (older v1)",
organization: "Anthropic",
maxLength: 100000,
},
"anthropic/claude-instant-1.1": {
id: "anthropic/claude-instant-1.1",
name: "Anthropic: Claude Instant (older v1.1)",
organization: "Anthropic",
maxLength: 100000,
},
"anthropic/claude-2:beta": {
id: "anthropic/claude-2:beta",
name: "Anthropic: Claude v2 (experimental)",
organization: "Anthropic",
maxLength: 200000,
},
"anthropic/claude-2.1:beta": {
id: "anthropic/claude-2.1:beta",
name: "Anthropic: Claude v2.1 (experimental)",
organization: "Anthropic",
maxLength: 200000,
},
"anthropic/claude-2.0:beta": {
id: "anthropic/claude-2.0:beta",
name: "Anthropic: Claude v2.0 (experimental)",
organization: "Anthropic",
maxLength: 100000,
},
"anthropic/claude-instant-1:beta": {
id: "anthropic/claude-instant-1:beta",
name: "Anthropic: Claude Instant v1 (experimental)",
organization: "Anthropic",
maxLength: 100000,
},
"huggingfaceh4/zephyr-7b-beta:free": {
id: "huggingfaceh4/zephyr-7b-beta:free",
name: "Hugging Face: Zephyr 7B (free)",
organization: "Huggingfaceh4",
maxLength: 4096,
},
"openchat/openchat-7b:free": {
id: "openchat/openchat-7b:free",
name: "OpenChat 3.5 (free)",
organization: "Openchat",
maxLength: 8192,
},
"mistralai/mistral-tiny": {
id: "mistralai/mistral-tiny",
name: "Mistral: Tiny",
organization: "Mistralai",
maxLength: 32000,
},
"mistralai/mistral-small": {
id: "mistralai/mistral-small",
name: "Mistral: Small",
organization: "Mistralai",
maxLength: 32000,
},
"mistralai/mistral-medium": {
id: "mistralai/mistral-medium",
name: "Mistral: Medium",
organization: "Mistralai",
maxLength: 32000,
},
};
module.exports.MODELS = MODELS;

View File

@ -0,0 +1 @@
*.json

View File

@ -0,0 +1,37 @@
// 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();

View File

@ -150,6 +150,7 @@ async function getOpenRouterModels() {
const models = Object.values(knownModels).map((model) => {
return {
id: model.id,
organization: model.organization,
name: model.name,
};
});