2024-09-04 03:07:46 +00:00
|
|
|
export const PROVIDERS = [
|
|
|
|
|
"cohere",
|
|
|
|
|
"textsynth",
|
|
|
|
|
"openai-compat",
|
|
|
|
|
"openai",
|
|
|
|
|
"openai-chat",
|
|
|
|
|
"azure",
|
|
|
|
|
"azure-chat",
|
|
|
|
|
"anthropic",
|
|
|
|
|
"openrouter",
|
|
|
|
|
];
|
2023-07-01 03:58:09 +00:00
|
|
|
export type Provider = (typeof PROVIDERS)[number];
|
|
|
|
|
|
2023-11-20 09:03:24 +00:00
|
|
|
type ProviderProps = {
|
2024-09-04 03:07:46 +00:00
|
|
|
openai: { organization: string };
|
2023-11-20 09:03:24 +00:00
|
|
|
"openai-chat": { organization: string };
|
2024-09-04 03:07:46 +00:00
|
|
|
"openai-compat": { url: string };
|
|
|
|
|
azure: { url: string };
|
2023-11-20 09:03:24 +00:00
|
|
|
"azure-chat": { url: string };
|
2024-09-04 03:07:46 +00:00
|
|
|
anthropic: { url: string };
|
|
|
|
|
openrouter: { quantization: string };
|
2023-11-20 09:03:24 +00:00
|
|
|
};
|
2023-07-01 03:58:09 +00:00
|
|
|
|
2023-11-20 09:03:24 +00:00
|
|
|
type SharedPresetSettings = {
|
|
|
|
|
name: string;
|
2023-07-01 03:58:09 +00:00
|
|
|
|
2023-11-20 09:03:24 +00:00
|
|
|
model: string;
|
|
|
|
|
contextLength: number;
|
|
|
|
|
apiKey: string;
|
|
|
|
|
};
|
2023-07-01 03:58:09 +00:00
|
|
|
|
2024-09-04 03:07:46 +00:00
|
|
|
export type ModelPreset<P extends Provider> = SharedPresetSettings &
|
|
|
|
|
(P extends keyof ProviderProps ? ProviderProps[P] : {}) & { provider: P };
|
2023-07-01 03:58:09 +00:00
|
|
|
|
2023-11-20 09:03:24 +00:00
|
|
|
export interface LoomSettings {
|
2023-07-03 06:34:18 +00:00
|
|
|
passageFolder: string;
|
|
|
|
|
defaultPassageSeparator: string;
|
|
|
|
|
defaultPassageFrontmatter: string;
|
|
|
|
|
|
2024-05-05 22:26:03 +00:00
|
|
|
logApiCalls: boolean;
|
|
|
|
|
|
2023-11-20 09:03:24 +00:00
|
|
|
modelPresets: ModelPreset<Provider>[];
|
|
|
|
|
modelPreset: number;
|
|
|
|
|
|
2023-11-21 03:15:55 +00:00
|
|
|
visibility: Record<string, boolean>;
|
2023-07-01 03:58:09 +00:00
|
|
|
maxTokens: number;
|
|
|
|
|
temperature: number;
|
|
|
|
|
topP: number;
|
|
|
|
|
frequencyPenalty: number;
|
|
|
|
|
presencePenalty: number;
|
2023-11-06 21:02:16 +00:00
|
|
|
prepend: string;
|
2023-11-05 04:54:44 +00:00
|
|
|
bestOf: number;
|
2023-07-01 03:58:09 +00:00
|
|
|
n: number;
|
2024-05-05 22:26:03 +00:00
|
|
|
systemPrompt: string;
|
|
|
|
|
userMessage: string;
|
2023-07-01 03:58:09 +00:00
|
|
|
|
|
|
|
|
showSettings: boolean;
|
2023-07-15 23:36:34 +00:00
|
|
|
showSearchBar: boolean;
|
2023-07-01 03:58:09 +00:00
|
|
|
showNodeBorders: boolean;
|
|
|
|
|
showExport: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-04 03:07:46 +00:00
|
|
|
export const getPreset = (settings: LoomSettings) =>
|
|
|
|
|
settings.modelPresets[settings.modelPreset];
|
2023-11-20 09:03:24 +00:00
|
|
|
|
2023-07-15 23:36:34 +00:00
|
|
|
export type SearchResultState = "result" | "ancestor" | "none" | null;
|
|
|
|
|
|
2023-07-01 03:58:09 +00:00
|
|
|
export interface Node {
|
|
|
|
|
text: string;
|
|
|
|
|
parentId: string | null;
|
|
|
|
|
collapsed: boolean;
|
|
|
|
|
unread: boolean;
|
|
|
|
|
bookmarked: boolean;
|
|
|
|
|
lastVisited?: number;
|
2023-07-15 23:36:34 +00:00
|
|
|
searchResultState: SearchResultState;
|
2023-07-01 03:58:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface NoteState {
|
|
|
|
|
current: string;
|
|
|
|
|
hoisted: string[];
|
2023-07-15 23:36:34 +00:00
|
|
|
searchTerm: string;
|
2023-07-01 03:58:09 +00:00
|
|
|
nodes: Record<string, Node>;
|
|
|
|
|
generating: string | null;
|
|
|
|
|
}
|