From 79bba67bc741d4929d2afb18c21a7b6e6c3ffbbb Mon Sep 17 00:00:00 2001 From: Nate Sesti <33237525+sestinj@users.noreply.github.com> Date: Mon, 8 Jul 2024 22:05:21 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=AA=84=20model=20dropdown,=20control=20pl?= =?UTF-8?q?ane=20(#1692)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Nate/control plane client (#1691) * docs: add docs and schema for "OS" provider (#1536) * ignore .env * fix(gui): ctx rendering w/ renderInlineAs: "" (#1541) * ✨ use and cache imports for autocomplete (#1456) * ✨ use and cache imports for autocomplete * fix tsc * fix codeqwen autocomplete leading space * add voyage rerank-1 * feat: `--noEmit` for tsc checks in CI (#1559) * docs: update CustomContextProvider docs (#1557) * add stop tokens to qwen prompt * update docs to reflect 3.5 sonnet being best * docs: comment out unused providers (#1561) * import Handlebars * feat: toast notification for config updates (#1560) * feat: toast notification for config updates * feat: only trigger toast on config.json save * displayRawMarkdown option * feat: open pane on install (#1564) * feat: open pane on activation * comment out testing code * update to reflect 16 stop words limit for deepseek * feat: only trigger config update toast in vscode (#1571) * docs(prompt-files): fix typos + clarify (#1575) * doc: prompt file typo + clarifications * fix: add back correct docs * chore: add telemetry for pageviews (#1576) * feat: update onboarding w/ embeddings model (#1570) * chore(gui): remove unused pages * feat: add embeddings step * feat: update styles * feat: copy button updates * fix: correct pull command for embed model * fix: remove commented code * fix: remove commented code * feat: simplify copy btn props * chore: rename onboarding selection event * feat: add provider config * fix: undo msg name * remove dead code * fix: invalid mode check * fix: remove testing logic * docs(telemetry): add pageviews to tracking list (#1581) * Add reranker configuration options to codebase embedding docs (#1584) - Introduce reranker concept - List available reranker options - Provide configuration instructions - Update keywords to include "reranker" * chore: update pr template with screenshots (#1590) * Refactor ConfirmationDialog to use SecondaryButton for cancel action (#1586) * Added instructions for running docs server locally (#1578) - Added NPM script method - Added VS Code task method - Update contributing guidelines * Update branch policy (#1577) - Change PR target to `dev` branch - Update `CONTRIBUTING.md` instructions * Consolidate example configurations into the main configuration guide (#1579) - Moved examples to configuration.md - Deleted the separate examples.md file - Updated sidebar order and links - Improved readability and structure in configuration.md * fix: fullscreen gui retains context when hidden, fixed fullscreen focusing (#1582) * Update completionProvider.ts (warning tab-autocomplete models) (#1566) * feat: enhanced IndexingProgressBar with blinking dot feature - Integrated BlinkingDot component - Added STATUS_COLORS for various states - Replaced CircleDiv with BlinkingDot in UI - Updated status messages and layout * small UI tweaks * feat(gui): enhance ModelCard, ModelProviderTag, and Toggle components (#1595) - add styling and adjustments to ModelCard - update ModelProviderTag font size - remove box shadow from Toggle component - tweak icon styles in ModelCard - improve alignment and spacing * media query * feat: add best experience onboarding * fix: file rename * stop movement on button hover by keeping same border thickness * fix mistake in setting cursor: pointer * fix when free trial option is shown * Support Node.js versions below 20 for streaming response handling (#1591) - Add fallback for Node < 20 - Implement toAsyncIterable for streaming - Use TextDecoder for manual decoding - Maintain existing streaming for Node 20+ * small fixes * feat: add free trial card to onboarding (#1600) * feat: add free trial card to onboarding * add import * fix hasPassedFTL * fix /edit cancellation from UI * feat: add `applyCodeBlock` experimental prop (#1601) * feat: add new model styling improvements (#1609) * feat: add new model styling improvements * better gap size * feat: update bug_report.yml (#1610) * chore: update bug_report.yml * typo fix * feat: add labels to "Add docs" dialog (#1612) * feat: add labels to "Add docs" dialog * remove autofocus * don't double load config * small fixes * speed up directory traversal, and use correct native path module * option not to show config update toast * merge air-gapped and recommended setup pages * chore: add telemetry for full screen toggle (#1618) * Fix headings in codebase-embeddings.md (#1617) * mention jetbrains * docs: update changie (#1619) * feat: updated changie config * hide toc and autogenerate * Update changelog.mdx * link to deeper explanation of embeddings models * ensure target="_blank" for all links in sidebar * fix gif links in intellij README.md * don't require rust in dependency installation * chore: fix padding on gh button (#1620) * chore: adjust button padding * Update tasks.json * escape colons in diff path * smoother lancedb indexing reporting * smooth progress updates for indexing * fix tsc err * rerank-lite-1 * remove doccs * basic tests for VS Code extension * improved testing of VS Code extension * docs: add docs and schema for "OS" provider (#1536) * ignore .env * 🚑 fix constant warnings when onboarding with Ollama * ✨ use and cache imports for autocomplete (#1456) * ✨ use and cache imports for autocomplete * fix tsc * team analytics * apply control plane settings * workos auth * ide protocol get session info * UI for auth * profile switching * small fixes * updates * refresh tokens * updates * fix tsc errs * model select in toolbar to make room for profile selector * prod client id * link to prod URL * internal beta option * profiles change listener --------- Co-authored-by: Patrick Erichsen Co-authored-by: Priyash <38959321+priyashpatil@users.noreply.github.com> Co-authored-by: Jonah Wagner Co-authored-by: YohannZe <99359799+YohannZe@users.noreply.github.com> Co-authored-by: Dan Dascalescu * temporary patch for type errs --------- Co-authored-by: Patrick Erichsen Co-authored-by: Priyash <38959321+priyashpatil@users.noreply.github.com> Co-authored-by: Jonah Wagner Co-authored-by: YohannZe <99359799+YohannZe@users.noreply.github.com> Co-authored-by: Dan Dascalescu --- .github/workflows/preview.yaml | 10 +- .vscode/tasks.json | 4 +- core/control-plane/schema.ts | 128 ++++++++++++++++++ .../vscode/src/extension/VsCodeExtension.ts | 4 +- .../components/modelSelection/ModelSelect.tsx | 2 +- .../control-plane-types/package-lock.json | 29 ++++ packages/control-plane-types/package.json | 15 ++ packages/control-plane-types/src/index.d.ts | 4 + packages/control-plane-types/tsconfig.json | 108 +++++++++++++++ 9 files changed, 295 insertions(+), 9 deletions(-) create mode 100644 core/control-plane/schema.ts create mode 100644 packages/control-plane-types/package-lock.json create mode 100644 packages/control-plane-types/package.json create mode 100644 packages/control-plane-types/src/index.d.ts create mode 100644 packages/control-plane-types/tsconfig.json diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index a04591c89..988920443 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -124,11 +124,11 @@ jobs: # npm run test # if: matrix.os == 'ubuntu-latest' - # - name: Run extension tests - # run: | - # cd extensions/vscode - # npm run test - # if: matrix.os != 'ubuntu-latest' + - name: Run extension tests + run: | + cd extensions/vscode + npm run test + if: matrix.os != 'ubuntu-latest' # 5. Package the extension - name: Package the extension diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 49dbba82e..3850dd66b 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -12,7 +12,9 @@ // To bundle the code the same way we do for publishing "vscode-extension:esbuild", // Start the React app that is used in the extension - "gui:dev" + "gui:dev", + // Start the docs site, without opening the browser + "docs:start" ], "group": { "kind": "build", diff --git a/core/control-plane/schema.ts b/core/control-plane/schema.ts new file mode 100644 index 000000000..5557eff13 --- /dev/null +++ b/core/control-plane/schema.ts @@ -0,0 +1,128 @@ +import { z } from "zod"; + +const modelDescriptionSchema = z.object({ + title: z.string(), + provider: z.enum([ + "openai", + "anthropic", + "cohere", + "ollama", + "huggingface-tgi", + "huggingface-inference-api", + "replicate", + "gemini", + "mistral", + "bedrock", + "cloudflare", + "azure", + ]), + model: z.string(), + apiKey: z.string().optional(), + apiBase: z.string().optional(), + contextLength: z.number().optional(), + template: z + .enum([ + "llama2", + "alpaca", + "zephyr", + "phi2", + "phind", + "anthropic", + "chatml", + "none", + "openchat", + "deepseek", + "xwin-coder", + "neural-chat", + "codellama-70b", + "llava", + "gemma", + "llama3", + ]) + .optional(), + completionOptions: z + .object({ + temperature: z.number().optional(), + topP: z.number().optional(), + topK: z.number().optional(), + minP: z.number().optional(), + presencePenalty: z.number().optional(), + frequencyPenalty: z.number().optional(), + mirostat: z.number().optional(), + stop: z.array(z.string()).optional(), + maxTokens: z.number().optional(), + numThreads: z.number().optional(), + keepAlive: z.number().optional(), + raw: z.boolean().optional(), + stream: z.boolean().optional(), + }) + .optional(), + systemMessage: z.string().optional(), + requestOptions: z + .object({ + timeout: z.number().optional(), + verifySsl: z.boolean().optional(), + caBundlePath: z.union([z.string(), z.array(z.string())]).optional(), + proxy: z.string().optional(), + headers: z.record(z.string()).optional(), + extraBodyProperties: z.record(z.any()).optional(), + noProxy: z.array(z.string()).optional(), + }) + .optional(), + promptTemplates: z.record(z.string()).optional(), +}); + +const embeddingsProviderSchema = z.object({ + provider: z.enum([ + "transformers.js", + "ollama", + "openai", + "cohere", + "free-trial", + "gemini", + ]), + apiBase: z.string().optional(), + apiKey: z.string().optional(), + model: z.string().optional(), + engine: z.string().optional(), + apiType: z.string().optional(), + apiVersion: z.string().optional(), + requestOptions: z + .object({ + timeout: z.number().optional(), + verifySsl: z.boolean().optional(), + caBundlePath: z.union([z.string(), z.array(z.string())]).optional(), + proxy: z.string().optional(), + headers: z.record(z.string()).optional(), + extraBodyProperties: z.record(z.any()).optional(), + noProxy: z.array(z.string()).optional(), + }) + .optional(), +}); + +const rerankerSchema = z.object({ + name: z.enum(["cohere", "voyage", "llm"]), + params: z.record(z.any()).optional(), +}); + +const analyticsSchema = z.object({ + url: z.string().optional(), + clientKey: z.string().optional(), +}); + +export type ControlPlaneAnalytics = z.infer; + +const devDataSchema = z.object({ + url: z.string().optional(), +}); + +export const controlPlaneSettingsSchema = z.object({ + models: z.array(modelDescriptionSchema), + tabAutocompleteModel: modelDescriptionSchema, + embeddingsModel: embeddingsProviderSchema, + reranker: rerankerSchema, + analytics: analyticsSchema, + devData: devDataSchema, +}); + +export type ControlPlaneSettings = z.infer; diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts index 8c1cdef01..251ba02fd 100644 --- a/extensions/vscode/src/extension/VsCodeExtension.ts +++ b/extensions/vscode/src/extension/VsCodeExtension.ts @@ -14,19 +14,19 @@ import { setupStatusBar, } from "../autocomplete/statusBar"; import { registerAllCommands } from "../commands"; -import { registerDebugTracker } from "../debug/debug"; import { ContinueGUIWebviewViewProvider } from "../ContinueGUIWebviewViewProvider"; +import { registerDebugTracker } from "../debug/debug"; import { DiffManager } from "../diff/horizontal"; import { VerticalPerLineDiffManager } from "../diff/verticalPerLine/manager"; import { VsCodeIde } from "../ideProtocol"; import { registerAllCodeLensProviders } from "../lang-server/codeLens"; +import { QuickEdit } from "../quickEdit/QuickEditQuickPick"; import { setupRemoteConfigSync } from "../stubs/activation"; import { getControlPlaneSessionInfo } from "../stubs/WorkOsAuthProvider"; import { Battery } from "../util/battery"; import { TabAutocompleteModel } from "../util/loadAutocompleteModel"; import type { VsCodeWebviewProtocol } from "../webviewProtocol"; import { VsCodeMessenger } from "./VsCodeMessenger"; -import { QuickEdit } from "../quickEdit/QuickEditQuickPick"; export class VsCodeExtension { // Currently some of these are public so they can be used in testing (test/test-suites) diff --git a/gui/src/components/modelSelection/ModelSelect.tsx b/gui/src/components/modelSelection/ModelSelect.tsx index b8e5109db..570badba0 100644 --- a/gui/src/components/modelSelection/ModelSelect.tsx +++ b/gui/src/components/modelSelection/ModelSelect.tsx @@ -2,8 +2,8 @@ import { Listbox } from "@headlessui/react"; import { ChevronDownIcon, CubeIcon, - TrashIcon, PlusIcon, + TrashIcon, } from "@heroicons/react/24/outline"; import { useContext, useEffect, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; diff --git a/packages/control-plane-types/package-lock.json b/packages/control-plane-types/package-lock.json new file mode 100644 index 000000000..0df9c60ee --- /dev/null +++ b/packages/control-plane-types/package-lock.json @@ -0,0 +1,29 @@ +{ + "name": "control-plane-types", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "control-plane-types", + "version": "1.0.0", + "license": "Apache-2.0", + "devDependencies": { + "typescript": "^5.5.2" + } + }, + "node_modules/typescript": { + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz", + "integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + } + } +} diff --git a/packages/control-plane-types/package.json b/packages/control-plane-types/package.json new file mode 100644 index 000000000..0bc5b95d5 --- /dev/null +++ b/packages/control-plane-types/package.json @@ -0,0 +1,15 @@ +{ + "name": "control-plane-types", + "version": "1.0.0", + "description": "", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Nate Sesti and Ty Dunn", + "license": "Apache-2.0", + "devDependencies": { + "typescript": "^5.5.2" + } +} diff --git a/packages/control-plane-types/src/index.d.ts b/packages/control-plane-types/src/index.d.ts new file mode 100644 index 000000000..d716289a4 --- /dev/null +++ b/packages/control-plane-types/src/index.d.ts @@ -0,0 +1,4 @@ +export interface Test { + a: string; + b: number; +} diff --git a/packages/control-plane-types/tsconfig.json b/packages/control-plane-types/tsconfig.json new file mode 100644 index 000000000..8bb6097f8 --- /dev/null +++ b/packages/control-plane-types/tsconfig.json @@ -0,0 +1,108 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + + /* Modules */ + "module": "commonjs", /* Specify what module code is generated. */ + // "rootDir": "./", /* Specify the root folder within your source files. */ + // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + // "outDir": "./", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ + // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } +}