Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] Add Openrouter v2 #148

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6a0370e
Merge remote-tracking branch 'upstream/main'
Oct 28, 2024
6a66cdd
Merge remote-tracking branch 'upstream/main'
Oct 28, 2024
134340a
Merge remote-tracking branch 'upstream/main'
charlwillia6 Oct 29, 2024
3f07de8
Merge remote-tracking branch 'upstream/main'
charlwillia6 Oct 30, 2024
8f7f236
Merge remote-tracking branch 'upstream/main'
charlwillia6 Oct 30, 2024
447600c
Merge remote-tracking branch 'upstream/main'
charlwillia6 Nov 1, 2024
02b8de3
Merge remote-tracking branch 'upstream/main'
charlwillia6 Nov 2, 2024
99f66ae
Merge remote-tracking branch 'upstream/main'
Nov 4, 2024
527e486
Merge remote-tracking branch 'upstream/main'
charlwillia6 Nov 7, 2024
a0e9d50
Merge remote-tracking branch 'upstream/main'
charlwillia6 Nov 8, 2024
b907905
Merge remote-tracking branch 'upstream/main'
charlwillia6 Nov 10, 2024
5690fd9
[FEAT] Add OpenRouter as a new model provider
charlwillia6 Nov 11, 2024
5b622d8
Merge remote-tracking branch 'upstream/main' into charlwillia6/add-op…
charlwillia6 Nov 11, 2024
44cbbd6
Changed button styles for disabled/enabled
charlwillia6 Nov 11, 2024
e6fc94e
Merge remote-tracking branch 'upstream/main' into charlwillia6/add-op…
charlwillia6 Nov 11, 2024
29edbea
Fixed URL to OpenRouter
charlwillia6 Nov 11, 2024
72dde31
Fixed button styling to match theme
charlwillia6 Nov 11, 2024
55b840b
Added error handling / removed disable/enable of submit button
charlwillia6 Nov 11, 2024
8539aec
Merge remote-tracking branch 'upstream/main' into charlwillia6/add-op…
charlwillia6 Nov 12, 2024
d190726
Fixed issue with mistyped variable
charlwillia6 Nov 12, 2024
cb9a338
Optimized for OpenRouter implementation
charlwillia6 Nov 12, 2024
dbc7a94
Merge remote-tracking branch 'upstream/main' into charlwillia6/add-op…
charlwillia6 Nov 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ type ModelProvider =
| "openai-aiohttp"
| "msty"
| "watsonx"
| "openrouter"
| "pearai_server"
| "aider"
| "perplexity"
Expand Down
1 change: 1 addition & 0 deletions core/llm/autodetect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const PROVIDER_SUPPORTS_IMAGES: ModelProvider[] = [
"bedrock",
"continue-proxy",
"pearai_server",
"openrouter",
];

