generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #654 from chhoumann/feature/local-llms
- Loading branch information
Showing
18 changed files
with
638 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
export interface AIProvider { | ||
name: string; | ||
endpoint: string; | ||
apiKey: string; | ||
models: Model[]; | ||
} | ||
|
||
export interface Model { | ||
name: string; | ||
maxTokens: number; | ||
} | ||
|
||
const OpenAIProvider: AIProvider = { | ||
name: "OpenAI", | ||
endpoint: "https://api.openai.com/v1", | ||
apiKey: "", | ||
models: [ | ||
{ | ||
name: "gpt-3.5-turbo", | ||
maxTokens: 4096, | ||
}, | ||
{ | ||
name: "gpt-3.5-turbo-16k", | ||
maxTokens: 16384, | ||
}, | ||
{ | ||
name: "gpt-3.5-turbo-1106", | ||
maxTokens: 16385, | ||
}, | ||
{ | ||
name: "gpt-4", | ||
maxTokens: 8192, | ||
}, | ||
{ | ||
name: "gpt-4-32k", | ||
maxTokens: 32768, | ||
}, | ||
{ | ||
name: "gpt-4-1106-preview", | ||
maxTokens: 128000, | ||
}, | ||
{ | ||
name: "text-davinci-003", | ||
maxTokens: 4096, | ||
}, | ||
], | ||
}; | ||
|
||
|
||
export const DefaultProviders: AIProvider[] = [ | ||
OpenAIProvider, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { settingsStore } from "src/settingsStore"; | ||
|
||
export function getModelNames() { | ||
const aiSettings = settingsStore.getState().ai; | ||
|
||
return aiSettings.providers | ||
.flatMap((provider) => provider.models) | ||
.map((model) => model.name); | ||
} | ||
|
||
export function getModelByName(model: string) { | ||
const aiSettings = settingsStore.getState().ai; | ||
|
||
return aiSettings.providers | ||
.flatMap((provider) => provider.models) | ||
.find((m) => m.name === model); | ||
} | ||
|
||
export function getModelMaxTokens(model: string) { | ||
const aiSettings = settingsStore.getState().ai; | ||
|
||
const modelData = aiSettings.providers | ||
.flatMap((provider) => provider.models) | ||
.find((m) => m.name === model); | ||
|
||
if (modelData) { | ||
return modelData.maxTokens; | ||
} | ||
|
||
throw new Error(`Model ${model} not found with any provider.`); | ||
} | ||
|
||
export function getModelProvider(modelName: string) { | ||
const aiSettings = settingsStore.getState().ai; | ||
|
||
return aiSettings.providers.find((provider) => | ||
provider.models.some((m) => m.name === modelName) | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.