Elffuss BraidHub

kikocis/continue public

9df0fa5d79c7 · 7.0 KiBRawPermalink
1import { z } from "zod";
2
3export const completionOptionsSchema = z.object({
4 temperature: z.number().optional(),
5 topP: z.number().optional(),
6 topK: z.number().optional(),
7 minP: z.number().optional(),
8 presencePenalty: z.number().optional(),
9 frequencyPenalty: z.number().optional(),
10 mirostat: z.number().optional(),
11 stop: z.array(z.string()).optional(),
12 maxTokens: z.number().optional(),
13 numThreads: z.number().optional(),
14 useMmap: z.boolean().optional(),
15 keepAlive: z.number().optional(),
16 numGpu: z.number().optional(),
17 raw: z.boolean().optional(),
18 stream: z.boolean().optional(),
19});
20export type CompletionOptions = z.infer<typeof completionOptionsSchema>;
21
22export const clientCertificateOptionsSchema = z.object({
23 cert: z.string(),
24 key: z.string(),
25 passphrase: z.string().optional(),
26});
27export type ClientCertificateOptions = z.infer<
28 typeof clientCertificateOptionsSchema
29>;
30
31export const requestOptionsSchema = z.object({
32 timeout: z.number().optional(),
33 verifySsl: z.boolean().optional(),
34 caBundlePath: z.union([z.string(), z.array(z.string())]).optional(),
35 proxy: z.string().optional(),
36 headers: z.record(z.string()).optional(),
37 extraBodyProperties: z.record(z.any()).optional(),
38 noProxy: z.array(z.string()).optional(),
39 clientCertificate: clientCertificateOptionsSchema.optional(),
40});
41export type RequestOptions = z.infer<typeof requestOptionsSchema>;
42
43export const modelDescriptionSchema = z.object({
44 title: z.string(),
45 provider: z.enum([
46 "openai",
47 "anthropic",
48 "cohere",
49 "ollama",
50 "huggingface-tgi",
51 "huggingface-inference-api",
52 "replicate",
53 "gemini",
54 "mistral",
55 "bedrock",
56 "sagemaker",
57 "cloudflare",
58 "azure",
59 "ovhcloud",
60 "continue-proxy",
61 "nebius",
62 "scaleway",
63 "watsonx",
64 ]),
65 model: z.string(),
66 apiKey: z.string().optional(),
67 apiBase: z.string().optional(),
68 contextLength: z.number().optional(),
69 template: z
70 .enum([
71 "llama2",
72 "alpaca",
73 "zephyr",
74 "phi2",
75 "phind",
76 "anthropic",
77 "chatml",
78 "none",
79 "openchat",
80 "deepseek",
81 "xwin-coder",
82 "neural-chat",
83 "codellama-70b",
84 "llava",
85 "gemma",
86 "llama3",
87 ])
88 .optional(),
89 completionOptions: completionOptionsSchema.optional(),
90 systemMessage: z.string().optional(),
91 requestOptions: z
92 .object({
93 timeout: z.number().optional(),
94 verifySsl: z.boolean().optional(),
95 caBundlePath: z.union([z.string(), z.array(z.string())]).optional(),
96 proxy: z.string().optional(),
97 headers: z.record(z.string()).optional(),
98 extraBodyProperties: z.record(z.any()).optional(),
99 noProxy: z.array(z.string()).optional(),
100 })
101 .optional(),
102 promptTemplates: z.record(z.string()).optional(),
103});
104export type ModelDescription = z.infer<typeof modelDescriptionSchema>;
105
106export const embeddingsProviderSchema = z.object({
107 provider: z.enum([
108 "transformers.js",
109 "ollama",
110 "openai",
111 "cohere",
112 "gemini",
113 "ovhcloud",
114 "continue-proxy",
115 "nebius",
116 "scaleway",
117 "watsonx",
118 ]),
119 apiBase: z.string().optional(),
120 apiKey: z.string().optional(),
121 model: z.string().optional(),
122 deployment: z.string().optional(),
123 apiType: z.string().optional(),
124 apiVersion: z.string().optional(),
125 requestOptions: requestOptionsSchema.optional(),
126});
127export type EmbeddingsProvider = z.infer<typeof embeddingsProviderSchema>;
128
129export const uiOptionsSchema = z.object({
130 codeBlockToolbarPosition: z.enum(["top", "bottom"]).optional(),
131 fontSize: z.number().optional(),
132 displayRawMarkdown: z.boolean().optional(),
133 showChatScrollbar: z.boolean().optional(),
134 codeWrap: z.boolean().optional(),
135});
136export type UiOptions = z.infer<typeof uiOptionsSchema>;
137
138export const tabAutocompleteOptionsSchema = z.object({
139 disable: z.boolean(),
140 maxPromptTokens: z.number(),
141 debounceDelay: z.number(),
142 maxSuffixPercentage: z.number(),
143 prefixPercentage: z.number(),
144 transform: z.boolean().optional(),
145 template: z.string().optional(),
146 multilineCompletions: z.enum(["always", "never", "auto"]),
147 slidingWindowPrefixPercentage: z.number(),
148 slidingWindowSize: z.number(),
149 useCache: z.boolean(),
150 onlyMyCode: z.boolean(),
151 useRecentlyEdited: z.boolean(),
152 disableInFiles: z.array(z.string()).optional(),
153 useImports: z.boolean().optional(),
154});
155export type TabAutocompleteOptions = z.infer<
156 typeof tabAutocompleteOptionsSchema
157>;
158
159export const slashCommandSchema = z.object({
160 name: z.string(),
161 description: z.string(),
162 params: z.record(z.any()).optional(),
163});
164export type SlashCommand = z.infer<typeof slashCommandSchema>;
165
166export const customCommandSchema = z.object({
167 name: z.string(),
168 description: z.string(),
169 params: z.record(z.any()).optional(),
170});
171export type CustomCommand = z.infer<typeof customCommandSchema>;
172
173export const contextProviderSchema = z.object({
174 name: z.string(),
175 params: z.record(z.string(), z.any()),
176});
177export type ContextProvider = z.infer<typeof contextProviderSchema>;
178
179export const rerankerSchema = z.object({
180 name: z.enum(["cohere", "voyage", "watsonx", "llm", "continue-proxy"]),
181 params: z.record(z.any()).optional(),
182});
183export type Reranker = z.infer<typeof rerankerSchema>;
184
185export const analyticsSchema = z.object({
186 provider: z.enum([
187 "posthog",
188 "amplitude",
189 "segment",
190 "logstash",
191 "mixpanel",
192 "splunk",
193 "datadog",
194 "continue-proxy",
195 ]),
196 url: z.string().optional(),
197 clientKey: z.string().optional(),
198});
199export type Analytics = z.infer<typeof analyticsSchema>;
200
201export const devDataSchema = z.object({
202 url: z.string().optional(),
203});
204export type DevData = z.infer<typeof devDataSchema>;
205
206export const siteIndexingConfigSchema = z.object({
207 startUrl: z.string(),
208 // rootUrl: z.string(),
209 title: z.string(),
210 maxDepth: z.number().optional(),
211 faviconUrl: z.string().optional(),
212 useLocalCrawling: z.boolean().optional(),
213});
214
215export const controlPlaneConfigSchema = z.object({
216 useContinueForTeamsProxy: z.boolean().optional(),
217 proxyUrl: z.string().optional(),
218});
219
220export const configJsonSchema = z.object({
221 models: z.array(modelDescriptionSchema),
222 tabAutocompleteModel: modelDescriptionSchema.optional(),
223 embeddingsProvider: embeddingsProviderSchema.optional(),
224 reranker: rerankerSchema.optional(),
225 analytics: analyticsSchema,
226 devData: devDataSchema,
227 allowAnonymousTelemetry: z.boolean().optional(),
228 systemMessage: z.string().optional(),
229 completionOptions: completionOptionsSchema.optional(),
230 requestOptions: requestOptionsSchema.optional(),
231 slashCommands: z.array(slashCommandSchema).optional(),
232 customCommands: z.array(customCommandSchema).optional(),
233 contextProviders: z.array(contextProviderSchema).optional(),
234 disableIndexing: z.boolean().optional(),
235 tabAutocompleteOptions: tabAutocompleteOptionsSchema.optional(),
236 ui: uiOptionsSchema.optional(),
237 docs: z.array(siteIndexingConfigSchema).optional(),
238 controlPlane: controlPlaneConfigSchema.optional(),
239});
240export type ConfigJson = z.infer<typeof configJsonSchema>;