const MODEL_SUPPORTS_IMAGES: string[] = [
Expand Down
17 changes: 17 additions & 0 deletions core/llm/llms/OpenRouter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { LLMOptions, ModelProvider } from "../../index.js";
import { osModelsEditPrompt } from "../templates/edit.js";
import OpenAI from "./OpenAI.js";

class OpenRouter extends OpenAI {
static providerName: ModelProvider = "openrouter";
static defaultOptions: Partial<LLMOptions> = {
apiBase: "https://openrouter.ai/api/v1/",
model: "",
promptTemplates: {
edit: osModelsEditPrompt,
},
useLegacyCompletionsEndpoint: false,
};
}

export default OpenRouter;
4 changes: 3 additions & 1 deletion core/llm/llms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import Mistral from "./Mistral.js";
import Msty from "./Msty.js";
import Ollama from "./Ollama.js";
import OpenAI from "./OpenAI.js";
import OpenRouter from "./OpenRouter.js";
import Replicate from "./Replicate.js";
import TextGenWebUI from "./TextGenWebUI.js";
import Together from "./Together.js";
Expand Down Expand Up @@ -134,6 +135,7 @@ const LLMs = [
WatsonX,
PearAIServer,
Aider,
OpenRouter,
];

export async function llmFromDescription(
Expand Down Expand Up @@ -206,4 +208,4 @@ export function llmFromProviderAndOptions(
}

return new cls(llmOptions);
}
}
6 changes: 4 additions & 2 deletions docs/static/schemas/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@
"msty",
"watsonx",
"pearai_server",
"aider"
"aider",
"openrouter"
],
"markdownEnumDescriptions": [
"### OpenAI\nUse gpt-4, gpt-3.5-turbo, or any other OpenAI model. See [here](https://openai.com/product#made-for-developers) to obtain an API key.\n\n> [Reference](https://trypear.ai/reference/Model%20Providers/openai)",
Expand All @@ -215,7 +216,8 @@
"### Deepseek\n Deepseek's API provides the best pricing for their state-of-the-art Deepseek Coder models. To get started, obtain an API key from [their console](https://platform.deepseek.com/api_keys)",
"### Azure OpenAI\n Azure OpenAI lets you securely run OpenAI's models on Azure. To get started, follow the steps [here](https://trypear.ai/reference/Model%20Providers/azure)",
"### Msty\nMsty is the simplest way to get started with online or local LLMs on all desktop platforms - Windows, Mac, and Linux. No fussing around, one-click and you are up and running. To get started, follow these steps:\n1. Download from [Msty.app](https://msty.app/), open the application, and click 'Setup Local AI'.\n2. Go to the Local AI Module page and download a model of your choice.\n3. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://pearai.dev/docs/reference/Model%20Providers/Msty)",
"### WatsonX\nWatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks."
"### WatsonX\nWatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks.",
"### OpenRouter\nOpenRouter offers a single API to access almost any language model. To get started, obtain an API key from [their console](https://openrouter.ai/settings/keys)."
],
"type": "string"
},
Expand Down
6 changes: 4 additions & 2 deletions extensions/intellij/src/main/resources/config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@
"msty",
"watsonx",
"pearai_server",
"aider"
"aider",
"openrouter"
],
"markdownEnumDescriptions": [
"### OpenAI\nUse gpt-4, gpt-3.5-turbo, or any other OpenAI model. See [here](https://openai.com/product#made-for-developers) to obtain an API key.\n\n> [Reference](https://trypear.ai/reference/Model%20Providers/openai)",
Expand All @@ -215,7 +216,8 @@
"### Deepseek\n Deepseek's API provides the best pricing for their state-of-the-art Deepseek Coder models. To get started, obtain an API key from [their console](https://platform.deepseek.com/api_keys)",
"### Azure OpenAI\n Azure OpenAI lets you securely run OpenAI's models on Azure. To get started, follow the steps [here](https://trypear.ai/reference/Model%20Providers/azure)",
"### Msty\nMsty is the simplest way to get started with online or local LLMs on all desktop platforms - Windows, Mac, and Linux. No fussing around, one-click and you are up and running. To get started, follow these steps:\n1. Download from [Msty.app](https://msty.app/), open the application, and click 'Setup Local AI'.\n2. Go to the Local AI Module page and download a model of your choice.\n3. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://pearai.dev/docs/reference/Model%20Providers/Msty)",
"### WatsonX\nWatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks."
"### WatsonX\nWatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks.",
"### OpenRouter\nOpenRouter offers a single API to access almost any language model. To get started, obtain an API key from [their console](https://openrouter.ai/settings/keys)."
],
"type": "string"
},
Expand Down
6 changes: 4 additions & 2 deletions extensions/vscode/config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@
"msty",
"watsonx",
"pearai_server",
"aider"
"aider",
"openrouter"
],
"markdownEnumDescriptions": [
"### OpenAI\nUse gpt-4, gpt-3.5-turbo, or any other OpenAI model. See [here](https://openai.com/product#made-for-developers) to obtain an API key.\n\n> [Reference](https://trypear.ai/reference/Model%20Providers/openai)",
Expand All @@ -215,7 +216,8 @@
"### Deepseek\n Deepseek's API provides the best pricing for their state-of-the-art Deepseek Coder models. To get started, obtain an API key from [their console](https://platform.deepseek.com/api_keys)",
"### Azure OpenAI\n Azure OpenAI lets you securely run OpenAI's models on Azure. To get started, follow the steps [here](https://trypear.ai/reference/Model%20Providers/azure)",
"### Msty\nMsty is the simplest way to get started with online or local LLMs on all desktop platforms - Windows, Mac, and Linux. No fussing around, one-click and you are up and running. To get started, follow these steps:\n1. Download from [Msty.app](https://msty.app/), open the application, and click 'Setup Local AI'.\n2. Go to the Local AI Module page and download a model of your choice.\n3. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://pearai.dev/docs/reference/Model%20Providers/Msty)",
"### WatsonX\nWatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks."
"### WatsonX\nWatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks.",
"### OpenRouter\nOpenRouter offers a single API to access almost any language model. To get started, obtain an API key from [their console](https://openrouter.ai/settings/keys)."
],
"type": "string"
},
Expand Down
6 changes: 4 additions & 2 deletions extensions/vscode/continue_rc_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@
"msty",
"watsonx",
"pearai_server",
"aider"
"aider",
"openrouter"
],
"markdownEnumDescriptions": [
"### OpenAI\nUse gpt-4, gpt-3.5-turbo, or any other OpenAI model. See [here](https://openai.com/product#made-for-developers) to obtain an API key.\n\n> [Reference](https://trypear.ai/reference/Model%20Providers/openai)",
Expand All @@ -218,7 +219,8 @@
"### Deepseek\n Deepseek's API provides the best pricing for their state-of-the-art Deepseek Coder models. To get started, obtain an API key from [their console](https://platform.deepseek.com/api_keys)",
"### Azure OpenAI\n Azure OpenAI lets you securely run OpenAI's models on Azure. To get started, follow the steps [here](https://trypear.ai/reference/Model%20Providers/azure)",
"### Msty\nMsty is the simplest way to get started with online or local LLMs on all desktop platforms - Windows, Mac, and Linux. No fussing around, one-click and you are up and running. To get started, follow these steps:\n1. Download from [Msty.app](https://msty.app/), open the application, and click 'Setup Local AI'.\n2. Go to the Local AI Module page and download a model of your choice.\n3. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://pearai.dev/docs/reference/Model%20Providers/Msty)",
"### WatsonX\nWatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks."
"### WatsonX\nWatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks.",
"### OpenRouter\nOpenRouter offers a single API to access almost any language model. To get started, obtain an API key from [their console](https://openrouter.ai/settings/keys)."
],
"type": "string"
},
Expand Down
Binary file added gui/public/logos/open-router.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading