mirror of
https://github.com/logancyang/obsidian-copilot.git
synced 2026-07-22 07:50:24 +00:00
Add support for Cohere's Command-R and Command-R+ models (#619)
This commit is contained in:
parent
9c770a47f3
commit
c6fbe77fe5
6 changed files with 2351 additions and 14 deletions
|
|
@ -34,7 +34,7 @@ const context = await esbuild.context({
|
|||
"@lezer/lr",
|
||||
],
|
||||
format: "cjs",
|
||||
target: "es2018",
|
||||
target: "es2020",
|
||||
logLevel: "info",
|
||||
sourcemap: prod ? false : "inline",
|
||||
treeShaking: true,
|
||||
|
|
|
|||
2334
package-lock.json
generated
2334
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -64,14 +64,14 @@
|
|||
"@huggingface/inference": "^2.6.4",
|
||||
"@koa/cors": "^5.0.0",
|
||||
"@langchain/anthropic": "^0.1.21",
|
||||
"@langchain/cohere": "^0.0.2",
|
||||
"@langchain/cohere": "^0.0.11",
|
||||
"@langchain/community": "^0.0.16",
|
||||
"@langchain/google-genai": "^0.0.7",
|
||||
"@langchain/groq": "^0.0.9",
|
||||
"@tabler/icons-react": "^2.14.0",
|
||||
"@types/pouchdb": "^6.4.0",
|
||||
"axios": "^1.3.4",
|
||||
"cohere-ai": "^7.6.2",
|
||||
"cohere-ai": "^7.13.0",
|
||||
"crypto-js": "^4.1.1",
|
||||
"esbuild-plugin-svg": "^0.1.0",
|
||||
"esbuild-plugins-node-modules-polyfill": "^1.6.5",
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { CustomModel, LangChainParams, ModelConfig } from "@/aiParams";
|
|||
import { BUILTIN_CHAT_MODELS, ChatModelProviders } from "@/constants";
|
||||
import EncryptionService from "@/encryptionService";
|
||||
import { ChatAnthropicWrapped, ProxyChatOpenAI } from "@/langchainWrappers";
|
||||
import { ChatCohere } from "@langchain/cohere";
|
||||
import { ChatGoogleGenerativeAI } from "@langchain/google-genai";
|
||||
import { ChatGroq } from "@langchain/groq";
|
||||
import { ChatOllama } from "@langchain/ollama";
|
||||
|
|
@ -78,6 +79,10 @@ export default class ChatModelManager {
|
|||
azureOpenAIApiDeploymentName: params.azureOpenAIApiDeploymentName,
|
||||
azureOpenAIApiVersion: params.azureOpenAIApiVersion,
|
||||
},
|
||||
[ChatModelProviders.COHEREAI]: {
|
||||
apiKey: decrypt(customModel.apiKey || params.cohereApiKey),
|
||||
model: customModel.name,
|
||||
},
|
||||
[ChatModelProviders.GOOGLE]: {
|
||||
apiKey: decrypt(customModel.apiKey || params.googleApiKey),
|
||||
modelName: customModel.name,
|
||||
|
|
@ -146,6 +151,10 @@ export default class ChatModelManager {
|
|||
constructor = ChatAnthropicWrapped;
|
||||
apiKey = model.apiKey || this.getLangChainParams().anthropicApiKey;
|
||||
break;
|
||||
case ChatModelProviders.COHEREAI:
|
||||
constructor = ChatCohere;
|
||||
apiKey = model.apiKey || this.getLangChainParams().cohereApiKey;
|
||||
break;
|
||||
case ChatModelProviders.OPENROUTERAI:
|
||||
constructor = ProxyChatOpenAI;
|
||||
apiKey = model.apiKey || this.getLangChainParams().openRouterAiApiKey;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ export interface ModelConfig {
|
|||
openAIApiKey?: string;
|
||||
openAIOrgId?: string;
|
||||
anthropicApiKey?: string;
|
||||
cohereApiKey?: string;
|
||||
azureOpenAIApiKey?: string;
|
||||
azureOpenAIApiInstanceName?: string;
|
||||
azureOpenAIApiDeploymentName?: string;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ export enum ChatModels {
|
|||
AZURE_OPENAI = "azure-openai",
|
||||
CLAUDE_3_5_SONNET = "claude-3-5-sonnet-20240620",
|
||||
CLAUDE_3_HAIKU = "claude-3-haiku-20240307",
|
||||
COMMAND_R = "command-r",
|
||||
COMMAND_R_PLUS = "command-r-plus",
|
||||
}
|
||||
|
||||
// Model Providers
|
||||
|
|
@ -23,6 +25,7 @@ export enum ChatModelProviders {
|
|||
OPENAI = "openai",
|
||||
AZURE_OPENAI = "azure openai",
|
||||
ANTHROPIC = "anthropic",
|
||||
COHEREAI = "cohereai",
|
||||
GOOGLE = "google",
|
||||
OPENROUTERAI = "openrouterai",
|
||||
GROQ = "groq",
|
||||
|
|
@ -62,6 +65,18 @@ export const BUILTIN_CHAT_MODELS: CustomModel[] = [
|
|||
enabled: true,
|
||||
isBuiltIn: true,
|
||||
},
|
||||
{
|
||||
name: ChatModels.COMMAND_R,
|
||||
provider: ChatModelProviders.COHEREAI,
|
||||
enabled: true,
|
||||
isBuiltIn: true,
|
||||
},
|
||||
{
|
||||
name: ChatModels.COMMAND_R_PLUS,
|
||||
provider: ChatModelProviders.COHEREAI,
|
||||
enabled: true,
|
||||
isBuiltIn: true,
|
||||
},
|
||||
{
|
||||
name: ChatModels.GEMINI_PRO,
|
||||
provider: ChatModelProviders.GOOGLE,
|
||||
|
|
|
|||
Loading…
Reference in a new issue