forked from cosmicoptima/loom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.ts
84 lines (71 loc) · 1.8 KB
/
common.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
export const PROVIDERS = [
"cohere",
"textsynth",
"openai-compat",
"openai",
"openai-chat",
"azure",
"azure-chat",
"anthropic",
"openrouter",
];
export type Provider = (typeof PROVIDERS)[number];
type ProviderProps = {
openai: { organization: string };
"openai-chat": { organization: string };
"openai-compat": { url: string };
azure: { url: string };
"azure-chat": { url: string };
anthropic: { url: string };
openrouter: { quantization: string };
};
type SharedPresetSettings = {
name: string;
model: string;
contextLength: number;
apiKey: string;
};
export type ModelPreset<P extends Provider> = SharedPresetSettings &
(P extends keyof ProviderProps ? ProviderProps[P] : {}) & { provider: P };
export interface LoomSettings {
passageFolder: string;
defaultPassageSeparator: string;
defaultPassageFrontmatter: string;
logApiCalls: boolean;
modelPresets: ModelPreset<Provider>[];
modelPreset: number;
visibility: Record<string, boolean>;
maxTokens: number;
temperature: number;
topP: number;
frequencyPenalty: number;
presencePenalty: number;
prepend: string;
bestOf: number;
n: number;
systemPrompt: string;
userMessage: string;
showSettings: boolean;
showSearchBar: boolean;
showNodeBorders: boolean;
showExport: boolean;
}
export const getPreset = (settings: LoomSettings) =>
settings.modelPresets[settings.modelPreset];
export type SearchResultState = "result" | "ancestor" | "none" | null;
export interface Node {
text: string;
parentId: string | null;
collapsed: boolean;
unread: boolean;
bookmarked: boolean;
lastVisited?: number;
searchResultState: SearchResultState;
}
export interface NoteState {
current: string;
hoisted: string[];
searchTerm: string;
nodes: Record<string, Node>;
generating: string | null;
}