From f27b3e4879481419e22e8420dcf68262d2b40925 Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 19 Dec 2024 21:12:28 -0800 Subject: [PATCH 001/114] test: add autocomplete test --- core/protocol/passThrough.ts | 2 + extensions/intellij/.gitignore | 4 +- .../.run/Run IDE for UI Tests.run.xml | 25 ---- extensions/intellij/.run/Run Test IDE.run.xml | 31 ++++ extensions/intellij/.run/Run Tests.run.xml | 24 +++ .../intellij/.run/Run e2e tests.run.xml | 7 + extensions/intellij/build.gradle.kts | 3 +- .../constants/MessageTypes.kt | 68 ++++++++- .../toolWindow/ContinueBrowser.kt | 60 +------- .../e2e/Autocomplete.kt | 73 +++++++++ .../continueintellijextension/e2e/GUI.kt | 139 ++++++++++++++++++ .../e2e/TutorialTest.kt | 94 ------------ .../e2e/test-continue/config.json | 43 ++++++ .../{pages => fixtures}/DialogFixture.kt | 2 +- .../{pages => fixtures}/IdeaFrame.kt | 2 +- .../{pages => fixtures}/WelcomeFrame.kt | 2 +- .../OnboardingCard/OnboardingCard.tsx | 5 +- .../components/dialogs/ConfirmationDialog.tsx | 2 +- 18 files changed, 399 insertions(+), 187 deletions(-) delete mode 100644 extensions/intellij/.run/Run IDE for UI Tests.run.xml create mode 100644 extensions/intellij/.run/Run Test IDE.run.xml create mode 100644 extensions/intellij/.run/Run Tests.run.xml create mode 100644 extensions/intellij/.run/Run e2e tests.run.xml create mode 100644 extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt create mode 100644 extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt delete mode 100644 extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/TutorialTest.kt create mode 100644 extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/test-continue/config.json rename extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/{pages => fixtures}/DialogFixture.kt (95%) rename extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/{pages => fixtures}/IdeaFrame.kt (98%) rename extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/{pages => fixtures}/WelcomeFrame.kt (94%) diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index f71b7460d..c89b91789 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -61,6 +61,8 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] = ]; // Message types to pass through from core to webview +// Note: If updating these values, make a corresponding update in +// extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt export const CORE_TO_WEBVIEW_PASS_THROUGH: (keyof ToWebviewFromCoreProtocol)[] = [ "configUpdate", diff --git a/extensions/intellij/.gitignore b/extensions/intellij/.gitignore index ac787e936..2be56cfd9 100644 --- a/extensions/intellij/.gitignore +++ b/extensions/intellij/.gitignore @@ -3,4 +3,6 @@ src/main/resources/webview src/main/resources/bin src/main/resources/config_schema.json src/main/resources/continue_rc_schema.json -video \ No newline at end of file +video +src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/test-continue/* +!src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/test-continue/config.json \ No newline at end of file diff --git a/extensions/intellij/.run/Run IDE for UI Tests.run.xml b/extensions/intellij/.run/Run IDE for UI Tests.run.xml deleted file mode 100644 index 5f7eb46c8..000000000 --- a/extensions/intellij/.run/Run IDE for UI Tests.run.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/extensions/intellij/.run/Run Test IDE.run.xml b/extensions/intellij/.run/Run Test IDE.run.xml new file mode 100644 index 000000000..e6c1a820e --- /dev/null +++ b/extensions/intellij/.run/Run Test IDE.run.xml @@ -0,0 +1,31 @@ + + + + + + + + true + true + false + false + + + + \ No newline at end of file diff --git a/extensions/intellij/.run/Run Tests.run.xml b/extensions/intellij/.run/Run Tests.run.xml new file mode 100644 index 000000000..bdff34d6d --- /dev/null +++ b/extensions/intellij/.run/Run Tests.run.xml @@ -0,0 +1,24 @@ + + + + + + + true + true + false + false + + + \ No newline at end of file diff --git a/extensions/intellij/.run/Run e2e tests.run.xml b/extensions/intellij/.run/Run e2e tests.run.xml new file mode 100644 index 000000000..2280aece0 --- /dev/null +++ b/extensions/intellij/.run/Run e2e tests.run.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/extensions/intellij/build.gradle.kts b/extensions/intellij/build.gradle.kts index 25d2fb361..a4ccd3422 100644 --- a/extensions/intellij/build.gradle.kts +++ b/extensions/intellij/build.gradle.kts @@ -130,7 +130,6 @@ tasks { // Configure UI tests plugin // Read more: https://github.com/JetBrains/intellij-ui-test-robot runIdeForUiTests { - environment("CONTINUE_GLOBAL_DIR", "src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/test-continue") systemProperty("robot-server.port", "8082") systemProperty("ide.mac.message.dialogs.as.sheets", "false") systemProperty("jb.privacy.policy.text", "") @@ -141,6 +140,7 @@ tasks { systemProperty("idea.trust.all.projects", "true") systemProperty("ide.show.tips.on.startup.default.value", "false") systemProperty("ide.browser.jcef.jsQueryPoolSize", "10000") + systemProperty("ide.browser.jcef.contextMenu.devTools.enabled", "true") // This is to ensure we load the GUI with OSR enabled. We have logic that // renders with OSR disabled below a particular IDE version. @@ -180,6 +180,5 @@ tasks { test { useJUnitPlatform() - environment("CONTINUE_GLOBAL_DIR", "src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/test-continue") } } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt index 264822b6c..4c8450268 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt @@ -53,13 +53,77 @@ class MessageTypes { "showToast", ) + // Note: If updating these values, make a corresponding update in + // core/protocol/passThrough.ts val PASS_THROUGH_TO_WEBVIEW = listOf( "configUpdate", "getDefaultModelTitle", - "indexProgress", + "indexProgress", // Codebase + "indexing/statusUpdate", // Docs, etc. + "addContextItem", "refreshSubmenuItems", + "isContinueInputFocused", "didChangeAvailableProfiles", - "addContextItem" + "setTTSActive", + "getWebviewHistoryLength", + "getCurrentSessionId", + "signInToControlPlane", + "openDialogMessage", + "docs/suggestions", + ) + + // Note: If updating these values, make a corresponding update in + // core/protocol/passThrough.ts + val PASS_THROUGH_TO_CORE = listOf( + "abort", + "history/list", + "history/delete", + "history/load", + "history/save", + "devdata/log", + "config/addModel", + "config/newPromptFile", + "config/ideSettingsUpdate", + "config/getSerializedProfileInfo", + "config/deleteModel", + "config/listProfiles", + "config/openProfile", + "context/getContextItems", + "context/getSymbolsForFiles", + "context/loadSubmenuItems", + "context/addDocs", + "context/removeDocs", + "context/indexDocs", + "autocomplete/complete", + "autocomplete/cancel", + "autocomplete/accept", + "command/run", + "tts/kill", + "llm/complete", + "llm/streamComplete", + "llm/streamChat", + "llm/listModels", + "streamDiffLines", + "chatDescriber/describe", + "stats/getTokensPerDay", + "stats/getTokensPerModel", + // Codebase + "index/setPaused", + "index/forceReIndex", + "index/forceReIndexFiles", + "index/indexingProgressBarInitialized", + // Docs, etc. + "indexing/reindex", + "indexing/abort", + "indexing/setPaused", + "docs/getSuggestedDocs", + "docs/initStatuses", + // + "completeOnboarding", + "addAutocompleteModel", + "profiles/switch", + "didChangeSelectedProfile", + "tools/call", ) } } \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt index 1ace413ea..b43cf62c9 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt @@ -2,6 +2,7 @@ package com.github.continuedev.continueintellijextension.toolWindow import com.github.continuedev.continueintellijextension.activities.ContinuePluginDisposable import com.github.continuedev.continueintellijextension.constants.MessageTypes +import com.github.continuedev.continueintellijextension.constants.MessageTypes.Companion.PASS_THROUGH_TO_CORE import com.github.continuedev.continueintellijextension.factories.CustomSchemeHandlerFactory import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings import com.github.continuedev.continueintellijextension.services.ContinuePluginService @@ -18,58 +19,6 @@ import org.cef.browser.CefBrowser import org.cef.handler.CefLoadHandlerAdapter class ContinueBrowser(val project: Project, url: String) { - private val PASS_THROUGH_TO_CORE = listOf( - "abort", - "history/list", - "history/delete", - "history/load", - "history/save", - "devdata/log", - "config/addModel", - "config/newPromptFile", - "config/ideSettingsUpdate", - "config/getSerializedProfileInfo", - "config/deleteModel", - "config/listProfiles", - "config/openProfile", - "context/getContextItems", - "context/getSymbolsForFiles", - "context/loadSubmenuItems", - "context/addDocs", - "context/removeDocs", - "context/indexDocs", - "autocomplete/complete", - "autocomplete/cancel", - "autocomplete/accept", - "command/run", - "tts/kill", - "llm/complete", - "llm/streamComplete", - "llm/streamChat", - "llm/listModels", - "streamDiffLines", - "chatDescriber/describe", - "stats/getTokensPerDay", - "stats/getTokensPerModel", - // Codebase - "index/setPaused", - "index/forceReIndex", - "index/forceReIndexFiles", - "index/indexingProgressBarInitialized", - // Docs, etc. - "indexing/reindex", - "indexing/abort", - "indexing/setPaused", - "docs/getSuggestedDocs", - "docs/initStatuses", - // - "completeOnboarding", - "addAutocompleteModel", - "profiles/switch", - "didChangeSelectedProfile", - "tools/call", - ) - private fun registerAppSchemeHandler() { CefApp.getInstance().registerSchemeHandlerFactory( "http", @@ -82,14 +31,9 @@ class ContinueBrowser(val project: Project, url: String) { init { val isOSREnabled = ServiceManager.getService(ContinueExtensionSettings::class.java).continueState.enableOSR + this.browser = JBCefBrowser.createBuilder().setOffScreenRendering(isOSREnabled).build() - - browser.jbCefClient.setProperty( - JBCefClient.Properties.JS_QUERY_POOL_SIZE, - JS_QUERY_POOL_SIZE - ) - registerAppSchemeHandler() browser.loadURL(url); Disposer.register(ContinuePluginDisposable.getInstance(project), browser) diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt new file mode 100644 index 000000000..1f105738a --- /dev/null +++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt @@ -0,0 +1,73 @@ +package com.github.continuedev.continueintellijextension.e2e + +import com.automation.remarks.junit5.Video +import com.github.continuedev.continueintellijextension.fixtures.dialog +import com.github.continuedev.continueintellijextension.fixtures.idea +import com.github.continuedev.continueintellijextension.fixtures.welcomeFrame +import com.github.continuedev.continueintellijextension.utils.RemoteRobotExtension +import com.github.continuedev.continueintellijextension.utils.StepsLogger +import com.intellij.remoterobot.RemoteRobot +import com.intellij.remoterobot.fixtures.ComponentFixture +import com.intellij.remoterobot.search.locators.byXpath +import com.intellij.remoterobot.steps.CommonSteps +import com.intellij.remoterobot.utils.keyboard +import com.intellij.remoterobot.utils.waitFor +import com.intellij.remoterobot.utils.waitForIgnoringError +import org.junit.jupiter.api.AfterEach +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import java.time.Duration.ofMinutes +import java.time.Duration.ofSeconds + +@ExtendWith(RemoteRobotExtension::class) +class Autocomplete {init { + StepsLogger.init() +} + + @BeforeEach + fun waitForIde(remoteRobot: RemoteRobot) { + waitForIgnoringError(ofMinutes(3)) { remoteRobot.callJs("true") } + } + + @AfterEach + fun closeProject(remoteRobot: RemoteRobot) = CommonSteps(remoteRobot).closeProject() + + @Test + @Video + fun displayCompletion(remoteRobot: RemoteRobot): Unit = with(remoteRobot) { + welcomeFrame { + createNewProjectLink.click() + dialog("New Project") { + findText("Java").click() + checkBox("Add sample code").select() + button("Create").click() + } + } + + // Wait for the default "Main.java" tab to load + // Our "continue_tutorial.java.ft" tab loads first, but then "Main.java" takes focus. + // So we need to wait for that to occur, and then focus on "continue_tutorial.java.ft" + waitFor(ofSeconds(20)) { + findAll( + byXpath("//div[@accessiblename='Main.java' and @class='EditorTabLabel']") + ).isNotEmpty() + } + + idea { + with(textEditor()) { + val USER_MESSAGE = "TEST_USER_MESSAGE_0" + editor.insertTextAtLine(0, 0, USER_MESSAGE) + editor.clickOnOffset(USER_MESSAGE.length) + + keyboard { + enterText(" ") + } + + waitFor(ofSeconds(10)) { + editor.hasText("TEST_LLM_RESPONSE_0") + } + } + } + } +} \ No newline at end of file diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt new file mode 100644 index 000000000..8099db9b5 --- /dev/null +++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt @@ -0,0 +1,139 @@ +/** + * Currently we can't test any actions in the GUI that involve clicks. + * See this open issue for details: https://github.com/JetBrains/intellij-ui-test-robot/issues/491 + */ +package com.github.continuedev.continueintellijextension.e2e + +import com.automation.remarks.junit5.Video +import com.github.continuedev.continueintellijextension.fixtures.* +import com.github.continuedev.continueintellijextension.utils.RemoteRobotExtension +import com.github.continuedev.continueintellijextension.utils.StepsLogger +import com.github.continuedev.continueintellijextension.utils.getMetaKey +import com.intellij.remoterobot.RemoteRobot +import com.intellij.remoterobot.fixtures.ComponentFixture +import com.intellij.remoterobot.search.locators.byXpath +import com.intellij.remoterobot.steps.CommonSteps +import com.intellij.remoterobot.stepsProcessing.step +import com.intellij.remoterobot.utils.keyboard +import com.intellij.remoterobot.utils.waitFor +import com.intellij.remoterobot.utils.waitForIgnoringError +import org.junit.jupiter.api.AfterEach +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Order +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import java.awt.event.KeyEvent.* +import java.time.Duration.ofMinutes +import java.time.Duration.ofSeconds + +@ExtendWith(RemoteRobotExtension::class) +class GUI { + init { + StepsLogger.init() + } + + @BeforeEach + fun waitForIde(remoteRobot: RemoteRobot) { + waitForIgnoringError(ofMinutes(3)) { remoteRobot.callJs("true") } + } + + @AfterEach + fun closeProject(remoteRobot: RemoteRobot) = CommonSteps(remoteRobot).closeProject() + + @Test + @Video + @Order(1) + fun onboarding(remoteRobot: RemoteRobot): Unit = with(remoteRobot) { + welcomeFrame { + createNewProjectLink.click() + dialog("New Project") { + findText("Java").click() + checkBox("Add sample code").select() + button("Create").click() + } + } + + idea { + // Wait for the default "Main.java" tab to load + // Our "continue_tutorial.java.ft" tab loads first, but then "Main.java" takes focus. + // So we need to wait for that to occur, and then focus on "continue_tutorial.java.ft" + waitFor(ofSeconds(20)) { + findAll( + byXpath("//div[@accessiblename='Main.java' and @class='EditorTabLabel']") + ).isNotEmpty() + } + + step("Verify Continue tutorial file is loaded") { + find(byXpath("//div[@visible_text='continue_tutorial.java.ft']")) + } + + step("Manually open the webview") { + // Manually open the webview + find(byXpath("//div[@text='Continue']"), ofSeconds((10))).click() + + waitFor(ofSeconds(10)) { + browser().isShowing + } + } + + step("Verify the onboarding card is present") { + waitFor(ofSeconds(30)) { + try { + browser().findElement("//*[@data-testid='onboarding-card']").html.isNotEmpty() + } catch (e: Exception) { + false + } + } + } + } + + } + + @Test + @Video + fun highlightCode(remoteRobot: RemoteRobot): Unit = with(remoteRobot) { + welcomeFrame { + createNewProjectLink.click() + dialog("New Project") { + findText("Java").click() + checkBox("Add sample code").select() + button("Create").click() + } + } + + + idea { + step("Manually open the webview") { + // Manually open the webview + find(byXpath("//div[@text='Continue']"), ofSeconds((10))).click() + + waitFor(ofSeconds(10)) { + browser().isShowing + } + + // Arbitrary timeout due to a bug where the webview will refresh + // and clear the editor state on first load + Thread.sleep(5000) + } + + + step("Verify we can highlight code and add to webview") { + val textToInsert = "Hello world!" + + with(textEditor()) { + editor.insertTextAtLine(0, 0, textToInsert) + editor.selectText(textToInsert) + + keyboard { + hotKey(getMetaKey(), VK_J) + } + } + + waitFor(ofSeconds(10)) { + browser().findElementByContainsText(textToInsert).html.isNotEmpty() + } + + } + } + } +} \ No newline at end of file diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/TutorialTest.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/TutorialTest.kt deleted file mode 100644 index 8e43def29..000000000 --- a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/TutorialTest.kt +++ /dev/null @@ -1,94 +0,0 @@ -package com.github.continuedev.continueintellijextension.e2e - -import com.automation.remarks.junit5.Video -import com.github.continuedev.continueintellijextension.pages.dialog -import com.github.continuedev.continueintellijextension.pages.idea -import com.github.continuedev.continueintellijextension.pages.welcomeFrame -import com.github.continuedev.continueintellijextension.utils.RemoteRobotExtension -import com.github.continuedev.continueintellijextension.utils.StepsLogger -import com.github.continuedev.continueintellijextension.utils.getMetaKey -import com.intellij.remoterobot.RemoteRobot -import com.intellij.remoterobot.fixtures.ComponentFixture -import com.intellij.remoterobot.fixtures.JCefBrowserFixture -import com.intellij.remoterobot.search.locators.Locator -import com.intellij.remoterobot.search.locators.byXpath -import com.intellij.remoterobot.steps.CommonSteps -import com.intellij.remoterobot.utils.keyboard -import com.intellij.remoterobot.utils.waitFor -import com.intellij.remoterobot.utils.waitForIgnoringError -import org.junit.jupiter.api.AfterEach -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -import java.awt.event.KeyEvent.* -import java.time.Duration.ofMinutes -import java.time.Duration.ofSeconds - -@ExtendWith(RemoteRobotExtension::class) -class TutorialTest { - init { - StepsLogger.init() - } - - @BeforeEach - fun waitForIde(remoteRobot: RemoteRobot) { - waitForIgnoringError(ofMinutes(3)) { remoteRobot.callJs("true") } - } - - @AfterEach - fun closeProject(remoteRobot: RemoteRobot) = CommonSteps(remoteRobot).closeProject() - - @Test - @Video - fun completeTutorial(remoteRobot: RemoteRobot) = with(remoteRobot) { - welcomeFrame { - createNewProjectLink.click() - dialog("New Project") { - findText("Java").click() - checkBox("Add sample code").select() - button("Create").click() - } - } - - // Wait for the default "Main.java" tab to load - // Our "continue_tutorial.java" tab loads first, but then "Main.java" takes focus. - // So we need to wait for that to occur, and then focus on "continue_tutorial.java" - waitFor(ofSeconds(20)) { - findAll( - byXpath("//div[@accessiblename='Main.java' and @class='EditorTabLabel']") - ).isNotEmpty() - } - - val tutorialEditorTabLocator: Locator = - byXpath("//div[@accessiblename='continue_tutorial.java' and @class='EditorTabLabel']") - val tutorialEditorTab: ComponentFixture = - remoteRobot.find(ComponentFixture::class.java, tutorialEditorTabLocator) - tutorialEditorTab.click() - - // Manually open the webview - find(byXpath("//div[@text='Continue']")).click() - - // Arbitrary sleep while we wait for the webview to load - Thread.sleep(10000) - - val textToInsert = "Hello world!" - - idea { - with(textEditor()) { - editor.insertTextAtLine(0, 0, textToInsert) - editor.selectText(textToInsert) - keyboard { - hotKey(getMetaKey(), VK_J) - } - } - } - - // TODO: locator needs to be OS aware - // https://github.com/JetBrains/intellij-ui-test-robot/blob/139a05eb99e9a49f13605626b81ad9864be23c96/remote-fixtures/src/main/kotlin/com/intellij/remoterobot/fixtures/CommonContainerFixture.kt#L203 - val jcefBrowser = find(JCefBrowserFixture.macLocator) - assert(jcefBrowser.getDom().isNotEmpty()) { "JCEF browser not found or empty" } - - val codeSnippetText = jcefBrowser.findElementByContainsText(textToInsert) - assert(codeSnippetText.html.isNotEmpty()) { "Failed to find code snippet in webview" } - } -} \ No newline at end of file diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/test-continue/config.json b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/test-continue/config.json new file mode 100644 index 000000000..0160335f5 --- /dev/null +++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/test-continue/config.json @@ -0,0 +1,43 @@ +{ + "ui": { + "displayRawMarkdown": false + }, + "models": [ + { + "title": "TEST LLM", + "provider": "test", + "model": "this field is not used" + }, + { + "title": "Mock", + "provider": "mock", + "model": "this field is not used" + } + ], + "analytics": { + "provider": "continue-proxy" + }, + "tabAutocompleteModel": { + "title": "TEST LLM", + "provider": "test", + "model": "this field is not used" + }, + "tabAutocompleteOptions": { + "useCache": false + }, + "contextProviders": [ + { + "name": "docs" + }, + { + "name": "diff" + }, + { + "name": "url" + }, + { + "name": "folder" + } + ], + "docs": [] +} diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/pages/DialogFixture.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/fixtures/DialogFixture.kt similarity index 95% rename from extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/pages/DialogFixture.kt rename to extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/fixtures/DialogFixture.kt index 8bb5798e3..d9643a96b 100644 --- a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/pages/DialogFixture.kt +++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/fixtures/DialogFixture.kt @@ -1,4 +1,4 @@ -package com.github.continuedev.continueintellijextension.pages +package com.github.continuedev.continueintellijextension.fixtures /* * Source: https://github.com/JetBrains/intellij-ui-test-robot/blob/139a05eb99e9a49f13605626b81ad9864be23c96/ui-test-example/src/test/kotlin/org/intellij/examples/simple/plugin/pages/DialogFixture.kt diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/pages/IdeaFrame.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/fixtures/IdeaFrame.kt similarity index 98% rename from extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/pages/IdeaFrame.kt rename to extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/fixtures/IdeaFrame.kt index b55432585..141677c15 100644 --- a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/pages/IdeaFrame.kt +++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/fixtures/IdeaFrame.kt @@ -1,4 +1,4 @@ -package com.github.continuedev.continueintellijextension.pages +package com.github.continuedev.continueintellijextension.fixtures /* * Source: https://github.com/JetBrains/intellij-ui-test-robot/blob/139a05eb99e9a49f13605626b81ad9864be23c96/ui-test-example/src/test/kotlin/org/intellij/examples/simple/plugin/pages/IdeaFrame.kt diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/pages/WelcomeFrame.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/fixtures/WelcomeFrame.kt similarity index 94% rename from extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/pages/WelcomeFrame.kt rename to extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/fixtures/WelcomeFrame.kt index ab59f72ab..70029fdaf 100644 --- a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/pages/WelcomeFrame.kt +++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/fixtures/WelcomeFrame.kt @@ -1,4 +1,4 @@ -package com.github.continuedev.continueintellijextension.pages +package com.github.continuedev.continueintellijextension.fixtures /* * Source: https://github.com/JetBrains/intellij-ui-test-robot/blob/139a05eb99e9a49f13605626b81ad9864be23c96/ui-test-example/src/test/kotlin/org/intellij/examples/simple/plugin/pages/WelcomeFrame.kt diff --git a/gui/src/components/OnboardingCard/OnboardingCard.tsx b/gui/src/components/OnboardingCard/OnboardingCard.tsx index bce9c5a98..78caa4b5b 100644 --- a/gui/src/components/OnboardingCard/OnboardingCard.tsx +++ b/gui/src/components/OnboardingCard/OnboardingCard.tsx @@ -41,7 +41,10 @@ export function OnboardingCard() { } return ( - + -

+

{props.title ?? "Confirmation"}

From b2048d82cd18619c93faf69b3ef436aee553fcd0 Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 19 Dec 2024 21:34:02 -0800 Subject: [PATCH 002/114] test: add onboarding test --- .../continueintellijextension/e2e/GUI.kt | 52 ------------ .../e2e/Onboarding.kt | 85 +++++++++++++++++++ 2 files changed, 85 insertions(+), 52 deletions(-) create mode 100644 extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Onboarding.kt diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt index 8099db9b5..2a953349b 100644 --- a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt +++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt @@ -19,7 +19,6 @@ import com.intellij.remoterobot.utils.waitFor import com.intellij.remoterobot.utils.waitForIgnoringError import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Order import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import java.awt.event.KeyEvent.* @@ -40,55 +39,6 @@ class GUI { @AfterEach fun closeProject(remoteRobot: RemoteRobot) = CommonSteps(remoteRobot).closeProject() - @Test - @Video - @Order(1) - fun onboarding(remoteRobot: RemoteRobot): Unit = with(remoteRobot) { - welcomeFrame { - createNewProjectLink.click() - dialog("New Project") { - findText("Java").click() - checkBox("Add sample code").select() - button("Create").click() - } - } - - idea { - // Wait for the default "Main.java" tab to load - // Our "continue_tutorial.java.ft" tab loads first, but then "Main.java" takes focus. - // So we need to wait for that to occur, and then focus on "continue_tutorial.java.ft" - waitFor(ofSeconds(20)) { - findAll( - byXpath("//div[@accessiblename='Main.java' and @class='EditorTabLabel']") - ).isNotEmpty() - } - - step("Verify Continue tutorial file is loaded") { - find(byXpath("//div[@visible_text='continue_tutorial.java.ft']")) - } - - step("Manually open the webview") { - // Manually open the webview - find(byXpath("//div[@text='Continue']"), ofSeconds((10))).click() - - waitFor(ofSeconds(10)) { - browser().isShowing - } - } - - step("Verify the onboarding card is present") { - waitFor(ofSeconds(30)) { - try { - browser().findElement("//*[@data-testid='onboarding-card']").html.isNotEmpty() - } catch (e: Exception) { - false - } - } - } - } - - } - @Test @Video fun highlightCode(remoteRobot: RemoteRobot): Unit = with(remoteRobot) { @@ -116,7 +66,6 @@ class GUI { Thread.sleep(5000) } - step("Verify we can highlight code and add to webview") { val textToInsert = "Hello world!" @@ -132,7 +81,6 @@ class GUI { waitFor(ofSeconds(10)) { browser().findElementByContainsText(textToInsert).html.isNotEmpty() } - } } } diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Onboarding.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Onboarding.kt new file mode 100644 index 000000000..2f8cdbbb1 --- /dev/null +++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Onboarding.kt @@ -0,0 +1,85 @@ +package com.github.continuedev.continueintellijextension.e2e + +import com.automation.remarks.junit5.Video +import com.github.continuedev.continueintellijextension.fixtures.dialog +import com.github.continuedev.continueintellijextension.fixtures.idea +import com.github.continuedev.continueintellijextension.fixtures.welcomeFrame +import com.github.continuedev.continueintellijextension.utils.RemoteRobotExtension +import com.github.continuedev.continueintellijextension.utils.StepsLogger +import com.intellij.remoterobot.RemoteRobot +import com.intellij.remoterobot.fixtures.ComponentFixture +import com.intellij.remoterobot.search.locators.byXpath +import com.intellij.remoterobot.steps.CommonSteps +import com.intellij.remoterobot.stepsProcessing.step +import com.intellij.remoterobot.utils.waitFor +import com.intellij.remoterobot.utils.waitForIgnoringError +import org.junit.jupiter.api.AfterEach +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import java.time.Duration.ofMinutes +import java.time.Duration.ofSeconds + +@ExtendWith(RemoteRobotExtension::class) +class Onboarding { + init { + StepsLogger.init() + } + + @BeforeEach + fun waitForIde(remoteRobot: RemoteRobot) { + waitForIgnoringError(ofMinutes(3)) { remoteRobot.callJs("true") } + } + + @AfterEach + fun closeProject(remoteRobot: RemoteRobot) = CommonSteps(remoteRobot).closeProject() + + + @Test + @Video + fun onboarding(remoteRobot: RemoteRobot): Unit = with(remoteRobot) { + welcomeFrame { + createNewProjectLink.click() + dialog("New Project") { + findText("Java").click() + checkBox("Add sample code").select() + button("Create").click() + } + } + + idea { + // Wait for the default "Main.java" tab to load + // Our "continue_tutorial.java.ft" tab loads first, but then "Main.java" takes focus. + // So we need to wait for that to occur, and then focus on "continue_tutorial.java.ft" + waitFor(ofSeconds(20)) { + findAll( + byXpath("//div[@accessiblename='Main.java' and @class='EditorTabLabel']") + ).isNotEmpty() + } + + // TODO: Need a good way to ensure this is the first test ran in the entire suite +// step("Verify Continue tutorial file is loaded") { +// find(byXpath("//div[@visible_text='continue_tutorial.java']")) +// } + + step("Manually open the webview") { + // Manually open the webview + find(byXpath("//div[@text='Continue']"), ofSeconds((10))).click() + + waitFor(ofSeconds(10)) { + browser().isShowing + } + } + + step("Verify the onboarding card is present") { + waitFor(ofSeconds(30)) { + try { + browser().findElement("//*[@data-testid='onboarding-card']").html.isNotEmpty() + } catch (e: Exception) { + false + } + } + } + } + } +} \ No newline at end of file From 1264de3c360f3eb5b9e56d1fd8d2abfc35fa8804 Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 19 Dec 2024 21:49:20 -0800 Subject: [PATCH 003/114] Update pr_checks.yaml --- .github/workflows/pr_checks.yaml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml index b2578aa5e..bc3454de1 100644 --- a/.github/workflows/pr_checks.yaml +++ b/.github/workflows/pr_checks.yaml @@ -75,7 +75,7 @@ jobs: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} gui-checks: - needs: [install-root, core-checks] + needs: [ install-root, core-checks ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -111,7 +111,7 @@ jobs: npx tsc --noEmit binary-checks: - needs: [install-root, core-checks] + needs: [ install-root, core-checks ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -147,7 +147,7 @@ jobs: npx tsc --noEmit vscode-checks: - needs: [install-root, core-checks] + needs: [ install-root, core-checks ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -186,7 +186,7 @@ jobs: npm run lint core-tests: - needs: [core-checks] + needs: [ core-checks ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -205,7 +205,7 @@ jobs: npm test vscode-tests: - needs: [vscode-checks, core-checks] + needs: [ vscode-checks, core-checks ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -265,7 +265,7 @@ jobs: path: extensions/vscode/e2e/storage/screenshots gui-tests: - needs: [gui-checks, core-checks] + needs: [ gui-checks, core-checks ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -296,7 +296,7 @@ jobs: npm test jetbrains-tests: - needs: [install-root, core-checks] + needs: [ install-root, core-checks ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -361,10 +361,11 @@ jobs: run: | cd extensions/intellij export DISPLAY=:99.0 + export CONTINUE_GLOBAL_DIR=${{ github.workspace }}/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/test-continue Xvfb -ac :99 -screen 0 1920x1080x24 & sleep 10 mkdir -p build/reports - ./gradlew runIdeForUiTests & + ./gradlew runIdeForUiTests & - name: Wait for JB connection uses: jtalk/url-health-check-action@v3 From 4a5f33acc1d43bd4ff95198747f5c1ac94ccf6c9 Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 19 Dec 2024 21:55:43 -0800 Subject: [PATCH 004/114] Update pr_checks.yaml --- .github/workflows/pr_checks.yaml | 218 ++++++++++++++++++++++++++++--- 1 file changed, 200 insertions(+), 18 deletions(-) diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml index bc3454de1..0610423f2 100644 --- a/.github/workflows/pr_checks.yaml +++ b/.github/workflows/pr_checks.yaml @@ -39,7 +39,7 @@ jobs: if: steps.root-cache.outputs.cache-hit != 'true' run: npm ci - core-checks: + install-core: needs: install-root runs-on: ubuntu-latest steps: @@ -66,6 +66,27 @@ jobs: cd core npm ci + core-checks: + needs: install-core + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + + - uses: actions/cache@v4 + id: root-cache + with: + path: node_modules + key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }} + + - uses: actions/cache@v4 + id: core-cache + with: + path: core/node_modules + key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }} + - name: Type check and lint run: | cd core @@ -74,8 +95,8 @@ jobs: env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - gui-checks: - needs: [ install-root, core-checks ] + install-gui: + needs: [ install-root, install-core ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -105,13 +126,38 @@ jobs: cd gui npm ci + gui-checks: + needs: install-gui + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + + - uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }} + + - uses: actions/cache@v4 + with: + path: core/node_modules + key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }} + + - uses: actions/cache@v4 + id: gui-cache + with: + path: gui/node_modules + key: ${{ runner.os }}-gui-node-modules-${{ hashFiles('gui/package-lock.json') }} + - name: Type check run: | cd gui npx tsc --noEmit binary-checks: - needs: [ install-root, core-checks ] + needs: [ install-root, install-core ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -146,8 +192,8 @@ jobs: cd binary npx tsc --noEmit - vscode-checks: - needs: [ install-root, core-checks ] + install-vscode: + needs: [ install-root, install-core ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -179,6 +225,31 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} + vscode-checks: + needs: install-vscode + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + + - uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }} + + - uses: actions/cache@v4 + with: + path: core/node_modules + key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }} + + - uses: actions/cache@v4 + id: vscode-cache + with: + path: extensions/vscode/node_modules + key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }} + - name: Type check and lint run: | cd extensions/vscode @@ -186,7 +257,7 @@ jobs: npm run lint core-tests: - needs: [ core-checks ] + needs: install-core runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -204,9 +275,38 @@ jobs: cd core npm test - vscode-tests: - needs: [ vscode-checks, core-checks ] + vscode-get-test-file-matrix: runs-on: ubuntu-latest + needs: [ install-root, install-vscode ] + outputs: + test_file_matrix: ${{ steps.vscode-get-test-file-matrix.outputs.test_file_matrix }} + steps: + - uses: actions/checkout@v4 + + - name: Cache node modules + uses: actions/cache@v3 + with: + path: extensions/vscode/node_modules + key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }} + + - name: Get test files + id: vscode-get-test-file-matrix + run: | + cd extensions/vscode + npm ci + npm run e2e:compile + FILES=$(ls -1 e2e/_output/tests/*.test.js | jq -R . | jq -s .) + echo "test_file_matrix<> $GITHUB_OUTPUT + echo "$FILES" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Debug Outputs + run: | + echo "Test files: ${{ steps.vscode-get-test-file-matrix.outputs.test_file_matrix }}" + + vscode-package-extension: + runs-on: ubuntu-latest + needs: [ install-vscode, install-core ] steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -225,18 +325,94 @@ jobs: path: core/node_modules key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }} + - name: Package extension + run: | + cd extensions/vscode + npm run package + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: vscode-extension-build + path: extensions/vscode/build + + vscode-download-e2e-dependencies: + runs-on: ubuntu-latest + needs: [ install-vscode, install-core ] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + + - uses: actions/cache@v4 + id: vscode-node-modules-cache + with: + path: extensions/vscode/node_modules + key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }} + - uses: actions/cache@v4 id: storage-cache with: path: extensions/vscode/e2e/storage key: ${{ runner.os }}-vscode-storage-${{ hashFiles('extensions/vscode/package-lock.json') }} - - name: Download Dependencies if Cache Miss + - name: Download Dependencies if: steps.storage-cache.outputs.cache-hit != 'true' run: | cd extensions/vscode npm run e2e:ci:download + - name: Upload e2e dependencies + uses: actions/upload-artifact@v4 + with: + name: vscode-e2e-dependencies + path: extensions/vscode/e2e/storage + + vscode-e2e-tests: + name: ${{ matrix.test_file }}" + needs: + [ + vscode-download-e2e-dependencies, + vscode-get-test-file-matrix, + vscode-package-extension, + install-vscode, + install-core, + ] + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + test_file: ${{ fromJson(needs.vscode-get-test-file-matrix.outputs.test_file_matrix) }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + + - uses: actions/cache@v4 + id: vscode-node-modules-cache + with: + path: extensions/vscode/node_modules + key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }} + + - name: Download build artifact + uses: actions/download-artifact@v4 + with: + name: vscode-extension-build + path: extensions/vscode/build + + - name: Download e2e dependencies + uses: actions/download-artifact@v4 + with: + name: vscode-e2e-dependencies + path: extensions/vscode/e2e/storage + + - name: Fix VSCode binary permissions + run: | + chmod +x extensions/vscode/e2e/storage/VSCode-linux-x64/code + chmod +x extensions/vscode/e2e/storage/chromedriver-linux64/chromedriver + - name: Set up SSH env: SSH_KEY: ${{ secrets.GH_ACTIONS_SSH_TEST_KEY_PEM }} @@ -248,24 +424,28 @@ jobs: ssh-keyscan -H "$SSH_HOST" >> ~/.ssh/known_hosts echo -e "Host ssh-test-container\n\tHostName $SSH_HOST\n\tUser ec2-user\n\tIdentityFile ~/.ssh/id_rsa" >> ~/.ssh/config - - name: Install Xvfb for Linux and run e2e tests + - name: Set up Xvfb + run: | + Xvfb :99 & + export DISPLAY=:99 + + - name: Run e2e tests run: | - sudo apt-get install -y xvfb # Install Xvfb - Xvfb :99 & # Start Xvfb - export DISPLAY=:99 # Export the display number to the environment cd extensions/vscode - npm run package - npm run e2e:ci:run + TEST_FILE="${{ matrix.test_file }}" npm run e2e:ci:run + + env: + DISPLAY: :99 - name: Upload e2e test screenshots if: failure() uses: actions/upload-artifact@v4 with: - name: e2e-screenshots + name: e2e-failure-screenshots path: extensions/vscode/e2e/storage/screenshots gui-tests: - needs: [ gui-checks, core-checks ] + needs: [ install-gui, install-core ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -399,3 +579,5 @@ jobs: name: jb-failure-report path: | ${{ github.workspace }}/extensions/intellij/build/reports + + From c46083d4115a79938bc6ae2b9421f36803b0a992 Mon Sep 17 00:00:00 2001 From: Test Date: Fri, 20 Dec 2024 09:34:29 -0800 Subject: [PATCH 005/114] fix: move autocomplete logic off of EDT --- .github/workflows/pr_checks.yaml | 3 +- extensions/intellij/.run/Run Test IDE.run.xml | 54 +++++++++---------- extensions/intellij/build.gradle.kts | 4 ++ .../autocomplete/AutocompleteService.kt | 13 ++--- .../e2e/Autocomplete.kt | 6 +-- 5 files changed, 40 insertions(+), 40 deletions(-) diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml index d57b51662..c41c57f72 100644 --- a/.github/workflows/pr_checks.yaml +++ b/.github/workflows/pr_checks.yaml @@ -536,11 +536,10 @@ jobs: run: | cd extensions/intellij export DISPLAY=:99.0 - export CONTINUE_GLOBAL_DIR=${{ github.workspace }}/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/test-continue Xvfb -ac :99 -screen 0 1920x1080x24 & sleep 10 mkdir -p build/reports - ./gradlew runIdeForUiTests & + ./gradlew runIdeForUiTests & - name: Wait for JB connection uses: jtalk/url-health-check-action@v3 diff --git a/extensions/intellij/.run/Run Test IDE.run.xml b/extensions/intellij/.run/Run Test IDE.run.xml index e6c1a820e..80a2a251f 100644 --- a/extensions/intellij/.run/Run Test IDE.run.xml +++ b/extensions/intellij/.run/Run Test IDE.run.xml @@ -1,31 +1,27 @@ - - - - - - - true - true - false - false - - - + + + + + + true + true + false + false + + + \ No newline at end of file diff --git a/extensions/intellij/build.gradle.kts b/extensions/intellij/build.gradle.kts index a4ccd3422..ee7dce8be 100644 --- a/extensions/intellij/build.gradle.kts +++ b/extensions/intellij/build.gradle.kts @@ -130,6 +130,10 @@ tasks { // Configure UI tests plugin // Read more: https://github.com/JetBrains/intellij-ui-test-robot runIdeForUiTests { + environment( + "CONTINUE_GLOBAL_DIR", + "${rootProject.projectDir}/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/test-continue" + ) systemProperty("robot-server.port", "8082") systemProperty("ide.mac.message.dialogs.as.sheets", "false") systemProperty("jb.privacy.policy.text", "") diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt index 6279e03f7..8a9c8003f 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt @@ -287,12 +287,13 @@ class AutocompleteService(private val project: Project) { } private fun isInjectedFile(editor: Editor): Boolean { - val psiFile = runReadAction { PsiDocumentManager.getInstance(project).getPsiFile(editor.document) } - if (psiFile == null) { - return false - } - val response = runReadAction { psiFile.isInjectedText() } - return response + return ApplicationManager.getApplication().executeOnPooledThread { + ApplicationManager.getApplication().runReadAction { + val psiFile = + PsiDocumentManager.getInstance(project).getPsiFile(editor.document) ?: return@runReadAction false + return@runReadAction psiFile.isInjectedText() + } + }.get() } fun hideCompletions(editor: Editor) { diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt index 1f105738a..a250bf053 100644 --- a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt +++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt @@ -56,9 +56,9 @@ class Autocomplete {init { idea { with(textEditor()) { - val USER_MESSAGE = "TEST_USER_MESSAGE_0" - editor.insertTextAtLine(0, 0, USER_MESSAGE) - editor.clickOnOffset(USER_MESSAGE.length) + val userMsg = "TEST_USER_MESSAGE_0" + editor.insertTextAtLine(0, 0, userMsg) + editor.clickOnOffset(userMsg.length) keyboard { enterText(" ") From a835ac1126eb5e9bff4dcb4a49536c69dc4b1dcb Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 20 Dec 2024 10:10:03 -0800 Subject: [PATCH 006/114] fix chat indexing peek --- core/indexing/docs/DocsService.ts | 8 +++++++- .../components/indexing/ChatIndexingPeeks.tsx | 20 ++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index f35f83466..5480dc161 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -710,14 +710,20 @@ export default class DocsService { await db.exec("PRAGMA busy_timeout = 3000;"); await runSqliteMigrations(db); - + // First create the table if it doesn't exist await db.exec(`CREATE TABLE IF NOT EXISTS ${DocsService.sqlitebTableName} ( id INTEGER PRIMARY KEY AUTOINCREMENT, title STRING NOT NULL, startUrl STRING NOT NULL UNIQUE, favicon STRING + embeddingsProviderId STRING )`); + // embeddingsProviderId was added later + await db.exec(`ALTER TABLE ${DocsService.sqlitebTableName} + ADD COLUMN IF NOT EXISTS embeddingsProviderId STRING; + `); + this.sqliteDb = db; } diff --git a/gui/src/components/indexing/ChatIndexingPeeks.tsx b/gui/src/components/indexing/ChatIndexingPeeks.tsx index 1ec1076c0..dbca84b05 100644 --- a/gui/src/components/indexing/ChatIndexingPeeks.tsx +++ b/gui/src/components/indexing/ChatIndexingPeeks.tsx @@ -75,25 +75,31 @@ function ChatIndexingPeek({ state }: ChatIndexingPeekProps) { } function ChatIndexingPeeks() { + const config = useAppSelector((store) => store.config.config); const indexingStatuses = useAppSelector( (store) => store.indexing.indexing.statuses, ); const mergedIndexingStates: MergedIndexingState[] = useMemo(() => { const mergedStates: MergedIndexingState[] = []; - const docsStates = Object.values(indexingStatuses).filter( - (status) => status.type === "docs" && status.status === "indexing", - ); - if (docsStates.length > 0) { + const configDocs = config?.docs ?? []; + const docsIndexing: IndexingStatus[] = []; + configDocs.forEach((doc) => { + const status = indexingStatuses[doc.startUrl]; + if (status && status.status === "indexing") { + docsIndexing.push(status); + } + }); + if (docsIndexing.length > 0) { mergedStates.push({ displayName: "Docs indexing", type: "docs", - titles: docsStates.map((state) => state.title), - progressPercentage: mergeProgress(docsStates), + titles: docsIndexing.map((doc) => doc.title), + progressPercentage: mergeProgress(docsIndexing), }); } return mergedStates; - }, [indexingStatuses]); + }, [config, indexingStatuses]); if (!mergedIndexingStates.length) return null; From eed7415ca3b8de94d64d9e8f001bf8b4dd59726c Mon Sep 17 00:00:00 2001 From: Test Date: Fri, 20 Dec 2024 12:24:01 -0800 Subject: [PATCH 007/114] chore: update binary build --- binary/build.js | 39 +++++++++++++++++++++++++---- extensions/intellij/CONTRIBUTING.md | 4 ++- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/binary/build.js b/binary/build.js index 5d7b6061f..6e3039cd5 100644 --- a/binary/build.js +++ b/binary/build.js @@ -1,3 +1,15 @@ +/** + * NOTE: The `--esbuild-only` flag is currently not working due to + * issues with sqlite bindings looking for a package.json + * + * Example usage + * + * node build.js # Full build + * node build.js --esbuild-only --os darwin # Only runs esbuild step for darwin + * node build.js --os linux # Full build for linux only + * node build.js --esbuild-only # Only runs esbuild step for all platforms + */ + const esbuild = require("esbuild"); const fs = require("fs"); const path = require("path"); @@ -38,12 +50,28 @@ const assetBackups = [ ]; let esbuildOnly = false; -for (let i = 2; i < process.argv.length; i++) { - if (process.argv[i] === "--esbuild-only") { +let specificOs = null; + +// Parse command line arguments +const args = process.argv.slice(2); + +for (let i = 0; i < args.length; i++) { + if (args[i] === "--esbuild-only") { esbuildOnly = true; } - if (process.argv[i - 1] === "--target") { - targets = [process.argv[i]]; + if (args[i] === "--target" && args[i + 1]) { + targets = [args[i + 1]]; + i++; // Skip the next argument since we've consumed it + } + if (args[i] === "--os" && args[i + 1]) { + const os = args[i + 1].toLowerCase(); + specificOs = os; + targets = targets.filter((target) => target.startsWith(os)); + if (targets.length === 0) { + console.error(`[error] No targets found for OS: ${os}`); + process.exit(1); + } + i++; // Skip the next argument since we've consumed it } } @@ -282,7 +310,8 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) { fs.unlinkSync("out/package.json"); const pathsToVerify = []; - for (target of targets) { + + for (const target of targets) { const exe = target.startsWith("win") ? ".exe" : ""; const targetDir = `bin/${target}`; pathsToVerify.push( diff --git a/extensions/intellij/CONTRIBUTING.md b/extensions/intellij/CONTRIBUTING.md index d37aaa2c4..836eaa7b6 100644 --- a/extensions/intellij/CONTRIBUTING.md +++ b/extensions/intellij/CONTRIBUTING.md @@ -101,7 +101,9 @@ toolbar. _Run | Debugging Actions | Reload Changed Classes`_ - This will often fail on new imports, schema changes etc. In that case, you need to stop and restart the extension - `gui`: Changes will be reloaded automatically -- `core`: Run `npm run build` from the `binary` directory (requires restarting the `Start Core Dev Server` task) +- `core`: Run `npm run build -- --os [darwin | linux | win32]` from the `binary` directory (requires + restarting the + `Start Core Dev Server` task) ### Setting breakpoints From baca0805bf9935f7322100ca42e29f0224c1afe5 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 20 Dec 2024 12:27:42 -0800 Subject: [PATCH 008/114] embeddings provider in docs --- core/context/providers/DocsContextProvider.ts | 41 ++-- core/core.ts | 2 +- core/indexing/docs/DocsService.ts | 196 ++++++++---------- core/util/GlobalContext.test.ts | 21 +- core/util/GlobalContext.ts | 1 - gui/src/components/dialogs/AddDocsDialog.tsx | 16 ++ .../components/indexing/DocsIndexingPeeks.tsx | 1 + 7 files changed, 135 insertions(+), 143 deletions(-) diff --git a/core/context/providers/DocsContextProvider.ts b/core/context/providers/DocsContextProvider.ts index 6eab55fa4..47542bc1c 100644 --- a/core/context/providers/DocsContextProvider.ts +++ b/core/context/providers/DocsContextProvider.ts @@ -80,22 +80,28 @@ class DocsContextProvider extends BaseContextProvider { query: string, extras: ContextProviderExtras, ): Promise { + // Get docs service const docsService = DocsService.getSingleton(); - if (!docsService) { console.error(`${DocsService.name} has not been initialized`); return []; } - await docsService.isInitialized; + + // Get chunks let chunks = await docsService.retrieveChunksFromQuery( extras.fullInput, // confusing: fullInput = the query, query = startUrl in this case query, this.options?.nRetrieve ?? DocsContextProvider.nRetrieve, ); + if(!chunks?.length) { + return []; + } + // We found chunks, so check if there's a favicon for the docs page const favicon = await docsService.getFavicon(query); + // Rerank if there's a rerankder if (extras.reranker) { chunks = await this._rerankChunks( chunks, @@ -139,18 +145,30 @@ class DocsContextProvider extends BaseContextProvider { async loadSubmenuItems( args: LoadSubmenuItemsArgs, ): Promise { + // Get docs service const docsService = DocsService.getSingleton(); - if (!docsService) { console.error(`${DocsService.name} has not been initialized`); return []; } + await docsService.isInitialized; - const docs = (await docsService.listMetadata()) ?? []; - const canUsePreindexedDocs = await docsService.canUsePreindexedDocs(); - + // Create map of docs url -> submenu item const submenuItemsMap = new Map(); + // Add custom docs from config + const docs = (await docsService.listMetadata()) ?? []; + for (const { startUrl, title, favicon } of docs) { + submenuItemsMap.set(startUrl, { + title,\ + id: startUrl, + description: new URL(startUrl).hostname, + icon: favicon, + }); + } + + // Add pre-indexed docs if supported + const canUsePreindexedDocs = await docsService.canUsePreindexedDocs(); if (canUsePreindexedDocs) { for (const { startUrl, title } of Object.values(preIndexedDocs)) { submenuItemsMap.set(startUrl, { @@ -164,17 +182,8 @@ class DocsContextProvider extends BaseContextProvider { } } - for (const { startUrl, title, favicon } of docs) { - submenuItemsMap.set(startUrl, { - title, - id: startUrl, - description: new URL(startUrl).hostname, - icon: favicon, - }); - } - + // Create array and sort if pre-indexed is supported const submenuItems = Array.from(submenuItemsMap.values()); - if (canUsePreindexedDocs) { return this._sortByPreIndexedDocs(submenuItems); } diff --git a/core/core.ts b/core/core.ts index fb3840d05..bea254c81 100644 --- a/core/core.ts +++ b/core/core.ts @@ -286,7 +286,7 @@ export class Core { }); on("context/indexDocs", async (msg) => { - await this.docsService.syncOrReindexAllDocsWithPrompt(msg.data.reIndex); + await this.docsService.syncDocsWithPrompt(msg.data.reIndex); }); on("context/loadSubmenuItems", async (msg) => { diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index 5480dc161..0af6aa28f 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -185,7 +185,6 @@ export default class DocsService { abort(startUrl: string) { const status = this.statuses.get(startUrl); if (status) { - this.docsIndexingQueue.delete(startUrl); this.handleStatusUpdate({ ...status, status: "aborted", @@ -193,6 +192,7 @@ export default class DocsService { description: "Canceled", }); } + this.docsIndexingQueue.delete(startUrl); } isAborted(startUrl: string) { @@ -256,93 +256,79 @@ export default class DocsService { this.docsCrawler = new DocsCrawler(this.ide, newConfig); + if (this.config.disableIndexing) { + return; + } + + // No point in indexing if no docs context provider + const hasDocsContextProvider = this.hasDocsContextProvider(); + if (!hasDocsContextProvider) { + return; + } + // Skip docs indexing if not supported + // No warning message here because would show on ANY config update const unsupported = await this.isUsingUnsupportedPreIndexedEmbeddingsProvider(); if (unsupported) { return; } - await this.syncOrReindexAllDocs(newConfig, oldConfig); + await this.syncDocs(oldConfig, newConfig, false); } } - private async syncOrReindexAllDocs( - newConfig: ContinueConfig, - oldConfig?: ContinueConfig, - ) { - // On embeddings provider change, reindex all non-preindexed docs - // change = doesn't match last successful embeddings provider - const curEmbeddingsProviderId = this.globalContext.get( - "curEmbeddingsProviderId", - ); - if ( - !curEmbeddingsProviderId || - curEmbeddingsProviderId !== newConfig.embeddingsProvider.embeddingId - ) { - // If not set, we're initializing - const currentDocs = await this.listMetadata(); - if (currentDocs.length > 0) { - await this.reindexDocsOnNewEmbeddingsProvider(); - return; - } - } - - await this.syncDocsOnConfigUpdate(oldConfig, newConfig); - } - - async syncOrReindexAllDocsWithPrompt(reIndex: boolean = false) { + async syncDocsWithPrompt(reIndex: boolean = false) { if (!this.hasDocsContextProvider()) { - const didAddDocsContextProvider = - await this.showAddDocsContextProviderToast(); + const actionMsg = "Add 'docs' context provider"; + const res = await this.ide.showToast( + "info", + "Starting docs indexing", + actionMsg, + ); - if (!didAddDocsContextProvider) { + if (res === actionMsg) { + addContextProvider({ + name: DocsContextProvider.description.title, + params: {}, + }); + + void this.ide.showToast( + "info", + "Successfuly added docs context provider", + ); + } else { return; } } - await this.syncOrReindexAllDocs(this.config); + await this.syncDocs(undefined, this.config, reIndex); void this.ide.showToast("info", "Docs indexing completed"); } + // Returns true if startUrl has been indexed with current embeddingsProvider async hasMetadata(startUrl: string): Promise> { const db = await this.getOrCreateSqliteDb(); const title = await db.get( - `SELECT title FROM ${DocsService.sqlitebTableName} WHERE startUrl = ?`, + `SELECT title FROM ${DocsService.sqlitebTableName} WHERE startUrl = ? AND embeddingsProviderId = ?`, startUrl, + this.config.embeddingsProvider.embeddingId, ); return !!title; } - async showAddDocsContextProviderToast() { - const actionMsg = "Add 'docs' context provider"; - const res = await this.ide.showToast( - "info", - "Starting docs indexing", - actionMsg, - ); - - if (res === actionMsg) { - addContextProvider({ - name: DocsContextProvider.description.title, - params: {}, - }); - - void this.ide.showToast( - "info", - "Successfuly added docs context provider", - ); - } - - return res === actionMsg; - } - async listMetadata() { + const embeddingsProvider = this.config.embeddingsProvider; + if (!embeddingsProvider) { + return []; + } const db = await this.getOrCreateSqliteDb(); const docs = await db.all( - `SELECT title, startUrl, favicon FROM ${DocsService.sqlitebTableName}`, + `SELECT title, startUrl, favicon FROM ${DocsService.sqlitebTableName} + WHERE embeddingsProviderId = ?`, + embeddingsProvider.embeddingId, ); return docs; @@ -363,15 +349,21 @@ export default class DocsService { ): Promise { const { startUrl } = siteIndexingConfig; + const canUsePreindexedDocs = await this.canUsePreindexedDocs(); + if (canUsePreindexedDocs) { + const preIndexedDoc = preIndexedDocs[startUrl]; + const isPreIndexedDoc = !!preIndexedDoc; + if (isPreIndexedDoc) { + console.warn("Can only use pre"); + } + } + // Queue - indexAndAdd is invoked circularly by config edits. This prevents duplicate runs if (this.docsIndexingQueue.has(startUrl)) { return; } const embeddingsProvider = await this.getEmbeddingsProvider(); - - this.docsIndexingQueue.add(startUrl); - const indexExists = await this.hasMetadata(startUrl); // Build status update - most of it is fixed values @@ -404,12 +396,9 @@ export default class DocsService { return; } } + this.docsIndexingQueue.add(startUrl); - // If not preindexed - const isPreIndexedDoc = !!preIndexedDocs[siteIndexingConfig.startUrl]; - if (!isPreIndexedDoc) { - this.addToConfig(siteIndexingConfig); - } + this.addToConfig(siteIndexingConfig); try { this.handleStatusUpdate({ @@ -650,13 +639,18 @@ export default class DocsService { return await this.retrieveChunks(startUrl, vector, nRetrieve); } + // This is split into its own function so that it can be recursive + // in the case of fetching preindexed docs from s3 async retrieveChunks( startUrl: string, vector: number[], nRetrieve: number, isRetry: boolean = false, ): Promise { - const isPreIndexedDoc = !!preIndexedDocs[startUrl]; + const preIndexedDoc = preIndexedDocs[startUrl]; + const isPreIndexedDoc = !!preIndexedDoc; + + // Lance doesn't have an embeddingsprovider column, instead it includes it in the table name const table = await this.getOrCreateLanceTable({ initializationVector: vector, isPreIndexedDoc, @@ -673,19 +667,21 @@ export default class DocsService { console.warn("Error retrieving chunks from LanceDB", e); } - const hasIndexedDoc = await this.hasMetadata(startUrl); - - if (!hasIndexedDoc && docs.length === 0) { - const preIndexedDoc = preIndexedDocs[startUrl]; - - if (isRetry || !preIndexedDoc) { + // No docs are found for preindexed? try fetching once + if (docs.length === 0 && isPreIndexedDoc) { + if (isRetry) { return []; } - await this.fetchAndAddPreIndexedDocEmbeddings(preIndexedDoc.title); return await this.retrieveChunks(startUrl, vector, nRetrieve, true); } + if (isPreIndexedDoc) { + void Telemetry.capture("docs_pre_indexed_doc_used", { + doc: preIndexedDoc["title"], + }); + } + return docs.map((doc) => ({ digest: doc.path, filepath: doc.path, @@ -747,9 +743,10 @@ export default class DocsService { Sync with no embeddings provider change Ignores pre-indexed docs */ - private async syncDocsOnConfigUpdate( + private async syncDocs( oldConfig: ContinueConfig | undefined, newConfig: ContinueConfig, + reindex: boolean, ) { try { this.isSyncing = true; @@ -869,9 +866,7 @@ export default class DocsService { return name.replace(/[^a-zA-Z0-9_.-]/g, "_"); } - private async getLanceTableNameFromEmbeddingsProvider( - isPreIndexedDoc: boolean, - ) { + private async getLanceTableName(isPreIndexedDoc: boolean) { const embeddingsProvider = await this.getEmbeddingsProvider(isPreIndexedDoc); @@ -892,7 +887,7 @@ export default class DocsService { const conn = await lancedb.connect(getLanceDbPath()); const tableNames = await conn.tableNames(); const tableNameFromEmbeddingsProvider = - await this.getLanceTableNameFromEmbeddingsProvider(!!isPreIndexedDoc); + await this.getLanceTableName(!!isPreIndexedDoc); if (!tableNames.includes(tableNameFromEmbeddingsProvider)) { if (initializationVector) { @@ -949,10 +944,11 @@ export default class DocsService { }: AddParams) { const db = await this.getOrCreateSqliteDb(); await db.run( - `INSERT INTO ${DocsService.sqlitebTableName} (title, startUrl, favicon) VALUES (?, ?, ?)`, + `INSERT INTO ${DocsService.sqlitebTableName} (title, startUrl, favicon, embeddingsProviderId) VALUES (?, ?, ?, ?)`, title, startUrl, favicon, + this.config.embeddingsProvider.embeddingId, ); } @@ -960,13 +956,23 @@ export default class DocsService { // Handles the case where a user has manually added the doc to config.json // so it already exists in the file const doesDocExist = this.config.docs?.some( - (doc) => doc.startUrl === siteIndexingConfig.startUrl, + (doc) => + doc.startUrl === siteIndexingConfig.startUrl && + doc.faviconUrl === siteIndexingConfig.faviconUrl && + siteIndexingConfig.title === doc.title, + // siteIndexingConfig.maxDepth === doc.maxDepth && + // doc.rootUrl === siteIndexingConfig.rootUrl, ); if (!doesDocExist) { editConfigJson((config) => ({ ...config, - docs: [...(config.docs ?? []), siteIndexingConfig], + docs: [ + ...(config.docs?.filter( + (doc) => doc.startUrl !== siteIndexingConfig.startUrl, + ) ?? []), + siteIndexingConfig, + ], })); } } @@ -1017,34 +1023,4 @@ export default class DocsService { this.deleteFromConfig(startUrl); this.messenger?.send("refreshSubmenuItems", undefined); } - - /** - * Currently this deletes re-crawls + re-indexes all docs. - * A more optimal solution in the future will be to create - * a per-embeddings-provider table for docs. - */ - private async reindexDocsOnNewEmbeddingsProvider() { - // We use config as our source of truth here since it contains additional information - // needed for re-crawling such as `faviconUrl` and `maxDepth`. - const { docs, embeddingsProvider } = this.config; - - if (!docs || docs.length === 0) { - return; - } - - console.log( - `Reindexing non-preindexed docs with new embeddings provider: ${embeddingsProvider.embeddingId}`, - ); - await Promise.allSettled(docs.map((doc) => this.indexAndAdd(doc))); - - // Important that this only is invoked after we have successfully - // cleared and reindex the docs so that the table cannot end up in an - // invalid state. - this.globalContext.update( - "curEmbeddingsProviderId", - embeddingsProvider.embeddingId, - ); - - console.log("Completed reindexing of all non-preindexed docs"); - } } diff --git a/core/util/GlobalContext.test.ts b/core/util/GlobalContext.test.ts index 6014a1d1d..0d6b9d799 100644 --- a/core/util/GlobalContext.test.ts +++ b/core/util/GlobalContext.test.ts @@ -75,7 +75,7 @@ describe("GlobalContext", () => { const value = globalContext.get("indexingPaused"); expect(value).toBeUndefined(); expect(consoleWarnMock).toHaveBeenCalledWith( - expect.stringContaining("Error parsing global context") + expect.stringContaining("Error parsing global context"), ); // Clean up @@ -99,7 +99,7 @@ describe("GlobalContext", () => { expect(value).toBeUndefined(); expect(consoleWarnMock).toHaveBeenCalledWith( - expect.stringContaining("Error updating global context") + expect.stringContaining("Error updating global context"), ); // Clean up @@ -113,10 +113,10 @@ describe("GlobalContext", () => { expect(globalContext.get("indexingPaused")).toBe(true); expect(globalContext.get("selectedTabAutocompleteModel")).toBe( - "test-model" + "test-model", ); expect(globalContext.get("hasDismissedConfigTsNoticeJetBrains")).toBe( - false + false, ); }); @@ -125,16 +125,7 @@ describe("GlobalContext", () => { expect(globalContext.get("hasAlreadyCreatedAPromptFile")).toBe(true); }); - it("should handle curEmbeddingsProviderId correctly", () => { - globalContext.update("curEmbeddingsProviderId", "test-provider-id"); - expect(globalContext.get("curEmbeddingsProviderId")).toBe( - "test-provider-id" - ); - }); - it("should not crash or throw when getting a key that hasn't been set", () => { - expect( - globalContext.get("hasAlreadyCreatedAPromptFile") - ).toBeUndefined(); + expect(globalContext.get("hasAlreadyCreatedAPromptFile")).toBeUndefined(); }); -}); \ No newline at end of file +}); diff --git a/core/util/GlobalContext.ts b/core/util/GlobalContext.ts index 1095234d8..5e4f7c6d7 100644 --- a/core/util/GlobalContext.ts +++ b/core/util/GlobalContext.ts @@ -12,7 +12,6 @@ export type GlobalContextType = { * * For VS Code users, it is unnecessary since we use transformers.js by default. */ - curEmbeddingsProviderId: string; hasDismissedConfigTsNoticeJetBrains: boolean; hasAlreadyCreatedAPromptFile: boolean; showConfigUpdateToast: boolean; diff --git a/gui/src/components/dialogs/AddDocsDialog.tsx b/gui/src/components/dialogs/AddDocsDialog.tsx index 0bcd40fd9..f816369c8 100644 --- a/gui/src/components/dialogs/AddDocsDialog.tsx +++ b/gui/src/components/dialogs/AddDocsDialog.tsx @@ -17,8 +17,10 @@ import DocsIndexingPeeks from "../indexing/DocsIndexingPeeks"; import preIndexedDocs from "core/indexing/docs/preIndexedDocs"; import { updateIndexingStatus } from "../../redux/slices/indexingSlice"; import { useAppSelector } from "../../redux/hooks"; +import { setConfig } from "../../redux/slices/configSlice"; function AddDocsDialog() { + const config = useAppSelector((store) => store.config.config); const posthog = usePostHog(); const dispatch = useDispatch(); @@ -125,6 +127,7 @@ function AddDocsDialog() { } const suggestedTitle = docsResult.details.title ?? docsResult.packageInfo.name; + if (docsResult.details?.docsLinkWarning) { setTitle(suggestedTitle); setStartUrl(docsResult.details.docsLink); @@ -143,6 +146,19 @@ function AddDocsDialog() { // Optimistic status update dispatch( + setConfig({ + ...config, + docs: [ + ...(config.docs?.filter( + (doc) => doc.startUrl !== docsResult.details.docsLink, + ) ?? []), + { + startUrl: docsResult.details.docsLink, + title: suggestedTitle, + faviconUrl: undefined, + }, + ], + }), updateIndexingStatus({ type: "docs", description: "Initializing", diff --git a/gui/src/components/indexing/DocsIndexingPeeks.tsx b/gui/src/components/indexing/DocsIndexingPeeks.tsx index f659b48f9..833c71430 100644 --- a/gui/src/components/indexing/DocsIndexingPeeks.tsx +++ b/gui/src/components/indexing/DocsIndexingPeeks.tsx @@ -3,6 +3,7 @@ import { IndexingStatus } from "core"; import { useMemo } from "react"; import { useNavigate } from "react-router-dom"; import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice"; +import { useAppSelector } from "../../redux/hooks"; export interface DocsIndexingPeekProps { status: IndexingStatus; From ada10398f748aa1cd94d44ba42aeee741b3b7d31 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 20 Dec 2024 15:26:19 -0800 Subject: [PATCH 009/114] embeddingsprovider docs column --- core/context/providers/DocsContextProvider.ts | 4 +- core/indexing/docs/DocsService.ts | 25 +++++------ core/indexing/docs/migrations.ts | 43 +++++++++++-------- 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/core/context/providers/DocsContextProvider.ts b/core/context/providers/DocsContextProvider.ts index 47542bc1c..9ee50c256 100644 --- a/core/context/providers/DocsContextProvider.ts +++ b/core/context/providers/DocsContextProvider.ts @@ -94,7 +94,7 @@ class DocsContextProvider extends BaseContextProvider { query, this.options?.nRetrieve ?? DocsContextProvider.nRetrieve, ); - if(!chunks?.length) { + if (!chunks?.length) { return []; } @@ -160,7 +160,7 @@ class DocsContextProvider extends BaseContextProvider { const docs = (await docsService.listMetadata()) ?? []; for (const { startUrl, title, favicon } of docs) { submenuItemsMap.set(startUrl, { - title,\ + title, id: startUrl, description: new URL(startUrl).hostname, icon: favicon, diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index 0af6aa28f..a65c65879 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -17,7 +17,6 @@ import DocsContextProvider from "../../context/providers/DocsContextProvider"; import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbeddingsProvider"; import { FromCoreProtocol, ToCoreProtocol } from "../../protocol"; import { fetchFavicon, getFaviconBase64 } from "../../util/fetchFavicon"; -import { GlobalContext } from "../../util/GlobalContext"; import { IMessenger } from "../../protocol/messenger"; import { editConfigJson, @@ -87,7 +86,6 @@ export default class DocsService { public isSyncing: boolean = false; private docsIndexingQueue = new Set(); - private globalContext = new GlobalContext(); private lanceTableNamesSet = new Set(); private config!: ContinueConfig; @@ -144,7 +142,7 @@ export default class DocsService { this.config.docs?.forEach((doc) => { if (!doc.startUrl) { - console.error("Invalid config docs entry, no start"); + console.error("Invalid config docs entry, no start url", doc.title); return; } @@ -396,11 +394,12 @@ export default class DocsService { return; } } - this.docsIndexingQueue.add(startUrl); - - this.addToConfig(siteIndexingConfig); try { + this.docsIndexingQueue.add(startUrl); + + this.addToConfig(siteIndexingConfig); + this.handleStatusUpdate({ ...fixedStatus, status: "indexing", @@ -710,16 +709,11 @@ export default class DocsService { await db.exec(`CREATE TABLE IF NOT EXISTS ${DocsService.sqlitebTableName} ( id INTEGER PRIMARY KEY AUTOINCREMENT, title STRING NOT NULL, - startUrl STRING NOT NULL UNIQUE, - favicon STRING + startUrl STRING NOT NULL, + favicon STRING, embeddingsProviderId STRING )`); - // embeddingsProviderId was added later - await db.exec(`ALTER TABLE ${DocsService.sqlitebTableName} - ADD COLUMN IF NOT EXISTS embeddingsProviderId STRING; - `); - this.sqliteDb = db; } @@ -756,6 +750,7 @@ export default class DocsService { const newConfigDocs = newConfig.docs || []; const newConfigStartUrls = newConfigDocs.map((doc) => doc.startUrl); + // NOTE since listMetadata filters by embeddings provider id embedding model changes are accounted for here const currentlyIndexedDocs = await this.listMetadata(); const currentStartUrls = currentlyIndexedDocs.map((doc) => doc.startUrl); @@ -955,7 +950,7 @@ export default class DocsService { private addToConfig(siteIndexingConfig: SiteIndexingConfig) { // Handles the case where a user has manually added the doc to config.json // so it already exists in the file - const doesDocExist = this.config.docs?.some( + const doesEquivalentDocExist = this.config.docs?.some( (doc) => doc.startUrl === siteIndexingConfig.startUrl && doc.faviconUrl === siteIndexingConfig.faviconUrl && @@ -964,7 +959,7 @@ export default class DocsService { // doc.rootUrl === siteIndexingConfig.rootUrl, ); - if (!doesDocExist) { + if (!doesEquivalentDocExist) { editConfigJson((config) => ({ ...config, docs: [ diff --git a/core/indexing/docs/migrations.ts b/core/indexing/docs/migrations.ts index e3483d507..b84b0b842 100644 --- a/core/indexing/docs/migrations.ts +++ b/core/indexing/docs/migrations.ts @@ -27,41 +27,50 @@ export async function runLanceMigrations(table: Table) { export async function runSqliteMigrations(db: Database) { await new Promise((resolve) => { - migrate( + void migrate( "sqlite_modify_docs_columns_and_copy_to_config", async () => { try { const pragma = await db.all( - `PRAGMA table_info(${DocsService.sqlitebTableName})`, + `PRAGMA table_info(${DocsService.sqlitebTableName});`, ); const hasFaviconCol = pragma.some( (pragma) => pragma.name === "favicon", ); + if (!hasFaviconCol) { + await db.exec( + `ALTER TABLE ${DocsService.sqlitebTableName} ADD COLUMN favicon BLOB;`, + ); + } + const hasBaseUrlCol = pragma.some( (pragma) => pragma.name === "baseUrl", ); - - if (!hasFaviconCol) { - await db.exec( - `ALTER TABLE ${DocsService.sqlitebTableName} ADD COLUMN favicon BLOB`, - ); - } - if (hasBaseUrlCol) { await db.exec( - `ALTER TABLE ${DocsService.sqlitebTableName} RENAME COLUMN baseUrl TO startUrl`, + `ALTER TABLE ${DocsService.sqlitebTableName} RENAME COLUMN baseUrl TO startUrl;`, ); } - const sqliteDocs = await db.all< - Array> - >(`SELECT title, startUrl FROM ${DocsService.sqlitebTableName}`); + const hasEmbeddingsProviderColumn = pragma.some( + (pragma) => pragma.name === "embeddingsProviderId", + ); + if (!hasEmbeddingsProviderColumn) { + // gotta just delete in this case since old docs will be unusable anyway + await db.exec(`DROP TABLE ${DocsService.sqlitebTableName};`); + } - editConfigJson((config) => ({ - ...config, - docs: [...(config.docs || []), ...sqliteDocs], - })); + const needsToUpdateConfig = !hasFaviconCol || hasBaseUrlCol; + if (needsToUpdateConfig) { + const sqliteDocs = await db.all< + Array> + >(`SELECT title, startUrl FROM ${DocsService.sqlitebTableName}`); + editConfigJson((config) => ({ + ...config, + docs: [...(config.docs || []), ...sqliteDocs], + })); + } } finally { resolve(undefined); } From 82fd94d6b1ab64473707f32a63ef3c46ac9cd5fb Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 20 Dec 2024 15:51:25 -0800 Subject: [PATCH 010/114] config/addContextProvider message --- core/core.ts | 13 ++++++- core/indexing/docs/DocsService.ts | 7 +++- core/protocol/core.ts | 2 + core/protocol/passThrough.ts | 1 + .../toolWindow/ContinueBrowser.kt | 1 + .../indexing/DocsIndexingStatuses.tsx | 38 ++++++++++++++++++- 6 files changed, 58 insertions(+), 4 deletions(-) diff --git a/core/core.ts b/core/core.ts index bea254c81..3d00db55e 100644 --- a/core/core.ts +++ b/core/core.ts @@ -12,7 +12,12 @@ import { setupLocalConfigAfterFreeTrial, setupQuickstartConfig, } from "./config/onboarding"; -import { addModel, addOpenAIKey, deleteModel } from "./config/util"; +import { + addContextProvider, + addModel, + addOpenAIKey, + deleteModel, +} from "./config/util"; import { recentlyEditedFilesCache } from "./context/retrieval/recentlyEditedFilesCache"; import { ContinueServerClient } from "./continueServer/stubs/client"; import { getAuthUrlForTokenPage } from "./control-plane/auth/index"; @@ -276,6 +281,10 @@ export class Core { return this.configHandler.listProfiles(); }); + on("config/addContextProvider", async (msg) => { + addContextProvider(msg.data); + }); + // Context providers on("context/addDocs", async (msg) => { void this.docsService.indexAndAdd(msg.data); @@ -794,7 +803,7 @@ export class Core { }); on("indexing/setPaused", async (msg) => { if (msg.data.type === "docs") { - // this.docsService.setPaused(msg.data.id, msg.data.paused); + // this.docsService.setPaused(msg.data.id, msg.data.paused); // not supported yet } }); on("docs/getSuggestedDocs", async (msg) => { diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index a65c65879..d81a4ec19 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -345,6 +345,10 @@ export default class DocsService { siteIndexingConfig: SiteIndexingConfig, reIndex: boolean = false, ): Promise { + if (this.config.disableIndexing) { + console.warn("Attempting to add/index docs when indexing is disabled"); + return; + } const { startUrl } = siteIndexingConfig; const canUsePreindexedDocs = await this.canUsePreindexedDocs(); @@ -352,7 +356,8 @@ export default class DocsService { const preIndexedDoc = preIndexedDocs[startUrl]; const isPreIndexedDoc = !!preIndexedDoc; if (isPreIndexedDoc) { - console.warn("Can only use pre"); + console.warn("Can not override pre-indexed start urls"); + return; } } diff --git a/core/protocol/core.ts b/core/protocol/core.ts index 9a7d85510..520f2dc41 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -6,6 +6,7 @@ import type { ChatMessage, ContextItem, ContextItemWithId, + ContextProviderWithParams, ContextSubmenuItem, DiffLine, FileSymbolMap, @@ -66,6 +67,7 @@ export type ToCoreFromIdeOrWebviewProtocol = { { config: BrowserSerializedContinueConfig; profileId: string }, ]; "config/deleteModel": [{ title: string }, void]; + "config/addContextProvider": [ContextProviderWithParams, void]; "config/reload": [undefined, BrowserSerializedContinueConfig]; "config/listProfiles": [undefined, ProfileDescription[]]; "config/openProfile": [{ profileId: string | undefined }, void]; diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index 0bbb5699a..756b3db54 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -16,6 +16,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] = "history/save", "devdata/log", "config/addModel", + "config/addContextProvider", "config/newPromptFile", "config/ideSettingsUpdate", "config/getSerializedProfileInfo", diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt index d682b8a3a..5523bdeff 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt @@ -26,6 +26,7 @@ class ContinueBrowser(val project: Project, url: String) { "history/save", "devdata/log", "config/addModel", + "config/addContextProvider", "config/newPromptFile", "config/ideSettingsUpdate", "config/getSerializedProfileInfo", diff --git a/gui/src/components/indexing/DocsIndexingStatuses.tsx b/gui/src/components/indexing/DocsIndexingStatuses.tsx index 76feb21e0..9a9ffb4df 100644 --- a/gui/src/components/indexing/DocsIndexingStatuses.tsx +++ b/gui/src/components/indexing/DocsIndexingStatuses.tsx @@ -4,11 +4,24 @@ import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice"; import AddDocsDialog from "../dialogs/AddDocsDialog"; import DocsIndexingStatus from "./DocsIndexingStatus"; import { useAppSelector } from "../../redux/hooks"; +import { useContext, useMemo } from "react"; +import { ExclamationTriangleIcon } from "@heroicons/react/24/outline"; +import { IdeMessengerContext } from "../../context/IdeMessenger"; function DocsIndexingStatuses() { const dispatch = useDispatch(); const config = useAppSelector((store) => store.config.config); - const configDocs = config.docs ?? []; + const ideMessenger = useContext(IdeMessengerContext); + + const hasDocsProvider = useMemo(() => { + return !!config.contextProviders?.some( + (provider) => provider.title === "docs", + ); + }, [config]); + + const configDocs = useMemo(() => { + return config.docs ?? []; + }, [config]); return (

@@ -33,6 +46,29 @@ function DocsIndexingStatuses() { : "No docs yet"}
+ {!hasDocsProvider && ( +
+
+
+ +
+ + @docs is not in your config + +
+ { + ideMessenger.post("config/addContextProvider", { + name: "docs", + params: {}, + }); + }} + > + Add @docs to my config + +
+ )}
{configDocs.length === 0 && ( Date: Fri, 20 Dec 2024 16:46:19 -0800 Subject: [PATCH 011/114] messaging --- core/indexing/docs/DocsService.ts | 23 +++++++---- .../indexing/DocsIndexingStatus.tsx | 41 ++++++++++--------- .../indexing/DocsIndexingStatuses.tsx | 15 ++++--- .../IndexingProgressSubtext.tsx | 2 +- 4 files changed, 47 insertions(+), 34 deletions(-) diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index d81a4ec19..7a35e8f24 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -193,8 +193,15 @@ export default class DocsService { this.docsIndexingQueue.delete(startUrl); } - isAborted(startUrl: string) { - return this.statuses.get(startUrl)?.status === "aborted"; + shouldCancel(startUrl: string) { + const isAborted = this.statuses.get(startUrl)?.status === "aborted"; + if (isAborted) { + return true; + } + if (this.config.disableIndexing) { + this.abort(startUrl); + return true; + } } // NOTE Pausing not supported for docs yet @@ -421,7 +428,7 @@ export default class DocsService { estimatedProgress += 1 / 2 ** (processedPages + 1); // NOTE - during "indexing" phase, check if aborted before each status update - if (this.isAborted(startUrl)) { + if (this.shouldCancel(startUrl)) { return; } this.handleStatusUpdate({ @@ -459,7 +466,7 @@ export default class DocsService { for (let i = 0; i < articles.length; i++) { const article = articles[i]; - if (this.isAborted(startUrl)) { + if (this.shouldCancel(startUrl)) { return; } this.handleStatusUpdate({ @@ -496,7 +503,7 @@ export default class DocsService { `No embeddings were created for site: ${siteIndexingConfig.startUrl}\n Num chunks: ${chunks.length}`, ); - if (this.isAborted(startUrl)) { + if (this.shouldCancel(startUrl)) { return; } this.handleStatusUpdate({ @@ -514,7 +521,7 @@ export default class DocsService { // Add docs to databases console.log(`Adding ${embeddings.length} embeddings to db`); - if (this.isAborted(startUrl)) { + if (this.shouldCancel(startUrl)) { return; } this.handleStatusUpdate({ @@ -532,7 +539,7 @@ export default class DocsService { const favicon = await fetchFavicon(new URL(siteIndexingConfig.startUrl)); - if (this.isAborted(startUrl)) { + if (this.shouldCancel(startUrl)) { return; } this.handleStatusUpdate({ @@ -551,7 +558,7 @@ export default class DocsService { this.docsIndexingQueue.delete(startUrl); - if (this.isAborted(startUrl)) { + if (this.shouldCancel(startUrl)) { return; } this.handleStatusUpdate({ diff --git a/gui/src/components/indexing/DocsIndexingStatus.tsx b/gui/src/components/indexing/DocsIndexingStatus.tsx index 31604874f..7f11d9dfa 100644 --- a/gui/src/components/indexing/DocsIndexingStatus.tsx +++ b/gui/src/components/indexing/DocsIndexingStatus.tsx @@ -28,6 +28,7 @@ const STATUS_TO_ICON: Record = { }; function DocsIndexingStatus({ docConfig }: IndexingStatusViewerProps) { + const config = useAppSelector((store) => store.config.config); const ideMessenger = useContext(IdeMessengerContext); const dispatch = useAppDispatch(); @@ -146,28 +147,30 @@ function DocsIndexingStatus({ docConfig }: IndexingStatusViewerProps) {
{}, - pending: () => {}, - }[status?.status] + config.disableIndexing + ? undefined + : { + complete: reIndex, + indexing: abort, + failed: reIndex, + aborted: reIndex, + paused: () => {}, + pending: () => {}, + }[status?.status] } > - { - { - complete: "Click to re-index", - indexing: "Cancel indexing", - failed: "Click to retry", - aborted: "Click to index", - paused: "", - pending: "", - }[status?.status] - } + {config.disableIndexing + ? "Indexing disabled" + : { + complete: "Click to re-index", + indexing: "Cancel indexing", + failed: "Click to retry", + aborted: "Click to index", + paused: "", + pending: "", + }[status?.status]} diff --git a/gui/src/components/indexing/DocsIndexingStatuses.tsx b/gui/src/components/indexing/DocsIndexingStatuses.tsx index 9a9ffb4df..9c52ab0af 100644 --- a/gui/src/components/indexing/DocsIndexingStatuses.tsx +++ b/gui/src/components/indexing/DocsIndexingStatuses.tsx @@ -41,12 +41,13 @@ function DocsIndexingStatuses() { ) : null}
- {configDocs.length - ? "Manage your documentation sources" - : "No docs yet"} - -
- {!hasDocsProvider && ( + {hasDocsProvider ? ( + configDocs.length ? ( + "Manage your documentation sources" + ) : ( + "No docs yet" + ) + ) : (
@@ -69,6 +70,8 @@ function DocsIndexingStatuses() {
)} + +
{configDocs.length === 0 && ( Date: Fri, 20 Dec 2024 18:30:52 -0800 Subject: [PATCH 012/114] handle config changes mid-index --- core/indexing/docs/DocsService.ts | 47 ++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index 7a35e8f24..ab2fb52ab 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -181,27 +181,37 @@ export default class DocsService { } abort(startUrl: string) { - const status = this.statuses.get(startUrl); - if (status) { - this.handleStatusUpdate({ - ...status, - status: "aborted", - progress: 0, - description: "Canceled", - }); + if (this.docsIndexingQueue.has(startUrl)) { + const status = this.statuses.get(startUrl); + if (status) { + this.handleStatusUpdate({ + ...status, + status: "aborted", + progress: 0, + description: "Canceled", + }); + } + this.docsIndexingQueue.delete(startUrl); } - this.docsIndexingQueue.delete(startUrl); } - shouldCancel(startUrl: string) { + shouldCancel(startUrl: string, startedWithEmbedder: string) { + // Check if aborted const isAborted = this.statuses.get(startUrl)?.status === "aborted"; if (isAborted) { return true; } + // Handle indexing disabled change mid-indexing if (this.config.disableIndexing) { this.abort(startUrl); return true; } + // Handle embeddings provider change mid-indexing + if (this.config.embeddingsProvider.embeddingId !== startedWithEmbedder) { + this.abort(startUrl); + return true; + } + return false; } // NOTE Pausing not supported for docs yet @@ -374,6 +384,7 @@ export default class DocsService { } const embeddingsProvider = await this.getEmbeddingsProvider(); + const startedWithEmbedder = this.config.embeddingsProvider.embeddingId; const indexExists = await this.hasMetadata(startUrl); // Build status update - most of it is fixed values @@ -428,7 +439,7 @@ export default class DocsService { estimatedProgress += 1 / 2 ** (processedPages + 1); // NOTE - during "indexing" phase, check if aborted before each status update - if (this.shouldCancel(startUrl)) { + if (this.shouldCancel(startUrl, startedWithEmbedder)) { return; } this.handleStatusUpdate({ @@ -466,7 +477,7 @@ export default class DocsService { for (let i = 0; i < articles.length; i++) { const article = articles[i]; - if (this.shouldCancel(startUrl)) { + if (this.shouldCancel(startUrl, startedWithEmbedder)) { return; } this.handleStatusUpdate({ @@ -503,7 +514,7 @@ export default class DocsService { `No embeddings were created for site: ${siteIndexingConfig.startUrl}\n Num chunks: ${chunks.length}`, ); - if (this.shouldCancel(startUrl)) { + if (this.shouldCancel(startUrl, startedWithEmbedder)) { return; } this.handleStatusUpdate({ @@ -521,7 +532,7 @@ export default class DocsService { // Add docs to databases console.log(`Adding ${embeddings.length} embeddings to db`); - if (this.shouldCancel(startUrl)) { + if (this.shouldCancel(startUrl, startedWithEmbedder)) { return; } this.handleStatusUpdate({ @@ -539,7 +550,7 @@ export default class DocsService { const favicon = await fetchFavicon(new URL(siteIndexingConfig.startUrl)); - if (this.shouldCancel(startUrl)) { + if (this.shouldCancel(startUrl, startedWithEmbedder)) { return; } this.handleStatusUpdate({ @@ -558,7 +569,7 @@ export default class DocsService { this.docsIndexingQueue.delete(startUrl); - if (this.shouldCancel(startUrl)) { + if (this.shouldCancel(startUrl, startedWithEmbedder)) { return; } this.handleStatusUpdate({ @@ -577,7 +588,7 @@ export default class DocsService { console.error("Error indexing docs", e); this.handleStatusUpdate({ ...fixedStatus, - description: `No embeddings were created for site: ${siteIndexingConfig.startUrl}`, + description: `Error getting docs from: ${siteIndexingConfig.startUrl}`, status: "failed", progress: 1, }); @@ -785,7 +796,9 @@ export default class DocsService { const oldConfigDoc = oldConfigDocs.find( (d) => d.startUrl === doc.startUrl, ); + // const currentStatus = this.statuses.get(doc.startUrl); if ( + // currentStatus?.status === "complete" && oldConfigDoc && (oldConfigDoc.maxDepth !== doc.maxDepth || oldConfigDoc.title !== doc.title || From 1c1ab88effbf46ae83c4c7e97cd185bf8f1c5e68 Mon Sep 17 00:00:00 2001 From: liuk Date: Sat, 21 Dec 2024 23:23:09 +0800 Subject: [PATCH 013/114] refactor: Adjust inlay rendering and improve completion logic - Replace `ContinueCustomElementRenderer` and `ContinueMultilineCustomElementRenderer` with `ContinueInlayRenderer`. - Add `Editor.addInlayElement` to handle inline and block inlay elements. - Refactor `AutocompleteService` to use new inlay renderer and improve completion rendering conditions. - Update `AcceptAutocompleteAction` to match new changes. --- .../autocomplete/AcceptAutocompleteAction.kt | 2 +- .../autocomplete/AutocompleteService.kt | 92 ++++++++++--------- .../ContinueCustomElementRenderer.kt | 45 --------- .../autocomplete/ContinueInlayRenderer.kt | 58 ++++++++++++ .../ContinueMultilineCustomElementRenderer.kt | 81 ---------------- 5 files changed, 107 insertions(+), 171 deletions(-) delete mode 100644 extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueCustomElementRenderer.kt create mode 100644 extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueInlayRenderer.kt delete mode 100644 extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueMultilineCustomElementRenderer.kt diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AcceptAutocompleteAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AcceptAutocompleteAction.kt index 45fb3b597..03b91e87c 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AcceptAutocompleteAction.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AcceptAutocompleteAction.kt @@ -22,4 +22,4 @@ class AcceptAutocompleteAction : EditorAction(object : EditorActionHandler() { && autocompleteService.pendingCompletion?.text != null return enabled } -}) {} \ No newline at end of file +}) \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt index 6279e03f7..8be92742c 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt @@ -10,8 +10,10 @@ import com.intellij.openapi.components.ServiceManager import com.intellij.openapi.components.service import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.InlayProperties +import com.intellij.openapi.editor.impl.EditorImpl import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.project.Project +import com.intellij.openapi.util.TextRange import com.intellij.openapi.wm.WindowManager import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiElement @@ -32,9 +34,24 @@ fun PsiElement.isInjectedText(): Boolean { return false } +fun Editor.addInlayElement( + lines: List, + offset: Int, + properties: InlayProperties +) { + if (this is EditorImpl) { + if (lines[0].isNotEmpty()) { + inlayModel.addInlineElement(offset, properties, ContinueInlayRenderer(listOf(lines[0]))) + } + if (lines.size > 1) { + inlayModel.addBlockElement(offset, properties, ContinueInlayRenderer(lines.drop(1))) + } + } +} + @Service(Service.Level.PROJECT) class AutocompleteService(private val project: Project) { - var pendingCompletion: PendingCompletion? = null; + var pendingCompletion: PendingCompletion? = null private val autocompleteLookupListener = project.service() private var widget: AutocompleteSpinnerWidget? = null @@ -66,12 +83,13 @@ class AutocompleteService(private val project: Project) { // Request a completion from the core val virtualFile = FileDocumentManager.getInstance().getFile(editor.document) + val line = editor.caretModel.primaryCaret.logicalPosition.line val column = editor.caretModel.primaryCaret.logicalPosition.column val input = mapOf( "completionId" to completionId, - "filepath" to virtualFile?.url, + "filepath" to virtualFile?.path, "pos" to mapOf( - "line" to editor.caretModel.primaryCaret.logicalPosition.line, + "line" to line, "character" to column ), "recentlyEditedFiles" to emptyList(), @@ -79,10 +97,6 @@ class AutocompleteService(private val project: Project) { "clipboardText" to "" ) - val lineStart = editor.document.getLineStartOffset(editor.caretModel.primaryCaret.logicalPosition.line) - val lineEnd = editor.document.getLineEndOffset(editor.caretModel.primaryCaret.logicalPosition.line) - val lineLength = lineEnd - lineStart - project.service().coreMessenger?.request( "autocomplete/complete", input, @@ -95,9 +109,8 @@ class AutocompleteService(private val project: Project) { val completion = completions[0].toString() val finalTextToInsert = deduplicateCompletion(editor, offset, completion) - if (shouldRenderCompletion(finalTextToInsert, column, lineLength, editor)) { + if (shouldRenderCompletion(finalTextToInsert, offset, line, editor)) { renderCompletion(editor, offset, finalTextToInsert) - pendingCompletion = PendingCompletion(editor, offset, completionId, finalTextToInsert) // Hide auto-popup // AutoPopupController.getInstance(project).cancelAllRequests() } @@ -106,13 +119,19 @@ class AutocompleteService(private val project: Project) { ) } - private fun shouldRenderCompletion(completion: String, column: Int, lineLength: Int, editor: Editor): Boolean { - if (completion.isEmpty()) { + private fun shouldRenderCompletion(completion: String, offset: Int, line: Int, editor: Editor): Boolean { + if (completion.isEmpty() || runReadAction { offset != editor.caretModel.offset }) { return false } + if (completion.lines().size == 1) { + return true + } + + val endOffset = editor.document.getLineEndOffset(line) + // Do not render if completion is multi-line and caret is in middle of line - return !(completion.lines().size > 1 && column < lineLength) + return offset <= endOffset && editor.document.getText(TextRange(offset, endOffset)).isBlank() } private fun deduplicateCompletion(editor: Editor, offset: Int, completion: String): String { @@ -122,9 +141,9 @@ class AutocompleteService(private val project: Project) { val caretOffset = editor.caretModel.offset val N = 10 var textAfterCursor = if (caretOffset + N <= document.textLength) { - document.getText(com.intellij.openapi.util.TextRange(caretOffset, caretOffset + N)) + document.getText(TextRange(caretOffset, caretOffset + N)) } else { - document.getText(com.intellij.openapi.util.TextRange(caretOffset, document.textLength)) + document.getText(TextRange(caretOffset, document.textLength)) } // Determine the index of a newline character within the text following the cursor. @@ -164,19 +183,9 @@ class AutocompleteService(private val project: Project) { properties.relatesToPrecedingText(true) properties.disableSoftWrapping(true) - if (completion.lines().size > 1) { - editor.inlayModel.addBlockElement( - offset, - properties, - ContinueMultilineCustomElementRenderer(editor, completion) - ) - } else { - editor.inlayModel.addInlineElement( - offset, - properties, - ContinueCustomElementRenderer(editor, completion) - ) - } + val lines = completion.lines() + pendingCompletion = pendingCompletion?.copy(text = lines.joinToString("\n")) + editor.addInlayElement(lines, offset, properties) // val attributes = TextAttributes().apply { // backgroundColor = JBColor.GREEN @@ -204,7 +213,7 @@ class AutocompleteService(private val project: Project) { ({}) ) invokeLater { - clearCompletions(editor) + clearCompletions(editor, completion) } } @@ -267,23 +276,14 @@ class AutocompleteService(private val project: Project) { project.service().coreMessenger?.request("autocomplete/cancel", null, null, ({})) } - fun clearCompletions(editor: Editor) { + fun clearCompletions(editor: Editor, completion: PendingCompletion? = pendingCompletion) { if (isInjectedFile(editor)) return - if (pendingCompletion != null) { - cancelCompletion(pendingCompletion!!) - pendingCompletion = null - } - editor.inlayModel.getInlineElementsInRange(0, editor.document.textLength).forEach { - if (it.renderer is ContinueCustomElementRenderer) { - it.dispose() - } - } - editor.inlayModel.getBlockElementsInRange(0, editor.document.textLength).forEach { - if (it.renderer is ContinueMultilineCustomElementRenderer) { - it.dispose() - } + if (completion != null) { + cancelCompletion(completion) + if (completion.completionId == pendingCompletion?.completionId) pendingCompletion = null } + disposeInlayRenderer(editor) } private fun isInjectedFile(editor: Editor): Boolean { @@ -298,13 +298,17 @@ class AutocompleteService(private val project: Project) { fun hideCompletions(editor: Editor) { if (isInjectedFile(editor)) return + disposeInlayRenderer(editor) + } + + private fun disposeInlayRenderer(editor: Editor) { editor.inlayModel.getInlineElementsInRange(0, editor.document.textLength).forEach { - if (it.renderer is ContinueCustomElementRenderer) { + if (it.renderer is ContinueInlayRenderer) { it.dispose() } } editor.inlayModel.getBlockElementsInRange(0, editor.document.textLength).forEach { - if (it.renderer is ContinueMultilineCustomElementRenderer) { + if (it.renderer is ContinueInlayRenderer) { it.dispose() } } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueCustomElementRenderer.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueCustomElementRenderer.kt deleted file mode 100644 index bfaeedb2d..000000000 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueCustomElementRenderer.kt +++ /dev/null @@ -1,45 +0,0 @@ -package com.github.continuedev.continueintellijextension.autocomplete - -import com.intellij.openapi.editor.Editor -import com.intellij.openapi.editor.EditorCustomElementRenderer -import com.intellij.openapi.editor.Inlay -import com.intellij.openapi.editor.colors.EditorFontType -import com.intellij.openapi.editor.impl.EditorImpl -import com.intellij.openapi.editor.impl.FontInfo -import com.intellij.openapi.editor.markup.TextAttributes -import com.intellij.ui.JBColor -import com.intellij.util.ui.UIUtil -import java.awt.Font -import java.awt.Graphics -import java.awt.Rectangle -import kotlin.math.ceil - -class ContinueCustomElementRenderer( - val editor: Editor, - val text: String, -) : EditorCustomElementRenderer { - override fun calcWidthInPixels(inlay: Inlay<*>): Int { - val width = (inlay.editor as EditorImpl).getFontMetrics(Font.PLAIN).stringWidth(this.text) - return width - } - - private fun font(editor: Editor): Font { - val editorFont = editor.colorsScheme.getFont(EditorFontType.PLAIN) - return UIUtil.getFontWithFallbackIfNeeded(editorFont, text).deriveFont(editor.colorsScheme.editorFontSize) - } - - private fun offsetY(editor: Editor): Int { - val metrics = - FontInfo.getFontMetrics(font(editor), FontInfo.getFontRenderContext(editor.contentComponent)) - val fontHeight = - font(editor).createGlyphVector(metrics.fontRenderContext, text).visualBounds.height - val height = (editor.lineHeight + fontHeight) / 2 - return ceil(height).toInt() - } - - override fun paint(inlay: Inlay<*>, g: Graphics, targetRegion: Rectangle, textAttributes: TextAttributes) { - g.color = JBColor.GRAY - g.font = font(inlay.editor) - g.drawString(this.text, targetRegion.x, targetRegion.y + inlay.editor.ascent) - } -} \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueInlayRenderer.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueInlayRenderer.kt new file mode 100644 index 000000000..bcf37fa20 --- /dev/null +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueInlayRenderer.kt @@ -0,0 +1,58 @@ +package com.github.continuedev.continueintellijextension.autocomplete + +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.editor.EditorCustomElementRenderer +import com.intellij.openapi.editor.Inlay +import com.intellij.openapi.editor.colors.EditorFontType +import com.intellij.openapi.editor.impl.EditorImpl +import com.intellij.openapi.editor.markup.TextAttributes +import com.intellij.ui.JBColor +import com.intellij.util.ui.UIUtil +import java.awt.Font +import java.awt.Graphics +import java.awt.Rectangle + +/** + * The `ContinueInlayRenderer` class is responsible for rendering custom inlay elements within an editor. + * It implements the [EditorCustomElementRenderer] interface to provide custom rendering logic for inlays. + * + * This renderer is designed to display a list of text lines (`lines`) within the editor, calculating the + * necessary width and height based on the content and rendering each line with appropriate font and color. + * + * @author lk + */ +class ContinueInlayRenderer(val lines: List) : EditorCustomElementRenderer { + override fun calcWidthInPixels(inlay: Inlay<*>): Int { + var maxLen = 0; + for (line in lines) { + val len = (inlay.editor as EditorImpl).getFontMetrics(Font.PLAIN).stringWidth(line) + if (len > maxLen) { + maxLen = len + } + } + return maxLen + } + + override fun calcHeightInPixels(inlay: Inlay<*>): Int { + return (inlay.editor as EditorImpl).lineHeight * lines.size + } + + private fun font(editor: Editor): Font { + val editorFont = editor.colorsScheme.getFont(EditorFontType.PLAIN) + return UIUtil.getFontWithFallbackIfNeeded(editorFont, lines.joinToString("\n")) + .deriveFont(editor.colorsScheme.editorFontSize) + } + + override fun paint(inlay: Inlay<*>, g: Graphics, targetRegion: Rectangle, textAttributes: TextAttributes) { + val editor = inlay.editor + g.color = JBColor.GRAY + g.font = font(editor) + var additionalYOffset = 0 + val ascent = editor.ascent + val lineHeight = editor.lineHeight + for (line in lines) { + g.drawString(line, targetRegion.x, targetRegion.y + ascent + additionalYOffset) + additionalYOffset += lineHeight + } + } +} \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueMultilineCustomElementRenderer.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueMultilineCustomElementRenderer.kt deleted file mode 100644 index a24b2453a..000000000 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/ContinueMultilineCustomElementRenderer.kt +++ /dev/null @@ -1,81 +0,0 @@ -package com.github.continuedev.continueintellijextension.autocomplete - -import com.intellij.openapi.editor.Editor -import com.intellij.openapi.editor.EditorCustomElementRenderer -import com.intellij.openapi.editor.Inlay -import com.intellij.openapi.editor.colors.EditorFontType -import com.intellij.openapi.editor.impl.EditorImpl -import com.intellij.openapi.editor.impl.FontInfo -import com.intellij.openapi.editor.markup.TextAttributes -import com.intellij.ui.JBColor -import com.intellij.util.ui.UIUtil -import java.awt.Font -import java.awt.Graphics -import java.awt.Rectangle -import kotlin.math.ceil -import kotlin.math.max - -class ContinueMultilineCustomElementRenderer( - val editor: Editor, - val text: String, -) : EditorCustomElementRenderer { - override fun calcWidthInPixels(inlay: Inlay<*>): Int { - val lines = text.lines() - var maxLen = 0; - for (line in lines) { - val len = (inlay.editor as EditorImpl).getFontMetrics(Font.PLAIN).stringWidth(line) - if (len > maxLen) { - maxLen = len - } - } - return maxLen - } - - override fun calcHeightInPixels(inlay: Inlay<*>): Int { - return (inlay.editor as EditorImpl).lineHeight * text.lines().size - } - - protected val font: Font - get() { - val editorFont = editor.colorsScheme.getFont(EditorFontType.PLAIN) - return UIUtil.getFontWithFallbackIfNeeded(editorFont, text).deriveFont(editor.colorsScheme.editorFontSize) - } - - private fun offsetY(): Int { - val metrics = - FontInfo.getFontMetrics(font, FontInfo.getFontRenderContext(editor.contentComponent)) - val fontHeight = - font.createGlyphVector(metrics.fontRenderContext, text).visualBounds.height - val height = (editor.lineHeight + fontHeight) / 2 - return ceil(height).toInt() - } - - private fun offsetX(): Int { - val currentLine = editor.caretModel.primaryCaret.logicalPosition.line - val currentColumn = editor.caretModel.primaryCaret.logicalPosition.column - val metrics = - FontInfo.getFontMetrics(font, FontInfo.getFontRenderContext(editor.contentComponent)) - val fontWidth = - font.createGlyphVector(metrics.fontRenderContext, text).visualBounds.width - val widthBeforeCaret = (editor as EditorImpl).getFontMetrics(Font.PLAIN).stringWidth( - text.substring(0, minOf(currentColumn, text.length)) - ) - return max(0, widthBeforeCaret - (editor as EditorImpl).scrollingModel.horizontalScrollOffset) - } - - override fun paint(inlay: Inlay<*>, g: Graphics, targetRegion: Rectangle, textAttributes: TextAttributes) { - g.color = JBColor.GRAY - g.font = font - var additionalYOffset = -editor.lineHeight; - var isFirstLine = true - for (line in text.lines()) { - g.drawString( - line, - if (isFirstLine) targetRegion.x + offsetX() else targetRegion.x, - targetRegion.y + inlay.editor.ascent + additionalYOffset - ) - additionalYOffset += editor.lineHeight - isFirstLine = false - } - } -} \ No newline at end of file From 94d8d39cfc8d21f2544633330370d99ef17e0fdf Mon Sep 17 00:00:00 2001 From: vercel Date: Mon, 23 Dec 2024 14:23:04 +0800 Subject: [PATCH 014/114] feat: add novita info --- CONTRIBUTING.md | 4 +- core/llm/autodetect.ts | 2 + core/llm/llms/Novita.ts | 53 +++++++++++++++++++ core/llm/llms/index.ts | 2 + docs/docs/chat/model-setup.mdx | 14 ++++- .../customize/model-providers/more/novita.md | 18 +++++++ docs/docs/customize/tutorials/llama3.1.md | 24 ++++++++- docs/docusaurus.config.js | 6 ++- .../current/chat/model-setup.mdx | 14 ++++- .../customize/model-providers/more/novita.md | 18 +++++++ .../current/customize/tutorials/llama3.1.md | 23 +++++++- extensions/vscode/config_schema.json | 46 +++++++++++++++- gui/src/pages/AddNewModel/configs/models.ts | 8 ++- .../pages/AddNewModel/configs/providers.ts | 36 ++++++++++++- packages/openai-adapters/README.md | 1 + packages/openai-adapters/src/index.ts | 2 + packages/openai-adapters/src/types.ts | 1 + packages/openai-adapters/test/main.test.ts | 6 +++ 18 files changed, 266 insertions(+), 12 deletions(-) create mode 100644 core/llm/llms/Novita.ts create mode 100644 docs/docs/customize/model-providers/more/novita.md create mode 100644 docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/novita.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ca26d38fe..843f5ad17 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -188,7 +188,7 @@ After you've written your context provider, make sure to complete the following: ### Adding an LLM Provider -Continue has support for more than a dozen different LLM "providers", making it easy to use models running on OpenAI, Ollama, Together, LM Studio, Msty, and more. You can find all of the existing providers [here](https://github.com/continuedev/continue/tree/main/core/llm/llms), and if you see one missing, you can add it with the following steps: +Continue has support for more than a dozen different LLM "providers", making it easy to use models running on OpenAI, Ollama, Together, Novita, LM Studio, Msty, and more. You can find all of the existing providers [here](https://github.com/continuedev/continue/tree/main/core/llm/llms), and if you see one missing, you can add it with the following steps: 1. Create a new file in the `core/llm/llms` directory. The name of the file should be the name of the provider, and it should export a class that extends `BaseLLM`. This class should contain the following minimal implementation. We recommend viewing pre-existing providers for more details. The [LlamaCpp Provider](./core/llm/llms/LlamaCpp.ts) is a good simple example. @@ -209,7 +209,7 @@ While any model that works with a supported provider can be used with Continue, 1. Add a `ModelPackage` entry for the model into [configs/models.ts](./gui/src/pages/AddNewModel/configs/models.ts), following the lead of the many examples near the top of the file 2. Add the model within its provider's array to [AddNewModel.tsx](./gui/src/pages/AddNewModel/AddNewModel.tsx) (add provider if needed) - [index.d.ts](./core/index.d.ts) - This file defines the TypeScript types used throughout Continue. You'll find a `ModelName` type. Be sure to add the name of your model to this. -- LLM Providers: Since many providers use their own custom strings to identify models, you'll have to add the translation from Continue's model name (the one you added to `index.d.ts`) and the model string for each of these providers: [Ollama](./core/llm/llms/Ollama.ts), [Together](./core/llm/llms/Together.ts), and [Replicate](./core/llm/llms/Replicate.ts). You can find their full model lists here: [Ollama](https://ollama.ai/library), [Together](https://docs.together.ai/docs/inference-models), [Replicate](https://replicate.com/collections/streaming-language-models). +- LLM Providers: Since many providers use their own custom strings to identify models, you'll have to add the translation from Continue's model name (the one you added to `index.d.ts`) and the model string for each of these providers: [Ollama](./core/llm/llms/Ollama.ts), [Together](./core/llm/llms/Together.ts), [Novita](./core/llm/llms/Novita.ts), and [Replicate](./core/llm/llms/Replicate.ts). You can find their full model lists here: [Ollama](https://ollama.ai/library), [Together](https://docs.together.ai/docs/inference-models), [Novita](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=link), [Replicate](https://replicate.com/collections/streaming-language-models). - [Prompt Templates](./core/llm/index.ts) - In this file you'll find the `autodetectTemplateType` function. Make sure that for the model name you just added, this function returns the correct template type. This is assuming that the chat template for that model is already built in Continue. If not, you will have to add the template type and corresponding edit and chat templates. ### Adding Pre-indexed Documentation diff --git a/core/llm/autodetect.ts b/core/llm/autodetect.ts index 226102e88..2a9986e6c 100644 --- a/core/llm/autodetect.ts +++ b/core/llm/autodetect.ts @@ -41,6 +41,7 @@ const PROVIDER_HANDLES_TEMPLATING: string[] = [ "openai", "ollama", "together", + "novita", "msty", "anthropic", "bedrock", @@ -130,6 +131,7 @@ const PARALLEL_PROVIDERS: string[] = [ "free-trial", "replicate", "together", + "novita", "sambanova", "nebius", "vertexai", diff --git a/core/llm/llms/Novita.ts b/core/llm/llms/Novita.ts new file mode 100644 index 000000000..7e90bbae6 --- /dev/null +++ b/core/llm/llms/Novita.ts @@ -0,0 +1,53 @@ +import OpenAI from "./OpenAI.js"; + +import type { CompletionOptions, LLMOptions } from "../../index.js"; + +class Novita extends OpenAI { + static providerName = "novita"; + static defaultOptions: Partial = { + apiBase: "https://api.novita.ai/v3/", + }; + + private static MODEL_IDS: { [name: string]: string } = { + // todo: yexiu + "codellama-7b": "togethercomputer/CodeLlama-7b-Instruct", + "codellama-13b": "togethercomputer/CodeLlama-13b-Instruct", + "codellama-34b": "togethercomputer/CodeLlama-34b-Instruct", + "codellama-70b": "codellama/CodeLlama-70b-Instruct-hf", + "llama3-8b": "meta-llama/Llama-3-8b-chat-hf", + "llama3-70b": "meta-llama/Llama-3-70b-chat-hf", + "llama3.1-8b": "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo", + "llama3.1-70b": "meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo", + "llama3.1-405b": "meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo", + "llama3.2-3b": "meta-llama/Llama-3.2-3B-Instruct-Turbo", + "llama3.2-11b": "meta-llama/Llama-3.2-11B-Vision-Instruct-Turbo", + "llama3.2-90b": "meta-llama/Llama-3.2-90B-Vision-Instruct-Turbo", + "llama2-7b": "togethercomputer/llama-2-7b-chat", + "llama2-13b": "togethercomputer/llama-2-13b-chat", + "llama2-70b": "togethercomputer/llama-2-70b-chat", + "mistral-7b": "mistralai/Mistral-7B-Instruct-v0.1", + "mistral-8x7b": "mistralai/Mixtral-8x7B-Instruct-v0.1", + "phind-codellama-34b": "Phind/Phind-CodeLlama-34B-v2", + "wizardcoder-34b": "WizardLM/WizardCoder-Python-34B-V1.0", + }; + + protected _convertModelName(model: string) { + return Novita.MODEL_IDS[model] || this.model; + } + + protected async *_streamComplete( + prompt: string, + signal: AbortSignal, + options: CompletionOptions, + ): AsyncGenerator { + for await (const chunk of this._legacystreamComplete( + prompt, + signal, + options, + )) { + yield chunk; + } + } +} + +export default Novita; diff --git a/core/llm/llms/index.ts b/core/llm/llms/index.ts index 7e1e2fdc5..20bc8b710 100644 --- a/core/llm/llms/index.ts +++ b/core/llm/llms/index.ts @@ -48,6 +48,7 @@ import ContinueProxy from "./stubs/ContinueProxy"; import TestLLM from "./Test"; import TextGenWebUI from "./TextGenWebUI"; import Together from "./Together"; +import Novita from "./Novita"; import VertexAI from "./VertexAI"; import Vllm from "./Vllm"; import WatsonX from "./WatsonX"; @@ -65,6 +66,7 @@ export const LLMClasses = [ Replicate, TextGenWebUI, Together, + Novita, HuggingFaceTGI, HuggingFaceInferenceAPI, Kindo, diff --git a/docs/docs/chat/model-setup.mdx b/docs/docs/chat/model-setup.mdx index a5668786b..0838b4720 100644 --- a/docs/docs/chat/model-setup.mdx +++ b/docs/docs/chat/model-setup.mdx @@ -33,7 +33,7 @@ Our current top recommendation is Claude Sonnet 3.5 from [Anthropic](../customiz ### Llama 3.1 405B from Meta -If you prefer to use an open-weight model, then Llama 3.1 405B from Meta is your best option right now. You will need to decide if you use it through a SaaS model provider (e.g. [Together](../customize/model-providers/more/together.md) or [Groq](../customize/model-providers/more/groq.md)) or self-host it (e.g. using [vLLM](../customize/model-providers//more/vllm.md) or [Ollama](../customize/model-providers/top-level/ollama.md)). +If you prefer to use an open-weight model, then Llama 3.1 405B from Meta is your best option right now. You will need to decide if you use it through a SaaS model provider (e.g. [Together](../customize/model-providers/more/together.md) or [Novita](../customize/model-providers/more/novita.md) or [Groq](../customize/model-providers/more/groq.md)) or self-host it (e.g. using [vLLM](../customize/model-providers//more/vllm.md) or [Ollama](../customize/model-providers/top-level/ollama.md)). @@ -48,6 +48,18 @@ If you prefer to use an open-weight model, then Llama 3.1 405B from Meta is your ] ``` + + ```json title="config.json" + "models": [ + { + "title": "Llama 3.1 405B", + "provider": "novita", + "model": "llama3.1-405b", + "apiKey": "[NOVITA_API_KEY]" + } + ] + ``` + ```json title="config.json" "models": [ diff --git a/docs/docs/customize/model-providers/more/novita.md b/docs/docs/customize/model-providers/more/novita.md new file mode 100644 index 000000000..d3aa359a4 --- /dev/null +++ b/docs/docs/customize/model-providers/more/novita.md @@ -0,0 +1,18 @@ +# Novita + +The Novita API is a cloud platform for running large AI models. You can sign up [here](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev), copy your API key on the initial welcome screen, and then hit the play button on any model from the [Novita Models list](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=link). Change `~/.continue/config.json` to look like this: + +```json title="config.json" +{ + "models": [ + { + "title": "Novita Qwen2.5 Coder", + "provider": "novita", + "model": "Qwen/Qwen2.5-Coder-32B-Instruct", + "apiKey": "YOUR_API_KEY" + } + ] +} +``` + +[View the source](https://github.com/continuedev/continue/blob/main/core/llm/llms/Novita.ts) diff --git a/docs/docs/customize/tutorials/llama3.1.md b/docs/docs/customize/tutorials/llama3.1.md index 2cec71cda..38c0f8b1b 100644 --- a/docs/docs/customize/tutorials/llama3.1.md +++ b/docs/docs/customize/tutorials/llama3.1.md @@ -1,7 +1,7 @@ --- title: Using Llama 3.1 with Continue description: How to use Llama 3.1 with Continue -keywords: [llama, meta, togetherai, ollama, replicate] +keywords: [llama, meta, togetherai, novita, ollama, replicate] --- Continue makes it easy to code with the latest open-source models, including the entire Llama 3.1 family of models. Llama 3.2 models are also supported but not recommended for chat, because they are specifically designed to be small or multi-modal. @@ -71,6 +71,28 @@ Together AI provides fast and reliable inference of open-source models. You'll b } ``` + +## Novita AI + +Novita AI provides fast and reliable inference of open-source models. You'll be able to run the 405b model with good speed. + +1. Create an account [here](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev) +2. Copy your API key that appears on the welcome screen +3. Update your Continue config file like this: + +```json title="config.json" +{ + "models": [ + { + "title": "Llama 3.1 405b", + "provider": "novita", + "model": "llama3.1-405b", + "apiKey": "" + } + ] +} +``` + ## Replicate Replicate makes it easy to host and run open-source AI with an API. diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index be2fa5f59..82c11d8de 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -388,7 +388,11 @@ const config = { }, { to: "/customize/model-providers/more/together", - from: "/reference/Model Providers/togetherllm", + from: "/reference/Model Providers/together", + }, + { + to: "/customize/model-providers/more/novita", + from: "/reference/Model Providers/novita", }, { to: "/customize/model-providers/more/vllm", diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx index b95d976f1..1157def5e 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx @@ -33,7 +33,7 @@ import TabItem from "@theme/TabItem"; ### 来自 Meta 的 Llama 3.1 405B -如果你倾向于使用开放权重模型,那么来自 Meta 的 Llama 3.1 405B 是你当前的最好选择。你需要决定,通过 SaaS 模型提供者使用它(比如 [Together](../customize/model-providers/more/together.md) 或 [Groq](../customize/model-providers/more/groq.md))或者自托管使用它(比如使用 [vLLM](../customize/model-providers//more/vllm.md) 或 [Ollama](../customize/model-providers/top-level/ollama.md)) 。 +如果你倾向于使用开放权重模型,那么来自 Meta 的 Llama 3.1 405B 是你当前的最好选择。你需要决定,通过 SaaS 模型提供者使用它(比如 [Together](../customize/model-providers/more/together.md) 、[Novita](../customize/model-providers/more/novita.md)或 [Groq](../customize/model-providers/more/groq.md))或者自托管使用它(比如使用 [vLLM](../customize/model-providers//more/vllm.md) 或 [Ollama](../customize/model-providers/top-level/ollama.md)) 。 @@ -48,6 +48,18 @@ import TabItem from "@theme/TabItem"; ] ``` + + ```json title="config.json" + "models": [ + { + "title": "Llama 3.1 405B", + "provider": "novita", + "model": "llama3.1-405b", + "apiKey": "[NOVITA_API_KEY]" + } + ] + ``` + ```json title="config.json" "models": [ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/novita.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/novita.md new file mode 100644 index 000000000..d3e335dca --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/novita.md @@ -0,0 +1,18 @@ +# Novita + +Novita API 是一个运行大 AI 模型的云平台。你可以在 [这里](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev) 注册,在最初欢迎屏幕复制你的 API key ,然后在 [Novita 模型列表](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=link) 的任何模型上点击 play 按钮。修改 `~/.continue/config.json` 像这样: + +```json title="config.json" +{ + "models": [ + { + "title": "Novita CodeLlama", + "provider": "Novita", + "model": "codellama-13b", + "apiKey": "YOUR_API_KEY" + } + ] +} +``` + +[查看代码](https://github.com/continuedev/continue/blob/main/core/llm/llms/Novita.ts) diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md index 2453fbd94..1ca491b8c 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md @@ -1,7 +1,7 @@ --- title: Continue 使用 Llama 3.1 description: Continue 如何使用 Llama 3.1 -keywords: [llama, meta, togetherai, ollama, replicate] +keywords: [llama, meta, togetherai, novita, ollama, replicate] --- Continue 让使用最新的开元模型编码变得简单,包括整个 Llama 3.1 家族模型。 @@ -71,6 +71,27 @@ Together AI 提供开源模型的快速和可信任的推理。你可以以良 } ``` +## Novita AI + +Novita AI 提供开源模型的快速和可信任的推理。你可以以良好的速度运行 405b 模型。 + +1. 创建账号 [在这里](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=link) +2. 复制出现在Key Management你的 API key +3. 更新你的 Continue 配置文件像这样: + +```json title="config.json" +{ + "models": [ + { + "title": "Llama 3.1 405b", + "provider": "novita", + "model": "llama3.1-405b", + "apiKey": "" + } + ] +} +``` + ## Replicate Replicate 让使用 API 托管和运行开源 AI 变得简单。 diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index f2c98642f..4886ba326 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -180,6 +180,7 @@ "bedrockimport", "sagemaker", "together", + "novita", "ollama", "huggingface-tgi", "huggingface-inference-api", @@ -222,6 +223,7 @@ "### Bedrock Imported Models\nTo get started with Bedrock you need to sign up on AWS [here](https://aws.amazon.com/bedrock)", "### Sagemaker\nSagemaker is AWS' machine learning platform.", "### Together\nTogether is a hosted service that provides extremely fast streaming of open-source language models. To get started with Together:\n1. Obtain an API key from [here](https://together.ai)\n2. Paste below\n3. Select a model preset\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/togetherllm)", + "### Novita\nNovita is a hosted service that provides extremely fast streaming of open-source language models. To get started with Novita:\n1. Obtain an API key from [here](https://novita.ai)\n2. Paste below\n3. Select a model preset\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/novitallm)", "### Ollama\nTo get started with Ollama, follow these steps:\n1. Download from [ollama.ai](https://ollama.ai/) and open the application\n2. Open a terminal and run `ollama run `. Example model names are `codellama:7b-instruct` or `llama2:7b-text`. You can find the full list [here](https://ollama.ai/library).\n3. Make sure that the model name used in step 2 is the same as the one in config.json (e.g. `model=\"codellama:7b-instruct\"`)\n4. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/ollama)", "### Huggingface TGI\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/huggingfacetgi)", "### Huggingface Inference API\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/huggingfaceinferenceapi)", @@ -262,7 +264,7 @@ }, "apiKey": { "title": "Api Key", - "description": "OpenAI, Anthropic, Cohere, Together, or other API key", + "description": "OpenAI, Anthropic, Cohere, Together, Novita, or other API key", "type": "string" }, "apiBase": { @@ -475,6 +477,7 @@ "huggingface-inference-api", "replicate", "together", + "novita", "cloudflare", "sambanova", "nebius", @@ -980,6 +983,47 @@ } } }, + { + "if": { + "properties": { + "provider": { + "enum": ["novita"] + } + }, + "required": ["provider"] + }, + "then": { + "properties": { + "model": { + "anyOf": [ + { + "enum": [ + "mistral-7b", + "mistral-8x7b", + "llama2-7b", + "llama2-13b", + "llama3-8b", + "llama3-70b", + "llama3.1-8b", + "llama3.1-70b", + "llama3.1-405b", + "codellama-7b", + "codellama-13b", + "codellama-34b", + "codellama-70b", + "phind-codellama-34b" + ] + }, + { + "type": "string" + } + ], + "markdownDescription": "Select a pre-defined option, or find an exact model string from Novita AI [here](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=link).", + "x-intellij-html-description": "Select a pre-defined option, or find an exact model string from Novita AI here." + } + } + } + }, { "if": { "properties": { diff --git a/gui/src/pages/AddNewModel/configs/models.ts b/gui/src/pages/AddNewModel/configs/models.ts index f3e320305..ed28e7a8d 100644 --- a/gui/src/pages/AddNewModel/configs/models.ts +++ b/gui/src/pages/AddNewModel/configs/models.ts @@ -65,6 +65,7 @@ export const models: { [key: string]: ModelPackage } = { "ollama", "lmstudio", "together", + "novita", "llama.cpp", "replicate", "sambanova", @@ -253,6 +254,7 @@ export const models: { [key: string]: ModelPackage } = { "ollama", "lmstudio", "together", + "novita", "llama.cpp", "replicate", "nebius", @@ -298,6 +300,7 @@ export const models: { [key: string]: ModelPackage } = { "ollama", "lmstudio", "together", + "novita", "llama.cpp", "replicate", ], @@ -445,7 +448,7 @@ export const models: { [key: string]: ModelPackage } = { contextLength: 8192, }, icon: "meta.png", - providerOptions: ["ollama", "groq", "llama.cpp", "sambanova", "together"], + providerOptions: ["ollama", "groq", "llama.cpp", "sambanova", "together", "novita"], isOpenSource: false, }, llama3211bChat: { @@ -458,7 +461,7 @@ export const models: { [key: string]: ModelPackage } = { contextLength: 8192, }, icon: "meta.png", - providerOptions: ["ollama", "groq", "llama.cpp", "together"], + providerOptions: ["ollama", "groq", "llama.cpp", "together", "novita"], isOpenSource: false, }, llama3290bChat: { @@ -504,6 +507,7 @@ export const models: { [key: string]: ModelPackage } = { "ollama", "lmstudio", "together", + "novita", "llama.cpp", "replicate", "nebius", diff --git a/gui/src/pages/AddNewModel/configs/providers.ts b/gui/src/pages/AddNewModel/configs/providers.ts index b3b80e6e1..f005dd6fa 100644 --- a/gui/src/pages/AddNewModel/configs/providers.ts +++ b/gui/src/pages/AddNewModel/configs/providers.ts @@ -404,6 +404,38 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n }), apiKeyUrl: "https://api.together.xyz/settings/api-keys", }, + novita: { + title: "NovitaAI", + provider: "novita", + refPage: "novita", + description: + "Use the NovitaAI API for extremely fast streaming of open-source models", + icon: "novita.png", + longDescription: `Novita is a hosted service that provides extremely fast streaming of open-source language models. To get started with Novita:\n1. Obtain an API key from [here](https://novita.ai)\n2. Paste below\n3. Select a model preset`, + tags: [ModelProviderTags.RequiresApiKey, ModelProviderTags.OpenSource], + params: { + apiKey: "", + }, + collectInputFor: [ + { + inputType: "text", + key: "apiKey", + label: "API Key", + placeholder: "Enter your NovitaAI API key", + required: true, + }, + ...completionParamsInputsConfigs, + ], + packages: [ + models.llama31Chat, + models.codeLlamaInstruct, + models.mistralOs, + ].map((p) => { + p.params.contextLength = 4096; + return p; + }), + apiKeyUrl: "https://novita.ai/settings/key-management", + }, gemini: { title: "Google Gemini API", provider: "gemini", @@ -640,8 +672,8 @@ To get started, [register](https://dataplatform.cloud.ibm.com/registration/stepo provider: "free-trial", refPage: "freetrial", description: - "New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, or Together using our API key", - longDescription: `New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, or Together using our API key. If you are ready to set up a model for long-term use or have used all ${FREE_TRIAL_LIMIT_REQUESTS} free uses, you can enter your API key or use a local model.`, + "New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, Together, or Novita using our API key", + longDescription: `New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, Together or Novita using our API key. If you are ready to set up a model for long-term use or have used all ${FREE_TRIAL_LIMIT_REQUESTS} free uses, you can enter your API key or use a local model.`, icon: "openai.png", tags: [ModelProviderTags.Free], packages: [ diff --git a/packages/openai-adapters/README.md b/packages/openai-adapters/README.md index cebaa129f..3d09e4afb 100644 --- a/packages/openai-adapters/README.md +++ b/packages/openai-adapters/README.md @@ -59,6 +59,7 @@ They are concerned with: - [ ] Silicon Flow - [x] TextGen Web UI - [x] Together +- [x] Novita - [x] Vllm - [ ] Vertex AI - [x] Voyage AI diff --git a/packages/openai-adapters/src/index.ts b/packages/openai-adapters/src/index.ts index c3db18bcf..2e7b362fc 100644 --- a/packages/openai-adapters/src/index.ts +++ b/packages/openai-adapters/src/index.ts @@ -73,6 +73,8 @@ export function constructLlmApi(config: LLMConfig): BaseLlmApi | undefined { return openAICompatible("https://api.fireworks.ai/inference/v1/", config); case "together": return openAICompatible("https://api.together.xyz/v1/", config); + case "novita": + return openAICompatible("https://api.novita.ai/v3", config); case "nebius": return openAICompatible("https://api.studio.nebius.ai/v1/", config); case "function-network": diff --git a/packages/openai-adapters/src/types.ts b/packages/openai-adapters/src/types.ts index fbb21e2e0..29d0310f2 100644 --- a/packages/openai-adapters/src/types.ts +++ b/packages/openai-adapters/src/types.ts @@ -39,6 +39,7 @@ export const OpenAIConfigSchema = BasePlusConfig.extend({ z.literal("nvidia"), z.literal("fireworks"), z.literal("together"), + z.literal("novita"), z.literal("sambanova"), z.literal("nebius"), z.literal("function-network"), diff --git a/packages/openai-adapters/test/main.test.ts b/packages/openai-adapters/test/main.test.ts index 4a9117cab..01e3e9300 100644 --- a/packages/openai-adapters/test/main.test.ts +++ b/packages/openai-adapters/test/main.test.ts @@ -267,6 +267,12 @@ const COMPLETION_TESTS: ({ chatOnly?: boolean } & LlmApiConfig)[] = [ apiKey: process.env.TOGETHER_API_KEY!, chatOnly: true, }, + { + provider: "novita", + model: "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo", + apiKey: process.env.NOVITA_API_KEY!, + chatOnly: true, + }, { provider: "sambanova", model: "Meta-Llama-3.1-8B-Instruct", From 81d1236a021ea4a3d6ab847a941dec0702b23905 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 23 Dec 2024 11:48:50 -0600 Subject: [PATCH 015/114] update symbols from codeblocks --- gui/src/redux/thunks/gatherContext.ts | 8 +------- gui/src/redux/thunks/streamResponse.ts | 10 ++++++++++ gui/src/redux/thunks/updateFileSymbols.ts | 22 ++++++---------------- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/gui/src/redux/thunks/gatherContext.ts b/gui/src/redux/thunks/gatherContext.ts index 7f59a0547..c34702047 100644 --- a/gui/src/redux/thunks/gatherContext.ts +++ b/gui/src/redux/thunks/gatherContext.ts @@ -6,14 +6,10 @@ import { MessageContent, RangeInFile, } from "core"; -import resolveEditorContent, { - hasSlashCommandOrContextProvider, -} from "../../components/mainInput/resolveInput"; +import resolveEditorContent from "../../components/mainInput/resolveInput"; import { ThunkApiType } from "../store"; import { selectDefaultModel } from "../slices/configSlice"; -import { setIsGatheringContext } from "../slices/sessionSlice"; import { findUriInDirs, getUriPathBasename } from "core/util/uri"; -import { updateFileSymbolsFromNewContextItems } from "./updateFileSymbols"; export const gatherContext = createAsyncThunk< { @@ -95,8 +91,6 @@ export const gatherContext = createAsyncThunk< } } - dispatch(updateFileSymbolsFromNewContextItems(selectedContextItems)); - if (promptPreamble) { if (typeof content === "string") { content = promptPreamble + content; diff --git a/gui/src/redux/thunks/streamResponse.ts b/gui/src/redux/thunks/streamResponse.ts index 3b70ecba1..1f1d35ca6 100644 --- a/gui/src/redux/thunks/streamResponse.ts +++ b/gui/src/redux/thunks/streamResponse.ts @@ -16,6 +16,7 @@ import { resetStateForNewMessage } from "./resetStateForNewMessage"; import { streamNormalInput } from "./streamNormalInput"; import { streamSlashCommand } from "./streamSlashCommand"; import { streamThunkWrapper } from "./streamThunkWrapper"; +import { updateFileSymbolsFromFiles } from "./updateFileSymbols"; const getSlashCommandForInput = ( input: MessageContent, @@ -79,6 +80,15 @@ export const streamResponseThunk = createAsyncThunk< const unwrapped = unwrapResult(result); const { selectedContextItems, selectedCode, content } = unwrapped; + // symbols for both context items AND selected codeblocks + const filesForSymbols = [ + ...selectedContextItems + .filter((item) => item.uri?.type === "file" && item?.uri?.value) + .map((item) => item.uri!.value), + ...selectedCode.map((rif) => rif.filepath), + ]; + dispatch(updateFileSymbolsFromFiles(filesForSymbols)); + dispatch( updateHistoryItemAtIndex({ index: inputIndex, diff --git a/gui/src/redux/thunks/updateFileSymbols.ts b/gui/src/redux/thunks/updateFileSymbols.ts index 199fbc1b1..6ddc28a04 100644 --- a/gui/src/redux/thunks/updateFileSymbols.ts +++ b/gui/src/redux/thunks/updateFileSymbols.ts @@ -1,28 +1,22 @@ import { createAsyncThunk } from "@reduxjs/toolkit"; import { ThunkApiType } from "../store"; import { updateFileSymbols } from "../slices/sessionSlice"; -import { ContextItemWithId } from "core"; +import { ContextItemWithId, RangeInFile } from "core"; /* Get file symbols for given context items Overwrite symbols for existing file matches */ -export const updateFileSymbolsFromNewContextItems = createAsyncThunk< +export const updateFileSymbolsFromFiles = createAsyncThunk< void, - ContextItemWithId[], + string[], ThunkApiType >( "symbols/updateFromContextItems", - async (contextItems, { dispatch, extra, getState }) => { + async (filepaths, { dispatch, extra, getState }) => { try { // Get unique file uris from context items - const uniqueUris = Array.from( - new Set( - contextItems - .filter((item) => item.uri?.type === "file" && item?.uri?.value) - .map((item) => item.uri!.value), - ), - ); + const uniqueUris = Array.from(new Set(filepaths)); // Update symbols for those files if (uniqueUris.length > 0) { @@ -36,11 +30,7 @@ export const updateFileSymbolsFromNewContextItems = createAsyncThunk< dispatch(updateFileSymbols(result.content)); } } catch (e) { - console.error( - "Error updating file symbols from context items", - e, - contextItems, - ); + console.error("Error updating file symbols from filepaths", e, filepaths); } }, ); From 9b6a0792ff240b39f7f5ca5bb4c9ab2e0a34bc7d Mon Sep 17 00:00:00 2001 From: Test Date: Mon, 23 Dec 2024 15:05:51 -0600 Subject: [PATCH 016/114] wait for dumb mode --- .../continuedev/continueintellijextension/e2e/Autocomplete.kt | 1 + .../com/github/continuedev/continueintellijextension/e2e/GUI.kt | 1 + .../continuedev/continueintellijextension/e2e/Onboarding.kt | 2 ++ 3 files changed, 4 insertions(+) diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt index a250bf053..fdef6bb0a 100644 --- a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt +++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt @@ -55,6 +55,7 @@ class Autocomplete {init { } idea { + waitFor(ofMinutes(5)) { isDumbMode().not() } with(textEditor()) { val userMsg = "TEST_USER_MESSAGE_0" editor.insertTextAtLine(0, 0, userMsg) diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt index 2a953349b..2a0775ce1 100644 --- a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt +++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt @@ -53,6 +53,7 @@ class GUI { idea { + waitFor(ofMinutes(5)) { isDumbMode().not() } step("Manually open the webview") { // Manually open the webview find(byXpath("//div[@text='Continue']"), ofSeconds((10))).click() diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Onboarding.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Onboarding.kt index 2f8cdbbb1..02c75552d 100644 --- a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Onboarding.kt +++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Onboarding.kt @@ -48,6 +48,8 @@ class Onboarding { } idea { + waitFor(ofMinutes(5)) { isDumbMode().not() } + // Wait for the default "Main.java" tab to load // Our "continue_tutorial.java.ft" tab loads first, but then "Main.java" takes focus. // So we need to wait for that to occur, and then focus on "continue_tutorial.java.ft" From a1ee36f207d1424a4699cc5ee3fb4bb0053b260f Mon Sep 17 00:00:00 2001 From: Test Date: Mon, 23 Dec 2024 15:07:21 -0600 Subject: [PATCH 017/114] Update build.js --- binary/build.js | 65 ++++++++----------------------------------------- 1 file changed, 10 insertions(+), 55 deletions(-) diff --git a/binary/build.js b/binary/build.js index 6e3039cd5..045fb64f2 100644 --- a/binary/build.js +++ b/binary/build.js @@ -1,15 +1,3 @@ -/** - * NOTE: The `--esbuild-only` flag is currently not working due to - * issues with sqlite bindings looking for a package.json - * - * Example usage - * - * node build.js # Full build - * node build.js --esbuild-only --os darwin # Only runs esbuild step for darwin - * node build.js --os linux # Full build for linux only - * node build.js --esbuild-only # Only runs esbuild step for all platforms - */ - const esbuild = require("esbuild"); const fs = require("fs"); const path = require("path"); @@ -50,28 +38,12 @@ const assetBackups = [ ]; let esbuildOnly = false; -let specificOs = null; - -// Parse command line arguments -const args = process.argv.slice(2); - -for (let i = 0; i < args.length; i++) { - if (args[i] === "--esbuild-only") { +for (let i = 2; i < process.argv.length; i++) { + if (process.argv[i] === "--esbuild-only") { esbuildOnly = true; } - if (args[i] === "--target" && args[i + 1]) { - targets = [args[i + 1]]; - i++; // Skip the next argument since we've consumed it - } - if (args[i] === "--os" && args[i + 1]) { - const os = args[i + 1].toLowerCase(); - specificOs = os; - targets = targets.filter((target) => target.startsWith(os)); - if (targets.length === 0) { - console.error(`[error] No targets found for OS: ${os}`); - process.exit(1); - } - i++; // Skip the next argument since we've consumed it + if (process.argv[i - 1] === "--target") { + targets = [process.argv[i]]; } } @@ -146,22 +118,6 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) { } (async () => { - // Informs of where to look for node_sqlite3.node https://www.npmjs.com/package/bindings#:~:text=The%20searching%20for,file%20is%20found - // This is only needed for our `pkg` command - fs.writeFileSync( - "out/package.json", - JSON.stringify( - { - name: "binary", - version: "1.0.0", - author: "Continue Dev, Inc", - license: "Apache-2.0", - }, - undefined, - 2, - ), - ); - console.log("[info] Downloading prebuilt lancedb..."); for (const target of targets) { if (targetToLanceDb[target]) { @@ -237,6 +193,8 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) { format: "cjs", platform: "node", sourcemap: true, + minify: true, + treeShaking: true, loader: { // eslint-disable-next-line @typescript-eslint/naming-convention ".node": "file", @@ -302,22 +260,19 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) { `node_modules/${targetToLanceDb[target]}/index.node`, `${targetDir}/index.node`, ); + + // Informs the `continue-binary` of where to look for node_sqlite3.node + // https://www.npmjs.com/package/bindings#:~:text=The%20searching%20for,file%20is%20found + fs.writeFileSync(`${targetDir}/package.json`, ""); } - // Our dummy `package.json` is no longer needed so we can remove it. - // If it isn't removed, then running locally via `node out/index.js` will fail - // with a `Failed to locate bindings` error - fs.unlinkSync("out/package.json"); - const pathsToVerify = []; - for (const target of targets) { const exe = target.startsWith("win") ? ".exe" : ""; const targetDir = `bin/${target}`; pathsToVerify.push( `${targetDir}/continue-binary${exe}`, `${targetDir}/index.node`, // @lancedb - "package.json", // Informs of where to look for node_sqlite3.node https://www.npmjs.com/package/bindings#:~:text=The%20searching%20for,file%20is%20found `${targetDir}/build/Release/node_sqlite3.node`, ); } From 38db23420345c7c3d94227d8fbc9302efc0b416c Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 23 Dec 2024 17:05:19 -0600 Subject: [PATCH 018/114] include files from toolbar in styledmarkdownpreview plugins --- .../markdown/StyledMarkdownPreview.tsx | 83 ++++++++++++------- 1 file changed, 52 insertions(+), 31 deletions(-) diff --git a/gui/src/components/markdown/StyledMarkdownPreview.tsx b/gui/src/components/markdown/StyledMarkdownPreview.tsx index 49eec1d81..92b09458a 100644 --- a/gui/src/components/markdown/StyledMarkdownPreview.tsx +++ b/gui/src/components/markdown/StyledMarkdownPreview.tsx @@ -26,9 +26,9 @@ import { patchNestedMarkdown } from "./utils/patchNestedMarkdown"; import { useAppSelector } from "../../redux/hooks"; import { fixDoubleDollarNewLineLatex } from "./utils/fixDoubleDollarLatex"; import { selectUIConfig } from "../../redux/slices/configSlice"; -import { IdeMessengerContext } from "../../context/IdeMessenger"; import { ToolTip } from "../gui/Tooltip"; import { v4 as uuidv4 } from "uuid"; +import { ContextItemWithId, RangeInFileWithContents } from "core"; const StyledMarkdown = styled.div<{ fontSize?: number; @@ -141,34 +141,59 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( // So they won't use the most up-to-date state values // So in this case we just put them in refs - // Grab context items that are this one or further back + // The logic here is to get file names from + // 1. Context items found in past messages + // 2. Toolbar Codeblocks found in past messages const history = useAppSelector((state) => state.session.history); - const previousFileContextItems = useMemo(() => { + const allSymbols = useAppSelector((state) => state.session.symbols); + const pastFileInfo = useMemo(() => { const index = props.itemIndex; if (index === undefined) { - return []; + return { + symbols: [], + rifs: [], + }; } - const previousItems = history.flatMap((item, i) => - i <= index ? item.contextItems : [], - ); - return previousItems.filter( - (item) => item.uri?.type === "file" && item?.uri?.value, - ); - }, [props.itemIndex, history]); - const previousFileContextItemsRef = useUpdatingRef(previousFileContextItems); + const pastHistoryItems = history.filter((_, i) => i <= index); - // Extract global symbols for files matching previous context items - const allSymbols = useAppSelector((state) => state.session.symbols); - const previousFileContextItemSymbols = useMemo(() => { - const uniqueUris = new Set( - previousFileContextItems.map((item) => item.uri!.value!), + const pastNormalContextItems = pastHistoryItems.flatMap((item) => { + return ( + item.contextItems?.filter( + (item) => item.uri?.type === "file" && item.uri?.value, + ) ?? [] + ); + }); + + const pastToolbarContextItems: ContextItemWithId[] = pastHistoryItems + .filter((item) => item.editorState && Array.isArray(item.editorState)) + .flatMap((item) => item.editorState) + .filter( + (content) => + content?.type === "codeBlock" && + content?.attrs?.item && + content.attrs.item.uri?.type === "file" && + content.attrs.item.uri?.value, + ) + .map((content) => content.attrs!.item!); + + const pastContextItems = [ + ...pastNormalContextItems, + ...pastToolbarContextItems, + ]; + const rifs = pastContextItems.map((item) => + ctxItemToRifWithContents(item, true), ); - return Object.entries(allSymbols) - .filter((e) => uniqueUris.has(e[0])) + const symbols = Object.entries(allSymbols) + .filter((e) => pastContextItems.find((item) => item.uri!.value === e[0])) .map((f) => f[1]) .flat(); - }, [allSymbols, previousFileContextItems]); - const symbolsRef = useUpdatingRef(previousFileContextItemSymbols); + + return { + symbols, + rifs, + }; + }, [props.itemIndex, history, allSymbols]); + const pastFileInfoRef = useUpdatingRef(pastFileInfo); const [reactContent, setMarkdownSource] = useRemark({ remarkPlugins: [ @@ -298,26 +323,22 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( code: ({ node, ...codeProps }) => { const content = getCodeChildrenContent(codeProps.children); - if (content && previousFileContextItemsRef.current) { + if (content) { + const { symbols, rifs } = pastFileInfoRef.current; // Insert file links for matching previous context items - const ctxItem = previousFileContextItemsRef.current.find((item) => - item.uri!.value!.includes(content), - ); - if (ctxItem) { - const rif = ctxItemToRifWithContents(ctxItem); + const rif = rifs.find((rif) => rif.filepath.includes(content)); + if (rif) { return ; } // Insert symbols for exact matches - const exactSymbol = symbolsRef.current.find( - (s) => s.name === content, - ); + const exactSymbol = symbols.find((s) => s.name === content); if (exactSymbol) { return ; } // Partial matches - this is the case where the llm returns e.g. `subtract(number)` instead of `subtract` - const partialSymbol = symbolsRef.current.find((s) => + const partialSymbol = symbols.find((s) => content.startsWith(s.name), ); if (partialSymbol) { From ad0fdb988b76bebadcbb26a3069b7f821207680f Mon Sep 17 00:00:00 2001 From: vercel Date: Tue, 24 Dec 2024 14:19:48 +0800 Subject: [PATCH 019/114] feat: fix version and address --- binary/package-lock.json | 1 + core/llm/llms/Novita.ts | 27 +++----------- .../customize/model-providers/more/novita.md | 4 +- extensions/vscode/package-lock.json | 4 +- gui/public/logos/novita.png | Bin 0 -> 6726 bytes gui/src/pages/AddNewModel/configs/models.ts | 35 +++++++++++++++--- .../pages/AddNewModel/configs/providers.ts | 4 +- packages/openai-adapters/src/index.ts | 2 +- 8 files changed, 42 insertions(+), 35 deletions(-) create mode 100644 gui/public/logos/novita.png diff --git a/binary/package-lock.json b/binary/package-lock.json index 6f7c394d1..c026c940c 100644 --- a/binary/package-lock.json +++ b/binary/package-lock.json @@ -48,6 +48,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.621.0", "@aws-sdk/credential-providers": "^3.620.1", "@continuedev/config-types": "^1.0.13", + "@continuedev/config-yaml": "^1.0.0", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", diff --git a/core/llm/llms/Novita.ts b/core/llm/llms/Novita.ts index 7e90bbae6..9121bd6c2 100644 --- a/core/llm/llms/Novita.ts +++ b/core/llm/llms/Novita.ts @@ -5,30 +5,15 @@ import type { CompletionOptions, LLMOptions } from "../../index.js"; class Novita extends OpenAI { static providerName = "novita"; static defaultOptions: Partial = { - apiBase: "https://api.novita.ai/v3/", + apiBase: "https://api.novita.ai/v3/openai/", }; private static MODEL_IDS: { [name: string]: string } = { - // todo: yexiu - "codellama-7b": "togethercomputer/CodeLlama-7b-Instruct", - "codellama-13b": "togethercomputer/CodeLlama-13b-Instruct", - "codellama-34b": "togethercomputer/CodeLlama-34b-Instruct", - "codellama-70b": "codellama/CodeLlama-70b-Instruct-hf", - "llama3-8b": "meta-llama/Llama-3-8b-chat-hf", - "llama3-70b": "meta-llama/Llama-3-70b-chat-hf", - "llama3.1-8b": "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo", - "llama3.1-70b": "meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo", - "llama3.1-405b": "meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo", - "llama3.2-3b": "meta-llama/Llama-3.2-3B-Instruct-Turbo", - "llama3.2-11b": "meta-llama/Llama-3.2-11B-Vision-Instruct-Turbo", - "llama3.2-90b": "meta-llama/Llama-3.2-90B-Vision-Instruct-Turbo", - "llama2-7b": "togethercomputer/llama-2-7b-chat", - "llama2-13b": "togethercomputer/llama-2-13b-chat", - "llama2-70b": "togethercomputer/llama-2-70b-chat", - "mistral-7b": "mistralai/Mistral-7B-Instruct-v0.1", - "mistral-8x7b": "mistralai/Mixtral-8x7B-Instruct-v0.1", - "phind-codellama-34b": "Phind/Phind-CodeLlama-34B-v2", - "wizardcoder-34b": "WizardLM/WizardCoder-Python-34B-V1.0", + "llama3.1-8b": "meta-llama/llama-3.1-8b-instruct", + "llama3.1-70b": "meta-llama/llama-3.1-70b-instruct", + "llama3.1-405b": "meta-llama/llama-3.1-405b-instruct", + "llama3.2-3b": "meta-llama/llama-3.2-3b-instruct", + "llama3.2-11b": "meta-llama/llama-3.2-11b-vision-instruct", }; protected _convertModelName(model: string) { diff --git a/docs/docs/customize/model-providers/more/novita.md b/docs/docs/customize/model-providers/more/novita.md index d3aa359a4..92fe572a1 100644 --- a/docs/docs/customize/model-providers/more/novita.md +++ b/docs/docs/customize/model-providers/more/novita.md @@ -6,9 +6,9 @@ The Novita API is a cloud platform for running large AI models. You can sign up { "models": [ { - "title": "Novita Qwen2.5 Coder", + "title": "Llama 3.1 8B", "provider": "novita", - "model": "Qwen/Qwen2.5-Coder-32B-Instruct", + "model": "meta-llama/llama-3.1-8b-instruct", "apiKey": "YOUR_API_KEY" } ] diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 3e213c999..ca4edfc38 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.244", + "version": "0.9.246", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.244", + "version": "0.9.246", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", diff --git a/gui/public/logos/novita.png b/gui/public/logos/novita.png new file mode 100644 index 0000000000000000000000000000000000000000..b744cd35cc7825bba5c201be63d76e3993a75ec9 GIT binary patch literal 6726 zcmV-M8oA|(P)b`>$2vY1tM6d%M!!jF(Kj5*%-r3p+W*mt{kce$Xh#*L8*hNBQ!U|=9$6mk= zoL^w)AAs1f%DfRmGO)<(h#gNC_uf-a)l;Y2B!cPJhIFC$81%v7ew6b= zl{K~{Z70LxIhk4IPWN?`cSL*T?KFe!l9pco_P>1JULlW{?ayERia&P&{NwucQ40y^ zi-NVfLWFDM&&~yXKCWAywf06C8;>K;v$F$%`amobP z&N9ZiKDzb!-}IY1PyYI|ervs6kH#p`(Hfadjq+|~IUr?DA4GbWB>7#24e6 z6-XZ`1hJlaR`l%3xRqSS;{yJ&;G%68@QRhUc4n_npGyFy zrq+O!7;2@>9a8Ht!AP2;GEU1C6BAC7Xe-kUW-5f3AvKR}7#TB`aNC|#T+3MwebnJyDO2&*uN zZ3fd5DtBI)CK5LrMY2s1 z2Fo-{*pV1Hlm{=9FAXN6Tn1~>iDjn=Yt%3$s%fq`)b_s2KD9O#f$gEJ zii&{l91FGtP*ss|?9dCZbsQxaOU3XU>uBXLA`#JkEQ&4Z(bv}nD->OW0A>`U4Co=7 zSr5?=NK*H{ujn+ii(AQ1^u!9tS` zOiAb_+}e}G`tDvr@DqbTXo`CY4<>>u?bp!DY~q}eab6k1bS^wqzcP!>F0GG)EOQw( z{a+g_!Xc;a09+9oakd`^?d-rjLLo;^$J3;O^D?cSom!cjbUop?hMG0SS6n63MJWj% z%Xf4MyI7euESBj%X^X32G8CKO2ZHbI8EK4kEzB!HU>PfMBxk?wtDQciN2z(o+>!zf zLhvp)YAOsbZEUp(Q+pqWq^AnVB!lg8N?r6CQLN_TJRz)9y z;;R@Y+Wci_HYG*+MDozafi$B%YYB{7g>ZMhfAhUZa0lx&X%8sly66?-{=bEB@8dYJ z>-V-l7pI?1*?V`im>=PEdLJL27CUZlu6J#$iat$MKa{`n;E{9?QsA6notjffUV zX!C*(D+gEVevQnuV^iYVFBkR;TdkZF5T*<~whHLx8g$?Ki^u(P&Azklp1kqeyM4Ff z5%t{-Ht|wT9y!JNq96$VM|LqZMd137z;}R{B&$lqMRCJ&0{V5ody% zuOB{zyI+6YU;oq3`VD+clgTv|O!H(?w((<`<_Q^%9E5SKAMSWx;E8=a+p*llQ^)-w zgpwF$A{*O%z^7NtzqLyB=AW%Fv-bDK{S{`u`Eh}nvS4VW1>*SRWW}!~M;8=4%#y1e z4k-f(;fz>M^Rbf>&i=Rih+?j<_pe@D;O^H}nE8_xW?p{CVTM-E@Yj&AIoKk*Kk3RM zL?os!T$><+7im8w32Cq<0&YOt8e{nxyJ$SZYa;~<9e2gO###xd*2vg$K*Ttbz=%fII=rHnoG6qtRf#;d zLeZ_|0yqEYbAGu(&Krjh@W$hErJmx=L%nW z+5rFP+$SfIab{w3*H+bROS4mlQW1|@5+k7}*VpZfU%=ac@VGyRt4XA-E2KtV;m6P? ziM3NhT#i?k5HkQY+mmC-SJQl;?_PV`a8+UKf;t6T90VW`#Rw<_xD1oMzM9NizyE|k zjWegE7Ml7*rsxCclQdkeczkS&A*SWoz$kR2Sqr5bD3r5K>A1}{)saRS#dGe!%T9bQ zpH2dI(SB%|Ej?oR2b?>38)KkjPZWmu9xCOYmTahIe;KZ+CT4%KUNU#sm`uS;n!D8M zVlo)@Oqu8!;bgw)*s|DGx7AJ5IvR8DeY}%t9tc z<)%H8DQ7!Tn|}?{^xT>;WZ-vnBuyHv>3_UqJ2~3W9+aj-X5If_6HKY{Owv5;t^aZkN;O>#s~MaO^_XdfsAF=58p z62~xlmgQt5eXdq$F8D3u;Zdx7AaDR2FDj*GM<>UcZH>U@%x3LR&F0LsECGIE(nRKp z36ELpg0m*>7A)2+5Y%?DX1Q{i)%W9PbV@**inpD0bce8=H}+}$yDgGKG+(r!7^%=g z!T7O|425}3FrJojbP(p8Ng2HTS*(}|iI}3S2@m#t&E+6#73l~WjdZQzs$GvrT+9oN zVV2q`8h~mGB7`I?7u;p)J`FgXYQDAyXNHl)?7->$5YA?Ohj!!vGfuPo(Co@IYVls4 zp~r znH75w7k{?@i#1JF1!+z^V1$Z=cH~U7*mHf>lCf3J!~#TfH4OAAijcg7tc+Cw^>k@v zv;Y-k&_SW7Mx8A!r65S!XtmakMys-N;Ay!+N~B)Z4k5F z+Br4Gz2e>EB^oI$R#4JIA)ADkglz;YH4`+cLpUL0vy4mR1H#i4gnskWWpF2_NG%dBKcJm?2x&bZcjz&m}IBL~q)nIQtvC@U{K?m{n$kD(qgmH@9 z0Ut-ipyRckH&Hs(nGQzjV!R9_zfnPOGI!)n9PAaPu>R%@;W7d9%u9>w(D@;xHcduE z6bbHO7G7Iox%e+Ze2XDHmt{?2=oTK5vG5}cuo$drd-k#5{Bd@kh|)zem$j0@?W74} zeQbjOJ1(^8Lk#-ZX*!)D#JWsY4FQ3H=)fwfP^6=t)R~Ofj9~rN&IHZWa!1#ob0%st zonYkUSY#b2l`y_lM^^nR3UJOM=Rvc-j5gG9mC5UDvpG8r2SWkcRuZg3iMEFkh47nu zs4>XX09TO|K7j61YD^WTYIFjgVvS1PJ}O$NX_af=IpFPpd^%NXetrO|Fgjg?!UHXf zP!f^N&RmZQLv4zr{7B&my3UbAA*)w|e#CI(TFnC@T-hz*lO{7r?@TmEW$CZMurMcd zy?Nz?ox&QlZ%B}VxU}80M~G?d1;o`-z?pGGtj*zVrL!NGE59Ry;I`Ok$(s5G=4c4Z z&V<`JyM&{hm-mG#pknP--`m2J$$f(&Z3tZ`I@l{&&n8wYjOawhG|C!d-fNj|iv@#O zFf~;ycs%nuh05n9A)#piuS|DzoC|AEJc~AJ)-~|nCt;i3vktBx$)0ICzayD&YEV(5Srqz`*iOTp=@c%uYrK-F*=G`#mXm0 z$mpO=NaE?F;i~bYgrjYd;n-1c72jEJE;G#Q@KWG)=0xZ)v?bsHf!03JI}Ypv+?DDu zLX3!ph`gyd$v{RNEPFs5aP(TFBJ&(=PqfYn5^o{1#_;z0kzoqqfLmYtcYF4|NAQKU z$Q^LguI+RCNtOWvsdpJlfbWJDq05k@e@0 z70UF-GfFO{P19Ex@o5c3+DHgtJJW<{C-~w%^7D@y!`HlT>vLQogy?IcLH(GWsD$`O(8b-#;FYrYj^a?R=%k$B; z;rv)qj+m>IE##F6Ptk837?#6W%{c}Ot1yQpva=A#fttxEBBF#vCMYI^a!ngJj?JZ< zYWFrN`pUOH>(`laKg_eC*_G%v7?Rrj{e$t0%=Hh`{-qrv_fGaShC*o+f2fi0WD??1Jcm*&aXk!K%$<_=V#oIWL&Pxsq)$$lOdqWn)m0cq|Yr(0EN7bZd+t zgPIGL&Px_FqtNXAVKD7zdnlG+xkMV}@;3u4TNJV!*H?z${pRD2jAe1Wc608Ocw6Jm zNBpzpbK`m|s~g$5Q{z%#zt-d(M*?s?GZ{|Ms#AE|1kmrMYB;95KnE6O&BT4$ab}%qU1eS= z)b>zy^Q)z=iqShAD9w%c6=ivg*lbZ}FT7f2oFOxj*~r+?k3rn0c)OgOcRCkYwAnMg zX=P!$=b%W$a4wqXoksZiT_l;qZ8>5%g0Ao{wGQMcEswNY$048qbDZnBR+8_v^TUV? zFgXj>7@j+vhf9b!F|!tQ&^6UCdG-z^jLm2KJWC=S^2IbRRyxK@pM~yFOS4fhg2JM< ztCHny8Z6Mc59m>b{PrAZEFF`Vokxy-=3<1E(qXMF7;1N#mZMC*qG+TTXqeZ6Oc*_Q zSbXrLvF$&~!m3L_vU`dRo!ARnhBbWS)V-`iV^nKefW-IaeMQFBaFb5x{AaTzS*jzN zIn7GQa5&D9SRSktjUHm5Q}iC*VN~$IFHUZV)%lgkuAf);4hJ6w5$zm`WuFy=_;A89 z38E}(@&$=E^l4L5(#-zcO zc@!^0m}uU$KQ%l@UyNVQd_H@b=|Dn7YCP$)7&{fx6tklRTU1ZNnJqYq_5B)u7*DOmgW#gt47#Z zx^kZNPEZ^*t{4XtR%9YW z<(o9ST21VQ6l|edl&hyG?Ni*J)(>*U&r&lj%M^k9t%A10K5PHJ4YdevUO^HX>Nn3Y zn2%B{CKrYuYqqk+3!g0~kfx^4(+u#we{`&MqB)U3?@0X5Mm51VF+)-J_N z4gIRD`Ts_&m*(d8nplUEFiqCci49r=;1Vib!PgckSSl~FOlfy&ctG8~JC}C3EEjl- zjm0lFH_f(DL0h$n3Oh+y_BqPvA{LoTCpc+!R;HFyuuZd(xIbR!4*fjOEoLAPD}A~j zX=;JYTg&Y{UY>u~-dUOX7IcMgT4GJDi%w1vp^0o_;i%`I^Hk;#Ea#J*d>1veS zxj%GT@I{(T>58!tRx)qB{16xT^R4c#5AVH?7uVc>=HTR#9x0hwAzwL4&XOej%PO3< zQf`)*HVZMY)+Y-IB|E`7tE9#Fez524iDOH+(0oNwOU1djzWvgj`2F>r#24?`y%+w| zzHqQz0++0m0k(F;M>@6Vs$Z0Wbw08g$1!tb)y|X1Zi4OH-!g@k6sOsh9nu-Jx$r~A zk%~6xd*}WIe(TP^*;{PGPBr}Z|x2*e-l}yCM;OSY`8O+~*RV2}8W%kQwWcGtd*YJSS^W!J3 zwio{HGk$Zm>syHLM@M$55m(La(;_RV7BjN?sZ(^YyS|Z{jjC8K-~-f zWp6zHANK6Zsi)T0i?$v2MMfke>6(b2@aogjtvX2nrc?Oc0bk{I&Hpi-mBdxsFW1+d zmGMt~V0d$Q^wO($n%)K$= zI^o0wPByL|4i(rg5xXBG0`s4D&Hk{oYx}zcW_*Jg8``eB?bhGVpFP$uQS=IH9`5v! z>ca*zzq2y_g?DXZ`m-y~-dwXU<%B*V#1umI`$aI{KH`D=lMCnKw6>aok*a zc*7#Z%Y8f>$A-BJv{(Lljz<2!>GxJ`zqLj)D+f1?|I!xCKz4HCQ_1N#xs cozYwRAM>ak5A>yRrT_o{07*qoM6N<$g587>V*mgE literal 0 HcmV?d00001 diff --git a/gui/src/pages/AddNewModel/configs/models.ts b/gui/src/pages/AddNewModel/configs/models.ts index ed28e7a8d..d43ed2ec1 100644 --- a/gui/src/pages/AddNewModel/configs/models.ts +++ b/gui/src/pages/AddNewModel/configs/models.ts @@ -31,6 +31,33 @@ export interface ModelPackage { } export const models: { [key: string]: ModelPackage } = { + llama318BChat: { + title: "Llama 3.1 8B", + description: "A model from Meta, fine-tuned for chat", + refUrl: "", + params: { + title: "Llama3.1-8b", + model: "meta-llama/llama-3.1-8b-instruct", + contextLength: 8192, + }, + icon: "meta.png", + dimensions: [ + { + name: "Parameter Count", + description: "The number of parameters in the model", + options: { + "8b": { + model: "meta-llama/llama-3.1-8b-instruct", + title: "Llama3.1-8b", + } + }, + }, + ], + providerOptions: [ + "novita" + ], + isOpenSource: true, + }, llama31Chat: { title: "Llama3.1 Chat", description: "A model from Meta, fine-tuned for chat", @@ -65,7 +92,6 @@ export const models: { [key: string]: ModelPackage } = { "ollama", "lmstudio", "together", - "novita", "llama.cpp", "replicate", "sambanova", @@ -254,7 +280,6 @@ export const models: { [key: string]: ModelPackage } = { "ollama", "lmstudio", "together", - "novita", "llama.cpp", "replicate", "nebius", @@ -300,7 +325,6 @@ export const models: { [key: string]: ModelPackage } = { "ollama", "lmstudio", "together", - "novita", "llama.cpp", "replicate", ], @@ -448,7 +472,7 @@ export const models: { [key: string]: ModelPackage } = { contextLength: 8192, }, icon: "meta.png", - providerOptions: ["ollama", "groq", "llama.cpp", "sambanova", "together", "novita"], + providerOptions: ["ollama", "groq", "llama.cpp", "sambanova", "together"], isOpenSource: false, }, llama3211bChat: { @@ -461,7 +485,7 @@ export const models: { [key: string]: ModelPackage } = { contextLength: 8192, }, icon: "meta.png", - providerOptions: ["ollama", "groq", "llama.cpp", "together", "novita"], + providerOptions: ["ollama", "groq", "llama.cpp", "together"], isOpenSource: false, }, llama3290bChat: { @@ -507,7 +531,6 @@ export const models: { [key: string]: ModelPackage } = { "ollama", "lmstudio", "together", - "novita", "llama.cpp", "replicate", "nebius", diff --git a/gui/src/pages/AddNewModel/configs/providers.ts b/gui/src/pages/AddNewModel/configs/providers.ts index f005dd6fa..647828c7f 100644 --- a/gui/src/pages/AddNewModel/configs/providers.ts +++ b/gui/src/pages/AddNewModel/configs/providers.ts @@ -427,9 +427,7 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n ...completionParamsInputsConfigs, ], packages: [ - models.llama31Chat, - models.codeLlamaInstruct, - models.mistralOs, + models.llama318BChat, ].map((p) => { p.params.contextLength = 4096; return p; diff --git a/packages/openai-adapters/src/index.ts b/packages/openai-adapters/src/index.ts index 2e7b362fc..4a42bbfee 100644 --- a/packages/openai-adapters/src/index.ts +++ b/packages/openai-adapters/src/index.ts @@ -74,7 +74,7 @@ export function constructLlmApi(config: LLMConfig): BaseLlmApi | undefined { case "together": return openAICompatible("https://api.together.xyz/v1/", config); case "novita": - return openAICompatible("https://api.novita.ai/v3", config); + return openAICompatible("https://api.novita.ai/v3/openai", config); case "nebius": return openAICompatible("https://api.studio.nebius.ai/v1/", config); case "function-network": From 8d3ecafa3dbd9a3373ec7784eda1feac6b77b684 Mon Sep 17 00:00:00 2001 From: vercel Date: Tue, 24 Dec 2024 15:05:22 +0800 Subject: [PATCH 020/114] feat: change model desc --- docs/docs/chat/model-setup.mdx | 2 +- docs/docs/customize/tutorials/llama3.1.md | 2 +- .../current/chat/model-setup.mdx | 2 +- .../customize/model-providers/more/novita.md | 6 +++--- .../current/customize/tutorials/llama3.1.md | 2 +- extensions/vscode/config_schema.json | 14 +++++--------- packages/openai-adapters/test/main.test.ts | 2 +- 7 files changed, 13 insertions(+), 17 deletions(-) diff --git a/docs/docs/chat/model-setup.mdx b/docs/docs/chat/model-setup.mdx index 0838b4720..f0a1b9508 100644 --- a/docs/docs/chat/model-setup.mdx +++ b/docs/docs/chat/model-setup.mdx @@ -54,7 +54,7 @@ If you prefer to use an open-weight model, then Llama 3.1 405B from Meta is your { "title": "Llama 3.1 405B", "provider": "novita", - "model": "llama3.1-405b", + "model": "meta-llama/llama-3.1-405b-instruct", "apiKey": "[NOVITA_API_KEY]" } ] diff --git a/docs/docs/customize/tutorials/llama3.1.md b/docs/docs/customize/tutorials/llama3.1.md index 38c0f8b1b..a5505f6d5 100644 --- a/docs/docs/customize/tutorials/llama3.1.md +++ b/docs/docs/customize/tutorials/llama3.1.md @@ -86,7 +86,7 @@ Novita AI provides fast and reliable inference of open-source models. You'll be { "title": "Llama 3.1 405b", "provider": "novita", - "model": "llama3.1-405b", + "model": "meta-llama/llama-3.1-405b-instruct", "apiKey": "" } ] diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx index 1157def5e..35db62cc3 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx @@ -54,7 +54,7 @@ import TabItem from "@theme/TabItem"; { "title": "Llama 3.1 405B", "provider": "novita", - "model": "llama3.1-405b", + "model": "meta-llama/llama-3.1-405b-instruct", "apiKey": "[NOVITA_API_KEY]" } ] diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/novita.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/novita.md index d3e335dca..4c413c2e8 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/novita.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/novita.md @@ -1,14 +1,14 @@ # Novita -Novita API 是一个运行大 AI 模型的云平台。你可以在 [这里](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev) 注册,在最初欢迎屏幕复制你的 API key ,然后在 [Novita 模型列表](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=link) 的任何模型上点击 play 按钮。修改 `~/.continue/config.json` 像这样: +Novita API 是一个运行大 AI 模型的云平台。你可以在 [这里](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev) 注册,在最初欢迎屏幕复制你的 API key ,然后在 [Novita 模型列表](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=link) 的任何模型上点击 Try it now 按钮。修改 `~/.continue/config.json` 像这样: ```json title="config.json" { "models": [ { - "title": "Novita CodeLlama", + "title": "Llama 3.1 8b", "provider": "Novita", - "model": "codellama-13b", + "model": "meta-llama/llama-3.1-8b-instruct", "apiKey": "YOUR_API_KEY" } ] diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md index 1ca491b8c..a36b5070d 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md @@ -85,7 +85,7 @@ Novita AI 提供开源模型的快速和可信任的推理。你可以以良好 { "title": "Llama 3.1 405b", "provider": "novita", - "model": "llama3.1-405b", + "model": "meta-llama/llama-3.1-405b-instruct", "apiKey": "" } ] diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 4886ba326..7ecff0aa4 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -998,20 +998,16 @@ "anyOf": [ { "enum": [ - "mistral-7b", - "mistral-8x7b", - "llama2-7b", - "llama2-13b", "llama3-8b", "llama3-70b", "llama3.1-8b", "llama3.1-70b", "llama3.1-405b", - "codellama-7b", - "codellama-13b", - "codellama-34b", - "codellama-70b", - "phind-codellama-34b" + "llama3.2-3b", + "llama3.2-11b", + "llama-3.3-70b", + "mistral-nemo", + "mistral-7b" ] }, { diff --git a/packages/openai-adapters/test/main.test.ts b/packages/openai-adapters/test/main.test.ts index 01e3e9300..7e4a56d06 100644 --- a/packages/openai-adapters/test/main.test.ts +++ b/packages/openai-adapters/test/main.test.ts @@ -269,7 +269,7 @@ const COMPLETION_TESTS: ({ chatOnly?: boolean } & LlmApiConfig)[] = [ }, { provider: "novita", - model: "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo", + model: "meta-llama/llama-3.1-8b-instruct", apiKey: process.env.NOVITA_API_KEY!, chatOnly: true, }, From a25afeeda10c86072f80c025c20c21b167ddaaf0 Mon Sep 17 00:00:00 2001 From: vercel Date: Tue, 24 Dec 2024 18:57:16 +0800 Subject: [PATCH 021/114] feat: brand text fix --- CONTRIBUTING.md | 4 ++-- docs/docs/chat/model-setup.mdx | 2 +- docs/docs/customize/model-providers/more/novita.md | 2 +- docs/docs/customize/tutorials/llama3.1.md | 2 +- .../current/chat/model-setup.mdx | 2 +- .../current/customize/model-providers/more/novita.md | 2 +- .../current/customize/tutorials/llama3.1.md | 6 +++--- extensions/vscode/config_schema.json | 4 ++-- gui/src/pages/AddNewModel/configs/providers.ts | 10 +++++----- packages/openai-adapters/README.md | 2 +- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 843f5ad17..458fc6038 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -188,7 +188,7 @@ After you've written your context provider, make sure to complete the following: ### Adding an LLM Provider -Continue has support for more than a dozen different LLM "providers", making it easy to use models running on OpenAI, Ollama, Together, Novita, LM Studio, Msty, and more. You can find all of the existing providers [here](https://github.com/continuedev/continue/tree/main/core/llm/llms), and if you see one missing, you can add it with the following steps: +Continue has support for more than a dozen different LLM "providers", making it easy to use models running on OpenAI, Ollama, Together, Novita AI, LM Studio, Msty, and more. You can find all of the existing providers [here](https://github.com/continuedev/continue/tree/main/core/llm/llms), and if you see one missing, you can add it with the following steps: 1. Create a new file in the `core/llm/llms` directory. The name of the file should be the name of the provider, and it should export a class that extends `BaseLLM`. This class should contain the following minimal implementation. We recommend viewing pre-existing providers for more details. The [LlamaCpp Provider](./core/llm/llms/LlamaCpp.ts) is a good simple example. @@ -209,7 +209,7 @@ While any model that works with a supported provider can be used with Continue, 1. Add a `ModelPackage` entry for the model into [configs/models.ts](./gui/src/pages/AddNewModel/configs/models.ts), following the lead of the many examples near the top of the file 2. Add the model within its provider's array to [AddNewModel.tsx](./gui/src/pages/AddNewModel/AddNewModel.tsx) (add provider if needed) - [index.d.ts](./core/index.d.ts) - This file defines the TypeScript types used throughout Continue. You'll find a `ModelName` type. Be sure to add the name of your model to this. -- LLM Providers: Since many providers use their own custom strings to identify models, you'll have to add the translation from Continue's model name (the one you added to `index.d.ts`) and the model string for each of these providers: [Ollama](./core/llm/llms/Ollama.ts), [Together](./core/llm/llms/Together.ts), [Novita](./core/llm/llms/Novita.ts), and [Replicate](./core/llm/llms/Replicate.ts). You can find their full model lists here: [Ollama](https://ollama.ai/library), [Together](https://docs.together.ai/docs/inference-models), [Novita](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=link), [Replicate](https://replicate.com/collections/streaming-language-models). +- LLM Providers: Since many providers use their own custom strings to identify models, you'll have to add the translation from Continue's model name (the one you added to `index.d.ts`) and the model string for each of these providers: [Ollama](./core/llm/llms/Ollama.ts), [Together](./core/llm/llms/Together.ts), [Novita AI](./core/llm/llms/Novita.ts), and [Replicate](./core/llm/llms/Replicate.ts). You can find their full model lists here: [Ollama](https://ollama.ai/library), [Together](https://docs.together.ai/docs/inference-models), [Novita AI](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=link), [Replicate](https://replicate.com/collections/streaming-language-models). - [Prompt Templates](./core/llm/index.ts) - In this file you'll find the `autodetectTemplateType` function. Make sure that for the model name you just added, this function returns the correct template type. This is assuming that the chat template for that model is already built in Continue. If not, you will have to add the template type and corresponding edit and chat templates. ### Adding Pre-indexed Documentation diff --git a/docs/docs/chat/model-setup.mdx b/docs/docs/chat/model-setup.mdx index f0a1b9508..41f7709d6 100644 --- a/docs/docs/chat/model-setup.mdx +++ b/docs/docs/chat/model-setup.mdx @@ -33,7 +33,7 @@ Our current top recommendation is Claude Sonnet 3.5 from [Anthropic](../customiz ### Llama 3.1 405B from Meta -If you prefer to use an open-weight model, then Llama 3.1 405B from Meta is your best option right now. You will need to decide if you use it through a SaaS model provider (e.g. [Together](../customize/model-providers/more/together.md) or [Novita](../customize/model-providers/more/novita.md) or [Groq](../customize/model-providers/more/groq.md)) or self-host it (e.g. using [vLLM](../customize/model-providers//more/vllm.md) or [Ollama](../customize/model-providers/top-level/ollama.md)). +If you prefer to use an open-weight model, then Llama 3.1 405B from Meta is your best option right now. You will need to decide if you use it through a SaaS model provider (e.g. [Together](../customize/model-providers/more/together.md) or [Novita AI](../customize/model-providers/more/novita.md) or [Groq](../customize/model-providers/more/groq.md)) or self-host it (e.g. using [vLLM](../customize/model-providers//more/vllm.md) or [Ollama](../customize/model-providers/top-level/ollama.md)). diff --git a/docs/docs/customize/model-providers/more/novita.md b/docs/docs/customize/model-providers/more/novita.md index 92fe572a1..841d3e11e 100644 --- a/docs/docs/customize/model-providers/more/novita.md +++ b/docs/docs/customize/model-providers/more/novita.md @@ -1,6 +1,6 @@ # Novita -The Novita API is a cloud platform for running large AI models. You can sign up [here](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev), copy your API key on the initial welcome screen, and then hit the play button on any model from the [Novita Models list](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=link). Change `~/.continue/config.json` to look like this: +[Novita AI](https://novita.ai) offers an affordable, reliable, and simple inference platform with scalable [LLM API](https://novita.ai/docs/model-api/reference/introduction.html), empowering developers to build AI applications. Try the [Novita AI Llama 3 API Demo](https://novita.ai/model-api/product/llm-api/playground/meta-llama-llama-3.1-70b-instruct) today!. You can sign up [here](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev), copy your API key on the [Key Management](https://novita.ai/settings/key-management), and then hit the play button on any model from the [Novita AI Models list](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=link). Change `~/.continue/config.json` to look like this: ```json title="config.json" { diff --git a/docs/docs/customize/tutorials/llama3.1.md b/docs/docs/customize/tutorials/llama3.1.md index a5505f6d5..28decd81e 100644 --- a/docs/docs/customize/tutorials/llama3.1.md +++ b/docs/docs/customize/tutorials/llama3.1.md @@ -74,7 +74,7 @@ Together AI provides fast and reliable inference of open-source models. You'll b ## Novita AI -Novita AI provides fast and reliable inference of open-source models. You'll be able to run the 405b model with good speed. +[Novita AI](https://novita.ai) offers an affordable, reliable, and simple inference platform with scalable [LLM API](https://novita.ai/docs/model-api/reference/introduction.html), empowering developers to build AI applications. Try the [Novita AI Llama 3 API Demo](https://novita.ai/model-api/product/llm-api/playground/meta-llama-llama-3.1-70b-instruct) today! 1. Create an account [here](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev) 2. Copy your API key that appears on the welcome screen diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx index 35db62cc3..4ef37a41e 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx @@ -33,7 +33,7 @@ import TabItem from "@theme/TabItem"; ### 来自 Meta 的 Llama 3.1 405B -如果你倾向于使用开放权重模型,那么来自 Meta 的 Llama 3.1 405B 是你当前的最好选择。你需要决定,通过 SaaS 模型提供者使用它(比如 [Together](../customize/model-providers/more/together.md) 、[Novita](../customize/model-providers/more/novita.md)或 [Groq](../customize/model-providers/more/groq.md))或者自托管使用它(比如使用 [vLLM](../customize/model-providers//more/vllm.md) 或 [Ollama](../customize/model-providers/top-level/ollama.md)) 。 +如果你倾向于使用开放权重模型,那么来自 Meta 的 Llama 3.1 405B 是你当前的最好选择。你需要决定,通过 SaaS 模型提供者使用它(比如 [Together](../customize/model-providers/more/together.md) 、[Novita AI](../customize/model-providers/more/novita.md)或 [Groq](../customize/model-providers/more/groq.md))或者自托管使用它(比如使用 [vLLM](../customize/model-providers//more/vllm.md) 或 [Ollama](../customize/model-providers/top-level/ollama.md)) 。 diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/novita.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/novita.md index 4c413c2e8..97adaa081 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/novita.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/novita.md @@ -1,6 +1,6 @@ # Novita -Novita API 是一个运行大 AI 模型的云平台。你可以在 [这里](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev) 注册,在最初欢迎屏幕复制你的 API key ,然后在 [Novita 模型列表](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=link) 的任何模型上点击 Try it now 按钮。修改 `~/.continue/config.json` 像这样: +[Novita AI](https://novita.ai) 提供了一个经济实惠、可靠且简单的推理平台。你可以在 [这里](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev) 注册,在 [Key 管理页面](https://novita.ai/settings/key-management)复制你的 API key ,然后在 [Novita 模型列表](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=link) 的任何模型上点击 Try it now 按钮。修改 `~/.continue/config.json` 像这样: ```json title="config.json" { diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md index a36b5070d..126be8f50 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md @@ -73,11 +73,11 @@ Together AI 提供开源模型的快速和可信任的推理。你可以以良 ## Novita AI -Novita AI 提供开源模型的快速和可信任的推理。你可以以良好的速度运行 405b 模型。 +[Novita AI](https://novita.ai) 提供了一个经济实惠、可靠且简单的推理平台。你可以以良好的速度运行 405b 模型。 1. 创建账号 [在这里](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=link) -2. 复制出现在Key Management你的 API key -3. 更新你的 Continue 配置文件像这样: +2. 复制[Key Management](https://novita.ai/settings/key-management)中的你的 API key +3. 更新你的 Continue 配置文件,像这样: ```json title="config.json" { diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 7ecff0aa4..76eedf998 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -223,7 +223,7 @@ "### Bedrock Imported Models\nTo get started with Bedrock you need to sign up on AWS [here](https://aws.amazon.com/bedrock)", "### Sagemaker\nSagemaker is AWS' machine learning platform.", "### Together\nTogether is a hosted service that provides extremely fast streaming of open-source language models. To get started with Together:\n1. Obtain an API key from [here](https://together.ai)\n2. Paste below\n3. Select a model preset\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/togetherllm)", - "### Novita\nNovita is a hosted service that provides extremely fast streaming of open-source language models. To get started with Novita:\n1. Obtain an API key from [here](https://novita.ai)\n2. Paste below\n3. Select a model preset\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/novitallm)", + "### Novita AI\n[Novita AI](https://novita.ai) offers an affordable, reliable, and simple inference platform with scalable [LLM APIs](https://novita.ai/docs/model-api/reference/introduction.html), empowering developers to build AI applications. To get started with Novita AI:\n1. Obtain an API key from [here](https://novita.ai/settings/key-management)\n2. Paste below\n3. Select a model preset\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/novitallm)", "### Ollama\nTo get started with Ollama, follow these steps:\n1. Download from [ollama.ai](https://ollama.ai/) and open the application\n2. Open a terminal and run `ollama run `. Example model names are `codellama:7b-instruct` or `llama2:7b-text`. You can find the full list [here](https://ollama.ai/library).\n3. Make sure that the model name used in step 2 is the same as the one in config.json (e.g. `model=\"codellama:7b-instruct\"`)\n4. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/ollama)", "### Huggingface TGI\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/huggingfacetgi)", "### Huggingface Inference API\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/huggingfaceinferenceapi)", @@ -264,7 +264,7 @@ }, "apiKey": { "title": "Api Key", - "description": "OpenAI, Anthropic, Cohere, Together, Novita, or other API key", + "description": "OpenAI, Anthropic, Cohere, Together, Novita AI, or other API key", "type": "string" }, "apiBase": { diff --git a/gui/src/pages/AddNewModel/configs/providers.ts b/gui/src/pages/AddNewModel/configs/providers.ts index 647828c7f..8ef4129eb 100644 --- a/gui/src/pages/AddNewModel/configs/providers.ts +++ b/gui/src/pages/AddNewModel/configs/providers.ts @@ -409,9 +409,9 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n provider: "novita", refPage: "novita", description: - "Use the NovitaAI API for extremely fast streaming of open-source models", + "Use Novita AI API for extremely fast streaming of open-source models", icon: "novita.png", - longDescription: `Novita is a hosted service that provides extremely fast streaming of open-source language models. To get started with Novita:\n1. Obtain an API key from [here](https://novita.ai)\n2. Paste below\n3. Select a model preset`, + longDescription: `[Novita AI](https://novita.ai) offers an affordable, reliable, and simple inference platform with scalable [LLM APIs](https://novita.ai/docs/model-api/reference/introduction.html), empowering developers to build AI applications. To get started with Novita AI:\n1. Obtain an API key from [here](https://novita.ai)\n2. Paste below\n3. Select a model preset`, tags: [ModelProviderTags.RequiresApiKey, ModelProviderTags.OpenSource], params: { apiKey: "", @@ -421,7 +421,7 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n inputType: "text", key: "apiKey", label: "API Key", - placeholder: "Enter your NovitaAI API key", + placeholder: "Enter your Novita AI API key", required: true, }, ...completionParamsInputsConfigs, @@ -670,8 +670,8 @@ To get started, [register](https://dataplatform.cloud.ibm.com/registration/stepo provider: "free-trial", refPage: "freetrial", description: - "New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, Together, or Novita using our API key", - longDescription: `New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, Together or Novita using our API key. If you are ready to set up a model for long-term use or have used all ${FREE_TRIAL_LIMIT_REQUESTS} free uses, you can enter your API key or use a local model.`, + "New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, Together, or Novita AI using our API key", + longDescription: `New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, Together or Novita AI using our API key. If you are ready to set up a model for long-term use or have used all ${FREE_TRIAL_LIMIT_REQUESTS} free uses, you can enter your API key or use a local model.`, icon: "openai.png", tags: [ModelProviderTags.Free], packages: [ diff --git a/packages/openai-adapters/README.md b/packages/openai-adapters/README.md index 3d09e4afb..b84b198e7 100644 --- a/packages/openai-adapters/README.md +++ b/packages/openai-adapters/README.md @@ -59,7 +59,7 @@ They are concerned with: - [ ] Silicon Flow - [x] TextGen Web UI - [x] Together -- [x] Novita +- [x] Novita AI - [x] Vllm - [ ] Vertex AI - [x] Voyage AI From d59b3b5297924b2b6343a990c09551be4af9c670 Mon Sep 17 00:00:00 2001 From: vercel Date: Tue, 24 Dec 2024 20:00:43 +0800 Subject: [PATCH 022/114] feat: fix address --- CONTRIBUTING.md | 2 +- docs/docs/customize/model-providers/more/novita.md | 2 +- docs/docs/customize/tutorials/llama3.1.md | 4 ++-- .../current/customize/model-providers/more/novita.md | 2 +- .../current/customize/tutorials/llama3.1.md | 6 +++--- extensions/vscode/config_schema.json | 6 +++--- gui/src/pages/AddNewModel/configs/providers.ts | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 458fc6038..eddf7b45b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -209,7 +209,7 @@ While any model that works with a supported provider can be used with Continue, 1. Add a `ModelPackage` entry for the model into [configs/models.ts](./gui/src/pages/AddNewModel/configs/models.ts), following the lead of the many examples near the top of the file 2. Add the model within its provider's array to [AddNewModel.tsx](./gui/src/pages/AddNewModel/AddNewModel.tsx) (add provider if needed) - [index.d.ts](./core/index.d.ts) - This file defines the TypeScript types used throughout Continue. You'll find a `ModelName` type. Be sure to add the name of your model to this. -- LLM Providers: Since many providers use their own custom strings to identify models, you'll have to add the translation from Continue's model name (the one you added to `index.d.ts`) and the model string for each of these providers: [Ollama](./core/llm/llms/Ollama.ts), [Together](./core/llm/llms/Together.ts), [Novita AI](./core/llm/llms/Novita.ts), and [Replicate](./core/llm/llms/Replicate.ts). You can find their full model lists here: [Ollama](https://ollama.ai/library), [Together](https://docs.together.ai/docs/inference-models), [Novita AI](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=link), [Replicate](https://replicate.com/collections/streaming-language-models). +- LLM Providers: Since many providers use their own custom strings to identify models, you'll have to add the translation from Continue's model name (the one you added to `index.d.ts`) and the model string for each of these providers: [Ollama](./core/llm/llms/Ollama.ts), [Together](./core/llm/llms/Together.ts), [Novita AI](./core/llm/llms/Novita.ts), and [Replicate](./core/llm/llms/Replicate.ts). You can find their full model lists here: [Ollama](https://ollama.ai/library), [Together](https://docs.together.ai/docs/inference-models), [Novita AI](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link), [Replicate](https://replicate.com/collections/streaming-language-models). - [Prompt Templates](./core/llm/index.ts) - In this file you'll find the `autodetectTemplateType` function. Make sure that for the model name you just added, this function returns the correct template type. This is assuming that the chat template for that model is already built in Continue. If not, you will have to add the template type and corresponding edit and chat templates. ### Adding Pre-indexed Documentation diff --git a/docs/docs/customize/model-providers/more/novita.md b/docs/docs/customize/model-providers/more/novita.md index 841d3e11e..02f7cefb5 100644 --- a/docs/docs/customize/model-providers/more/novita.md +++ b/docs/docs/customize/model-providers/more/novita.md @@ -1,6 +1,6 @@ # Novita -[Novita AI](https://novita.ai) offers an affordable, reliable, and simple inference platform with scalable [LLM API](https://novita.ai/docs/model-api/reference/introduction.html), empowering developers to build AI applications. Try the [Novita AI Llama 3 API Demo](https://novita.ai/model-api/product/llm-api/playground/meta-llama-llama-3.1-70b-instruct) today!. You can sign up [here](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev), copy your API key on the [Key Management](https://novita.ai/settings/key-management), and then hit the play button on any model from the [Novita AI Models list](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=link). Change `~/.continue/config.json` to look like this: +[Novita AI](https://novita.ai?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) offers an affordable, reliable, and simple inference platform with scalable [LLM API](https://novita.ai/docs/model-api/reference/introduction.html), empowering developers to build AI applications. Try the [Novita AI Llama 3 API Demo](https://novita.ai/model-api/product/llm-api/playground/meta-llama-llama-3.1-70b-instruct?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) today!. You can sign up [here](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link), copy your API key on the [Key Management](https://novita.ai/settings/key-management?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link), and then hit the play button on any model from the [Novita AI Models list](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link). Change `~/.continue/config.json` to look like this: ```json title="config.json" { diff --git a/docs/docs/customize/tutorials/llama3.1.md b/docs/docs/customize/tutorials/llama3.1.md index 28decd81e..38e90bee9 100644 --- a/docs/docs/customize/tutorials/llama3.1.md +++ b/docs/docs/customize/tutorials/llama3.1.md @@ -74,9 +74,9 @@ Together AI provides fast and reliable inference of open-source models. You'll b ## Novita AI -[Novita AI](https://novita.ai) offers an affordable, reliable, and simple inference platform with scalable [LLM API](https://novita.ai/docs/model-api/reference/introduction.html), empowering developers to build AI applications. Try the [Novita AI Llama 3 API Demo](https://novita.ai/model-api/product/llm-api/playground/meta-llama-llama-3.1-70b-instruct) today! +[Novita AI](https://novita.ai?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) offers an affordable, reliable, and simple inference platform with scalable [LLM API](https://novita.ai/docs/model-api/reference/introduction.html), empowering developers to build AI applications. Try the [Novita AI Llama 3 API Demo](https://novita.ai/model-api/product/llm-api/playground/meta-llama-llama-3.1-70b-instruct?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) today! -1. Create an account [here](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev) +1. Create an account [here](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) 2. Copy your API key that appears on the welcome screen 3. Update your Continue config file like this: diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/novita.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/novita.md index 97adaa081..fffdd195a 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/novita.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/novita.md @@ -1,6 +1,6 @@ # Novita -[Novita AI](https://novita.ai) 提供了一个经济实惠、可靠且简单的推理平台。你可以在 [这里](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev) 注册,在 [Key 管理页面](https://novita.ai/settings/key-management)复制你的 API key ,然后在 [Novita 模型列表](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=link) 的任何模型上点击 Try it now 按钮。修改 `~/.continue/config.json` 像这样: +[Novita AI](https://novita.ai?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) 提供了一个经济实惠、可靠且简单的推理平台。你可以在 [这里](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) 注册,在 [Key Management](https://novita.ai/settings/key-management?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link)复制你的 API key ,然后在 [Novita 模型列表](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) 的任何模型上点击 Try it now 按钮。修改 `~/.continue/config.json` 像这样: ```json title="config.json" { diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md index 126be8f50..dc285627a 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md @@ -73,10 +73,10 @@ Together AI 提供开源模型的快速和可信任的推理。你可以以良 ## Novita AI -[Novita AI](https://novita.ai) 提供了一个经济实惠、可靠且简单的推理平台。你可以以良好的速度运行 405b 模型。 +[Novita AI](https://novita.ai?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) 提供了一个经济实惠、可靠且简单的推理平台。你可以以良好的速度运行 405b 模型。 -1. 创建账号 [在这里](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=link) -2. 复制[Key Management](https://novita.ai/settings/key-management)中的你的 API key +1. 创建账号 [在这里](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) +2. 复制[Key Management](https://novita.ai/settings/key-management?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link)中的你的 API key 3. 更新你的 Continue 配置文件,像这样: ```json title="config.json" diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 76eedf998..3ae0e3cc5 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -223,7 +223,7 @@ "### Bedrock Imported Models\nTo get started with Bedrock you need to sign up on AWS [here](https://aws.amazon.com/bedrock)", "### Sagemaker\nSagemaker is AWS' machine learning platform.", "### Together\nTogether is a hosted service that provides extremely fast streaming of open-source language models. To get started with Together:\n1. Obtain an API key from [here](https://together.ai)\n2. Paste below\n3. Select a model preset\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/togetherllm)", - "### Novita AI\n[Novita AI](https://novita.ai) offers an affordable, reliable, and simple inference platform with scalable [LLM APIs](https://novita.ai/docs/model-api/reference/introduction.html), empowering developers to build AI applications. To get started with Novita AI:\n1. Obtain an API key from [here](https://novita.ai/settings/key-management)\n2. Paste below\n3. Select a model preset\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/novitallm)", + "### Novita AI\n[Novita AI](https://novita.ai?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) offers an affordable, reliable, and simple inference platform with scalable [LLM APIs](https://novita.ai/docs/model-api/reference/introduction.html), empowering developers to build AI applications. To get started with Novita AI:\n1. Obtain an API key from [here](https://novita.ai/settings/key-management?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link)\n2. Paste below\n3. Select a model preset\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/novita)", "### Ollama\nTo get started with Ollama, follow these steps:\n1. Download from [ollama.ai](https://ollama.ai/) and open the application\n2. Open a terminal and run `ollama run `. Example model names are `codellama:7b-instruct` or `llama2:7b-text`. You can find the full list [here](https://ollama.ai/library).\n3. Make sure that the model name used in step 2 is the same as the one in config.json (e.g. `model=\"codellama:7b-instruct\"`)\n4. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/ollama)", "### Huggingface TGI\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/huggingfacetgi)", "### Huggingface Inference API\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/huggingfaceinferenceapi)", @@ -1014,8 +1014,8 @@ "type": "string" } ], - "markdownDescription": "Select a pre-defined option, or find an exact model string from Novita AI [here](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=link).", - "x-intellij-html-description": "Select a pre-defined option, or find an exact model string from Novita AI here." + "markdownDescription": "Select a pre-defined option, or find an exact model string from Novita AI [here](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link).", + "x-intellij-html-description": "Select a pre-defined option, or find an exact model string from Novita AI here." } } } diff --git a/gui/src/pages/AddNewModel/configs/providers.ts b/gui/src/pages/AddNewModel/configs/providers.ts index 8ef4129eb..49b30e409 100644 --- a/gui/src/pages/AddNewModel/configs/providers.ts +++ b/gui/src/pages/AddNewModel/configs/providers.ts @@ -411,7 +411,7 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n description: "Use Novita AI API for extremely fast streaming of open-source models", icon: "novita.png", - longDescription: `[Novita AI](https://novita.ai) offers an affordable, reliable, and simple inference platform with scalable [LLM APIs](https://novita.ai/docs/model-api/reference/introduction.html), empowering developers to build AI applications. To get started with Novita AI:\n1. Obtain an API key from [here](https://novita.ai)\n2. Paste below\n3. Select a model preset`, + longDescription: `[Novita AI](https://novita.ai?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) offers an affordable, reliable, and simple inference platform with scalable [LLM APIs](https://novita.ai/docs/model-api/reference/introduction.html), empowering developers to build AI applications. To get started with Novita AI:\n1. Obtain an API key from [here](https://novita.ai/settings/key-management?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link)\n2. Paste below\n3. Select a model preset`, tags: [ModelProviderTags.RequiresApiKey, ModelProviderTags.OpenSource], params: { apiKey: "", @@ -432,7 +432,7 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n p.params.contextLength = 4096; return p; }), - apiKeyUrl: "https://novita.ai/settings/key-management", + apiKeyUrl: "https://novita.ai/settings/key-management?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link", }, gemini: { title: "Google Gemini API", From 3df34b725e873fcd42058474d83ef634e21d5cad Mon Sep 17 00:00:00 2001 From: liuk Date: Wed, 25 Dec 2024 01:11:38 +0800 Subject: [PATCH 023/114] fix: Revert filepath changes --- .../autocomplete/AutocompleteService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt index 8be92742c..e7a1fb830 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt @@ -87,7 +87,7 @@ class AutocompleteService(private val project: Project) { val column = editor.caretModel.primaryCaret.logicalPosition.column val input = mapOf( "completionId" to completionId, - "filepath" to virtualFile?.path, + "filepath" to virtualFile?.url, "pos" to mapOf( "line" to line, "character" to column From d401a5c11fdf5b3267269ff3603f83318a9dd9ad Mon Sep 17 00:00:00 2001 From: vercel Date: Wed, 25 Dec 2024 14:45:14 +0800 Subject: [PATCH 024/114] feat: fix models --- core/llm/llms/Novita.ts | 6 +++++ extensions/vscode/config_schema.json | 3 ++- gui/src/pages/AddNewModel/configs/models.ts | 27 +++++++++++++++++++ .../pages/AddNewModel/configs/providers.ts | 2 +- 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/core/llm/llms/Novita.ts b/core/llm/llms/Novita.ts index 9121bd6c2..2f5c61b55 100644 --- a/core/llm/llms/Novita.ts +++ b/core/llm/llms/Novita.ts @@ -9,11 +9,17 @@ class Novita extends OpenAI { }; private static MODEL_IDS: { [name: string]: string } = { + "llama3-8b": "meta-llama/llama-3-8b-instruct", + "llama3-70b": "meta-llama/llama-3-70b-instruct", "llama3.1-8b": "meta-llama/llama-3.1-8b-instruct", "llama3.1-70b": "meta-llama/llama-3.1-70b-instruct", "llama3.1-405b": "meta-llama/llama-3.1-405b-instruct", + "llama3.2-1b": "meta-llama/llama-3.2-1b-instruct", "llama3.2-3b": "meta-llama/llama-3.2-3b-instruct", "llama3.2-11b": "meta-llama/llama-3.2-11b-vision-instruct", + "llama3.3-70b": "meta-llama/llama-3.3-70b-instruct", + "mistral-nemo": "mistralai/mistral-nemo", + "mistral-7b": "mistralai/mistral-7b-instruct", }; protected _convertModelName(model: string) { diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 3ae0e3cc5..0bd81a53e 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -1003,9 +1003,10 @@ "llama3.1-8b", "llama3.1-70b", "llama3.1-405b", + "llama3.2-1b", "llama3.2-3b", "llama3.2-11b", - "llama-3.3-70b", + "llama3.3-70b", "mistral-nemo", "mistral-7b" ] diff --git a/gui/src/pages/AddNewModel/configs/models.ts b/gui/src/pages/AddNewModel/configs/models.ts index d43ed2ec1..d3ca71c5d 100644 --- a/gui/src/pages/AddNewModel/configs/models.ts +++ b/gui/src/pages/AddNewModel/configs/models.ts @@ -58,6 +58,33 @@ export const models: { [key: string]: ModelPackage } = { ], isOpenSource: true, }, + mistralChat: { + title: "Mistral Chat", + description: + "A series of open-weight models created by Mistral AI, highly competent for code generation and other tasks", + params: { + title: "Mistral", + model: "mistralai/mistral-7b-instruct", + contextLength: 4096, + }, + dimensions: [ + { + name: "Parameter Count", + description: "The number of parameters in the model", + options: { + "7b": { + model: "mistralai/mistral-7b-instruct", + title: "Mistral-7b", + }, + }, + }, + ], + icon: "mistral.png", + providerOptions: [ + "novita", + ], + isOpenSource: true, + }, llama31Chat: { title: "Llama3.1 Chat", description: "A model from Meta, fine-tuned for chat", diff --git a/gui/src/pages/AddNewModel/configs/providers.ts b/gui/src/pages/AddNewModel/configs/providers.ts index 49b30e409..f29482975 100644 --- a/gui/src/pages/AddNewModel/configs/providers.ts +++ b/gui/src/pages/AddNewModel/configs/providers.ts @@ -427,7 +427,7 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n ...completionParamsInputsConfigs, ], packages: [ - models.llama318BChat, + models.llama318BChat, models.mistralChat ].map((p) => { p.params.contextLength = 4096; return p; From e270b206808a35d5156f851fe66c1e1d13752812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8E=9F=E4=BF=8A=E6=9D=B0?= Date: Wed, 25 Dec 2024 17:37:49 +0800 Subject: [PATCH 025/114] Remove the extra "+" sign from the IDEA shortcut --- docs/docs/getting-started/install.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/getting-started/install.md b/docs/docs/getting-started/install.md index 20aa52baa..3729edbfd 100644 --- a/docs/docs/getting-started/install.md +++ b/docs/docs/getting-started/install.md @@ -18,7 +18,7 @@ If you have any problems, see the [troubleshooting guide](troubleshooting.md) or ## JetBrains -1. Open your JetBrains IDE and open **Settings** using Ctrl + +Alt + S +1. Open your JetBrains IDE and open **Settings** using Ctrl + Alt + S 2. Select **Plugins** on the sidebar and search for "Continue" in the marketplace 3. Click `Install`, which will cause the Continue logo to show up on the right toolbar From decd04eddd4965b9f76c7a9a3abd276d8d2e1692 Mon Sep 17 00:00:00 2001 From: liuk Date: Wed, 25 Dec 2024 23:03:53 +0800 Subject: [PATCH 026/114] fix: Skip duplicate checks at document end or blank text Prevent autocomplete from truncating when the cursor is at the end of the document or when the text after the cursor is blank. --- .../autocomplete/AutocompleteService.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt index 6279e03f7..2dc6ba021 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt @@ -120,6 +120,10 @@ class AutocompleteService(private val project: Project) { return ApplicationManager.getApplication().runReadAction { val document = editor.document val caretOffset = editor.caretModel.offset + + // Don't care about it if it's at the end of the document + if (caretOffset == document.textLength) return@runReadAction completion + val N = 10 var textAfterCursor = if (caretOffset + N <= document.textLength) { document.getText(com.intellij.openapi.util.TextRange(caretOffset, caretOffset + N)) @@ -127,6 +131,9 @@ class AutocompleteService(private val project: Project) { document.getText(com.intellij.openapi.util.TextRange(caretOffset, document.textLength)) } + // Avoid truncating the completion text when the text after the cursor is blank + if (textAfterCursor.isBlank()) return@runReadAction completion + // Determine the index of a newline character within the text following the cursor. val newlineIndex = textAfterCursor.indexOf("\r\n").takeIf { it >= 0 } ?: textAfterCursor.indexOf('\n') // If a newline character is found and the current line is not empty, truncate the text at that point. From 0a7da2067e8d8567084d05f69038b7ca95464d1f Mon Sep 17 00:00:00 2001 From: liuk Date: Thu, 26 Dec 2024 19:46:53 +0800 Subject: [PATCH 027/114] fix: Resolved errors related to incorrect URIs --- .../activities/ContinuePluginStartupActivity.kt | 8 ++++---- .../autocomplete/AutocompleteService.kt | 6 +++++- .../continue/IdeProtocolClient.kt | 14 ++++++++------ .../continue/IntelliJIde.kt | 13 +++++++------ .../continueintellijextension/utils/Utils.kt | 5 ++++- 5 files changed, 28 insertions(+), 18 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt index facc89424..72819421a 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt @@ -10,7 +10,7 @@ import com.github.continuedev.continueintellijextension.listeners.ContinuePlugin import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings import com.github.continuedev.continueintellijextension.services.ContinuePluginService import com.github.continuedev.continueintellijextension.services.SettingsListener -import com.intellij.openapi.Disposable +import com.github.continuedev.continueintellijextension.utils.toUriOrNull import com.intellij.openapi.actionSystem.KeyboardShortcut import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.ApplicationNamesInfo @@ -162,7 +162,7 @@ class ContinuePluginStartupActivity : StartupActivity, DumbAware { override fun after(events: List) { // Collect all relevant URIs for deletions val deletedURIs = events.filterIsInstance() - .map { event -> event.file.url } + .mapNotNull { event -> event.file.toUriOrNull() } // Send "files/deleted" message if there are any deletions if (deletedURIs.isNotEmpty()) { @@ -172,7 +172,7 @@ class ContinuePluginStartupActivity : StartupActivity, DumbAware { // Collect all relevant URIs for content changes val changedURIs = events.filterIsInstance() - .map { event -> event.file.url } + .mapNotNull { event -> event.file.toUriOrNull() } // Send "files/changed" message if there are any content changes if (changedURIs.isNotEmpty()) { @@ -220,7 +220,7 @@ class ContinuePluginStartupActivity : StartupActivity, DumbAware { // Reload the WebView continuePluginService?.let { pluginService -> val allModulePaths = ModuleManager.getInstance(project).modules - .flatMap { module -> ModuleRootManager.getInstance(module).contentRoots.map { it.url } } + .flatMap { module -> ModuleRootManager.getInstance(module).contentRoots.mapNotNull { it.toUriOrNull() } } val topLevelModulePaths = allModulePaths .filter { modulePath -> allModulePaths.none { it != modulePath && modulePath.startsWith(it) } } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt index e7a1fb830..2941aae8e 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteService.kt @@ -2,6 +2,7 @@ package com.github.continuedev.continueintellijextension.autocomplete import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings import com.github.continuedev.continueintellijextension.services.ContinuePluginService +import com.github.continuedev.continueintellijextension.utils.toUriOrNull import com.github.continuedev.continueintellijextension.utils.uuid import com.intellij.injected.editor.VirtualFileWindow import com.intellij.openapi.application.* @@ -83,11 +84,14 @@ class AutocompleteService(private val project: Project) { // Request a completion from the core val virtualFile = FileDocumentManager.getInstance().getFile(editor.document) + + val uri = virtualFile?.toUriOrNull() ?: return + val line = editor.caretModel.primaryCaret.logicalPosition.line val column = editor.caretModel.primaryCaret.logicalPosition.column val input = mapOf( "completionId" to completionId, - "filepath" to virtualFile?.url, + "filepath" to uri, "pos" to mapOf( "line" to line, "character" to column diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt index 69e06e89e..43ee85e29 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt @@ -546,12 +546,14 @@ class IdeProtocolClient( val startChar = startOffset - document.getLineStartOffset(startLine) val endChar = endOffset - document.getLineStartOffset(endLine) - return@runReadAction RangeInFileWithContents( - virtualFile.url, Range( - Position(startLine, startChar), - Position(endLine, endChar) - ), selectedText - ) + return@runReadAction virtualFile.toUriOrNull()?.let { + RangeInFileWithContents( + it, Range( + Position(startLine, startChar), + Position(endLine, endChar) + ), selectedText + ) + } } return result diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt index 154476f5e..39d7b3681 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt @@ -5,6 +5,7 @@ import com.github.continuedev.continueintellijextension.services.ContinuePluginS import com.github.continuedev.continueintellijextension.utils.OS import com.github.continuedev.continueintellijextension.utils.getMachineUniqueID import com.github.continuedev.continueintellijextension.utils.getOS +import com.github.continuedev.continueintellijextension.utils.toUriOrNull import com.intellij.codeInsight.daemon.impl.HighlightInfo import com.intellij.execution.configurations.GeneralCommandLine import com.intellij.execution.util.ExecUtil @@ -180,7 +181,7 @@ class IntelliJIDE( for (workspaceDir in workspaceDirs) { val dir = VirtualFileManager.getInstance().findFileByUrl(workspaceDir) if (dir != null) { - val contents = dir.children.map { it.url } + val contents = dir.children.mapNotNull { it.toUriOrNull() } // Find any .continuerc.json files for (file in contents) { @@ -307,16 +308,16 @@ class IntelliJIDE( override suspend fun getOpenFiles(): List { val fileEditorManager = FileEditorManager.getInstance(project) - return fileEditorManager.openFiles.map { it.url }.toList() + return fileEditorManager.openFiles.mapNotNull { it.toUriOrNull() }.toList() } override suspend fun getCurrentFile(): Map? { val fileEditorManager = FileEditorManager.getInstance(project) val editor = fileEditorManager.selectedTextEditor val virtualFile = editor?.document?.let { FileDocumentManager.getInstance().getFile(it) } - return virtualFile?.let { + return virtualFile?.toUriOrNull()?.let { mapOf( - "path" to it.url, + "path" to it, "contents" to editor.document.text, "isUntitled" to false ) @@ -382,7 +383,7 @@ class IntelliJIDE( problems.add( Problem( - filepath = psiFile.virtualFile?.url ?: "", + filepath = psiFile.virtualFile?.toUriOrNull() ?: "", range = Range( start = Position( line = startLineNumber, @@ -561,6 +562,6 @@ class IntelliJIDE( return dirs } - return listOfNotNull(project.guessProjectDir()?.url).toTypedArray() + return listOfNotNull(project.guessProjectDir()?.toUriOrNull()).toTypedArray() } } \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/utils/Utils.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/utils/Utils.kt index fe29b6235..7e90ba99e 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/utils/Utils.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/utils/Utils.kt @@ -1,5 +1,6 @@ package com.github.continuedev.continueintellijextension.utils +import com.intellij.openapi.vfs.VirtualFile import java.net.NetworkInterface import java.util.* import java.awt.event.KeyEvent.* @@ -77,4 +78,6 @@ fun getMachineUniqueID(): String { fun uuid(): String { return UUID.randomUUID().toString() -} \ No newline at end of file +} + +fun VirtualFile.toUriOrNull(): String? = fileSystem.getNioPath(this)?.toUri()?.toString()?.removeSuffix("/") \ No newline at end of file From 1a1585e8800cb8f33425b6ddb4d83d107da0c7b9 Mon Sep 17 00:00:00 2001 From: Prajna Kandarpa Date: Fri, 27 Dec 2024 13:25:21 +0530 Subject: [PATCH 028/114] minor documentationtip for aws bedrock --- .../model-providers/top-level/bedrock.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/docs/customize/model-providers/top-level/bedrock.md b/docs/docs/customize/model-providers/top-level/bedrock.md index fb88d5ae0..67d919a2f 100644 --- a/docs/docs/customize/model-providers/top-level/bedrock.md +++ b/docs/docs/customize/model-providers/top-level/bedrock.md @@ -22,6 +22,22 @@ We recommend configuring **Claude 3.5 Sonnet** as your chat model. ] } ``` +> If you run into the following error when connecting to the new Claude 3.5 Sonnet 2 models from AWS - `400 Invocation of model ID anthropic.claude-3-5-sonnet-20241022-v2:0 with on-demand throughput isn’t supported. Retry your request with the ID or ARN of an inference profile that contains this model.` + +> You can fix this using the following config.json +```json title="config.json" +{ + "models": [ + { + "title": "Claude 3.5 Sonnet", + "provider": "bedrock", + "model": "us.anthropic.claude-3-5-sonnet-20241022-v2:0", + "region": "us-east-1", + "profile": "bedrock" + } + ] +} +``` ## Autocomplete model From 43e76f8aa21a9c937ca1c1a834ae16c74e1cb32b Mon Sep 17 00:00:00 2001 From: henry Date: Fri, 27 Dec 2024 18:31:54 -0500 Subject: [PATCH 029/114] fixed fullscreen bug --- extensions/vscode/src/commands.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index b83d3d380..3c9dc2d90 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -37,6 +37,7 @@ import { Battery } from "./util/battery"; import { VsCodeIde } from "./VsCodeIde"; import type { VsCodeWebviewProtocol } from "./webviewProtocol"; +import { Disposable } from "vscode-languageclient"; let fullScreenPanel: vscode.WebviewPanel | undefined; @@ -767,14 +768,17 @@ const getCommandsMap: ( true, ); - panel.onDidChangeViewState(() => { - vscode.commands.executeCommand("continue.newSession"); - if (sessionId) { - vscode.commands.executeCommand( - "continue.focusContinueSessionId", - sessionId, - ); + const sessionLoader = panel.onDidChangeViewState(() => { + if(!fullScreenTab){ + vscode.commands.executeCommand("continue.newSession"); + if (sessionId) { + vscode.commands.executeCommand( + "continue.focusContinueSessionId", + sessionId, + ); + } } + sessionLoader.dispose() }); // When panel closes, reset the webview and focus From 9451f0e7bb71731bc794cf757cbc018e59908605 Mon Sep 17 00:00:00 2001 From: henry Date: Fri, 27 Dec 2024 23:52:33 -0500 Subject: [PATCH 030/114] removed if statement i forgot about --- extensions/vscode/src/commands.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index 3c9dc2d90..d3fe2eb43 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -769,14 +769,12 @@ const getCommandsMap: ( ); const sessionLoader = panel.onDidChangeViewState(() => { - if(!fullScreenTab){ - vscode.commands.executeCommand("continue.newSession"); - if (sessionId) { - vscode.commands.executeCommand( - "continue.focusContinueSessionId", - sessionId, - ); - } + vscode.commands.executeCommand("continue.newSession"); + if (sessionId) { + vscode.commands.executeCommand( + "continue.focusContinueSessionId", + sessionId, + ); } sessionLoader.dispose() }); From caf31ed11f55d7be40cb74225dfd1068594deaec Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Sun, 29 Dec 2024 15:14:56 +0100 Subject: [PATCH 031/114] clipboard context provider p1 --- .../providers/ClipboardContextProvider.ts | 57 +++++++++++++++++++ core/core.ts | 5 ++ core/protocol/core.ts | 1 + core/util/clipboardCache.ts | 54 ++++++++++++++++++ extensions/vscode/package-lock.json | 4 +- extensions/vscode/src/commands.ts | 13 ++++- 6 files changed, 130 insertions(+), 4 deletions(-) create mode 100644 core/context/providers/ClipboardContextProvider.ts create mode 100644 core/util/clipboardCache.ts diff --git a/core/context/providers/ClipboardContextProvider.ts b/core/context/providers/ClipboardContextProvider.ts new file mode 100644 index 000000000..eb128ea7f --- /dev/null +++ b/core/context/providers/ClipboardContextProvider.ts @@ -0,0 +1,57 @@ +import { BaseContextProvider } from ".."; +import { + ContextItem, + ContextProviderDescription, + ContextProviderExtras, + ContextSubmenuItem, + LoadSubmenuItemsArgs, +} from "../.."; +import { clipboardCache } from "../../util/clipboardCache"; + +const MAX_CLIPBOARD_ITEMS = 10; + +class ClipboardContextProvider extends BaseContextProvider { + static description: ContextProviderDescription = { + title: "clipboard", + displayTitle: "Clipboard", + description: "Use recent copies", + type: "submenu", + }; + + async getContextItems( + query: string, + extras: ContextProviderExtras, + ): Promise { + // Assume the query is a cache id + const id = query.trim(); + const content = clipboardCache.get(id); + + if (content) { + clipboardCache.select(id); + return [ + { + name: "Clipboard item", + description: content.slice(0, 20), + content, + }, + ]; + } + return []; + } + + async loadSubmenuItems( + args: LoadSubmenuItemsArgs, + ): Promise { + const recentClipboardItems = clipboardCache.getNItems(MAX_CLIPBOARD_ITEMS); + + return recentClipboardItems.map((item, index) => { + return { + id: item.id, + title: item.content.slice(0, 20), + description: `#${index + 1}`, + }; + }); + } +} + +export default ClipboardContextProvider; diff --git a/core/core.ts b/core/core.ts index 14389910c..90a6246c3 100644 --- a/core/core.ts +++ b/core/core.ts @@ -46,6 +46,7 @@ import * as URI from "uri-js"; import { SYSTEM_PROMPT_DOT_FILE } from "./config/getSystemPromptDotFile"; import type { IMessenger, Message } from "./protocol/messenger"; import { localPathToUri } from "./util/pathToUri"; +import { clipboardCache } from "./util/clipboardCache"; export class Core { // implements IMessenger @@ -377,6 +378,10 @@ export class Core { }; }); + on("clipboardCache/add", (msg) => { + clipboardCache.add(uuidv4(), msg.data.content); + }); + async function* llmStreamChat( configHandler: ConfigHandler, abortedMessageIds: Set, diff --git a/core/protocol/core.ts b/core/protocol/core.ts index e05ce1bc4..d0c84121f 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -193,4 +193,5 @@ export type ToCoreFromIdeOrWebviewProtocol = { { toolCall: ToolCall; selectedModelTitle: string }, { contextItems: ContextItem[] }, ]; + "clipboardCache/add": [{ content: string }, void]; }; diff --git a/core/util/clipboardCache.ts b/core/util/clipboardCache.ts new file mode 100644 index 000000000..4ecd16afc --- /dev/null +++ b/core/util/clipboardCache.ts @@ -0,0 +1,54 @@ +class ClipboardCache { + private cache: Map; + private order: string[]; + private readonly maxSize = 30; + + constructor() { + this.cache = new Map(); + this.order = []; + } + + add(id: string, content: string): void { + if (!content) { + return; + } + if (this.order.length >= this.maxSize) { + const oldest = this.order.pop(); + if (oldest) { + this.cache.delete(oldest); + } + } + + this.cache.set(id, content); + this.order.unshift(id); + } + + getNItems(count: number): { + id: string; + content: string; + }[] { + return this.order.slice(0, count).map((id) => ({ + id, + content: this.cache.get(id) || "", + })); + } + + get(id: string): string | undefined { + return this.cache.get(id); + } + + select(id: string): void { + const index = this.order.indexOf(id); + if (index > -1) { + this.order.splice(index, 1); + this.order.unshift(id); + } + } + + clear(): void { + this.cache.clear(); + this.order = []; + } +} + +export const clipboardCache = new ClipboardCache(); diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 8f5cad8a0..0a2dd8330 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.247", + "version": "0.9.248", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.247", + "version": "0.9.248", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index b83d3d380..147a1f118 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -1001,7 +1001,10 @@ const getCommandsMap: ( }; }; -const registerCopyBufferSpy = (context: vscode.ExtensionContext) => { +const registerCopyBufferSpy = ( + context: vscode.ExtensionContext, + core: Core, +) => { const typeDisposable = vscode.commands.registerCommand( "editor.action.clipboardCopyAction", async (arg) => doCopy(typeDisposable), @@ -1014,6 +1017,12 @@ const registerCopyBufferSpy = (context: vscode.ExtensionContext) => { const clipboardText = await vscode.env.clipboard.readText(); + if (clipboardText) { + core.invoke("clipboardCache/add", { + content: clipboardText, + }); + } + await context.workspaceState.update("continue.copyBuffer", { text: clipboardText, copiedAt: new Date().toISOString(), @@ -1043,7 +1052,7 @@ export function registerAllCommands( core: Core, editDecorationManager: EditDecorationManager, ) { - registerCopyBufferSpy(context); + registerCopyBufferSpy(context, core); for (const [command, callback] of Object.entries( getCommandsMap( From 465362e407ac7ee0da1951f3ee78d6f9c60a19a3 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Sun, 29 Dec 2024 15:34:13 +0100 Subject: [PATCH 032/114] clipboard context provider p2 --- core/context/providers/ClipboardContextProvider.ts | 4 ++-- core/context/providers/index.ts | 2 ++ core/core.ts | 3 +++ core/index.d.ts | 1 + docs/docs/customize/context-providers.md | 14 ++++++++++++++ extensions/vscode/config_schema.json | 8 +++----- 6 files changed, 25 insertions(+), 7 deletions(-) diff --git a/core/context/providers/ClipboardContextProvider.ts b/core/context/providers/ClipboardContextProvider.ts index eb128ea7f..86e64d619 100644 --- a/core/context/providers/ClipboardContextProvider.ts +++ b/core/context/providers/ClipboardContextProvider.ts @@ -14,7 +14,7 @@ class ClipboardContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { title: "clipboard", displayTitle: "Clipboard", - description: "Use recent copies", + description: "Recent copies", type: "submenu", }; @@ -43,7 +43,7 @@ class ClipboardContextProvider extends BaseContextProvider { args: LoadSubmenuItemsArgs, ): Promise { const recentClipboardItems = clipboardCache.getNItems(MAX_CLIPBOARD_ITEMS); - + console.log(recentClipboardItems); return recentClipboardItems.map((item, index) => { return { id: item.id, diff --git a/core/context/providers/index.ts b/core/context/providers/index.ts index f5656832c..3d1d7cc55 100644 --- a/core/context/providers/index.ts +++ b/core/context/providers/index.ts @@ -1,5 +1,6 @@ import { BaseContextProvider } from "../"; import { ContextProviderName } from "../../"; +import ClipboardContextProvider from "./ClipboardContextProvider"; import CodeContextProvider from "./CodeContextProvider"; import ContinueProxyContextProvider from "./ContinueProxyContextProvider"; @@ -62,6 +63,7 @@ export const Providers: (typeof BaseContextProvider)[] = [ GreptileContextProvider, WebContextProvider, MCPContextProvider, + ClipboardContextProvider, ]; export function contextProviderClassFromName( diff --git a/core/core.ts b/core/core.ts index 90a6246c3..871856038 100644 --- a/core/core.ts +++ b/core/core.ts @@ -295,6 +295,7 @@ export class Core { }); on("context/loadSubmenuItems", async (msg) => { + console.log("Load SUMBENU ITEMS", msg); const config = await this.config(); if (!config) { return []; @@ -379,7 +380,9 @@ export class Core { }); on("clipboardCache/add", (msg) => { + console.log("ADD TO CLIPBOARD", msg); clipboardCache.add(uuidv4(), msg.data.content); + this.messenger.send("refreshSubmenuItems", undefined); }); async function* llmStreamChat( diff --git a/core/index.d.ts b/core/index.d.ts index d916a19f1..c21040e3c 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -751,6 +751,7 @@ export type ContextProviderName = | "issue" | "repo-map" | "url" + | "clipboard" | string; export type TemplateType = diff --git a/docs/docs/customize/context-providers.md b/docs/docs/customize/context-providers.md index 256f4eab5..0b48c386b 100644 --- a/docs/docs/customize/context-providers.md +++ b/docs/docs/customize/context-providers.md @@ -576,6 +576,20 @@ The response 200 OK should be a JSON object with the following structure: } ``` +### `@Clipboard` + +Reference recent clipboard items + +```json title="config.json" +{ + "contextProviders": [ + { + "name": "clipboard" + } + ] +} +``` + ### Requesting Context Providers Not seeing what you want? Create an issue [here](https://github.com/continuedev/continue/issues/new?assignees=TyDunn&labels=enhancement&projects=&template=feature-request-%F0%9F%92%AA.md&title=) to request a new Context Provider. diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index f2c98642f..d60daa499 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -1864,7 +1864,8 @@ "os", "repo-map", "greptile", - "web" + "web", + "clipboard" ], "markdownEnumDescriptions": [ "Reference the contents of the current changes as given by `git diff`", @@ -2805,10 +2806,7 @@ "type": "object", "properties": { "model": { - "enum": [ - "cohere.rerank-v3-5:0", - "amazon.rerank-v1:0" - ] + "enum": ["cohere.rerank-v3-5:0", "amazon.rerank-v1:0"] } }, "required": ["model"] From 72d4ad039f0275e1a3cfc1946b009db502f7d05a Mon Sep 17 00:00:00 2001 From: Test Date: Mon, 30 Dec 2024 11:52:27 -0600 Subject: [PATCH 033/114] bugfix(JB): handle disposed editor tooltips --- .../listeners/ContinuePluginSelectionListener.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/listeners/ContinuePluginSelectionListener.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/listeners/ContinuePluginSelectionListener.kt index 4676cae33..24d9787f5 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/listeners/ContinuePluginSelectionListener.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/listeners/ContinuePluginSelectionListener.kt @@ -28,6 +28,10 @@ class ContinuePluginSelectionListener( private var lastActiveEditor: Editor? = null override fun selectionChanged(e: SelectionEvent) { + if (e.editor.isDisposed || e.editor.project?.isDisposed == true) { + return + } + debouncer.debounce { handleSelection(e) } } From ddd3915c7b9e1f9ffa37481539da5bfd6308ac1e Mon Sep 17 00:00:00 2001 From: Test Date: Mon, 30 Dec 2024 12:38:55 -0600 Subject: [PATCH 034/114] Update Autocomplete.kt --- .../continuedev/continueintellijextension/e2e/Autocomplete.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt index fdef6bb0a..eb100bbe0 100644 --- a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt +++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt @@ -33,7 +33,8 @@ class Autocomplete {init { @AfterEach fun closeProject(remoteRobot: RemoteRobot) = CommonSteps(remoteRobot).closeProject() - @Test + // TODO: Uncomment +// @Test @Video fun displayCompletion(remoteRobot: RemoteRobot): Unit = with(remoteRobot) { welcomeFrame { From 7db443232916109ced1907df8e0555c1d4c6d46d Mon Sep 17 00:00:00 2001 From: Test Date: Mon, 30 Dec 2024 12:58:35 -0600 Subject: [PATCH 035/114] update tests --- .../continueintellijextension/e2e/Autocomplete.kt | 12 +++++------- .../continuedev/continueintellijextension/e2e/GUI.kt | 10 +++++++++- .../continueintellijextension/e2e/Onboarding.kt | 2 -- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt index eb100bbe0..25179123f 100644 --- a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt +++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt @@ -21,9 +21,10 @@ import java.time.Duration.ofMinutes import java.time.Duration.ofSeconds @ExtendWith(RemoteRobotExtension::class) -class Autocomplete {init { - StepsLogger.init() -} +class Autocomplete { + init { + StepsLogger.init() + } @BeforeEach fun waitForIde(remoteRobot: RemoteRobot) { @@ -33,8 +34,7 @@ class Autocomplete {init { @AfterEach fun closeProject(remoteRobot: RemoteRobot) = CommonSteps(remoteRobot).closeProject() - // TODO: Uncomment -// @Test + @Test @Video fun displayCompletion(remoteRobot: RemoteRobot): Unit = with(remoteRobot) { welcomeFrame { @@ -48,7 +48,6 @@ class Autocomplete {init { // Wait for the default "Main.java" tab to load // Our "continue_tutorial.java.ft" tab loads first, but then "Main.java" takes focus. - // So we need to wait for that to occur, and then focus on "continue_tutorial.java.ft" waitFor(ofSeconds(20)) { findAll( byXpath("//div[@accessiblename='Main.java' and @class='EditorTabLabel']") @@ -56,7 +55,6 @@ class Autocomplete {init { } idea { - waitFor(ofMinutes(5)) { isDumbMode().not() } with(textEditor()) { val userMsg = "TEST_USER_MESSAGE_0" editor.insertTextAtLine(0, 0, userMsg) diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt index 2a0775ce1..4a47fb45a 100644 --- a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt +++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt @@ -51,9 +51,17 @@ class GUI { } } + // Wait for the default "Main.java" tab to load + // Our "continue_tutorial.java.ft" tab loads first, but then "Main.java" takes focus. + // If we don't wait for this, clicking on the GUI may fail because a popup displays + // while the `continue_tutorial.java` is loading. + waitFor(ofSeconds(20)) { + findAll( + byXpath("//div[@accessiblename='Main.java' and @class='EditorTabLabel']") + ).isNotEmpty() + } idea { - waitFor(ofMinutes(5)) { isDumbMode().not() } step("Manually open the webview") { // Manually open the webview find(byXpath("//div[@text='Continue']"), ofSeconds((10))).click() diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Onboarding.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Onboarding.kt index 02c75552d..2f8cdbbb1 100644 --- a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Onboarding.kt +++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Onboarding.kt @@ -48,8 +48,6 @@ class Onboarding { } idea { - waitFor(ofMinutes(5)) { isDumbMode().not() } - // Wait for the default "Main.java" tab to load // Our "continue_tutorial.java.ft" tab loads first, but then "Main.java" takes focus. // So we need to wait for that to occur, and then focus on "continue_tutorial.java.ft" From ddf19053b1b4afb37fc18a60ddd7b6abc86e27c8 Mon Sep 17 00:00:00 2001 From: Test Date: Mon, 30 Dec 2024 16:47:34 -0600 Subject: [PATCH 036/114] bugfix(GUI): broken Chinese input w/ codeblock --- gui/src/components/mainInput/CodeBlockComponent.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gui/src/components/mainInput/CodeBlockComponent.tsx b/gui/src/components/mainInput/CodeBlockComponent.tsx index f8c359e14..0a0e7996b 100644 --- a/gui/src/components/mainInput/CodeBlockComponent.tsx +++ b/gui/src/components/mainInput/CodeBlockComponent.tsx @@ -1,4 +1,4 @@ -import { NodeViewWrapper } from "@tiptap/react"; +import { NodeViewWrapper, NodeViewWrapperProps } from "@tiptap/react"; import { ContextItemWithId } from "core"; import { vscBadgeBackground } from ".."; import CodeSnippetPreview from "../markdown/CodeSnippetPreview"; @@ -13,8 +13,15 @@ export const CodeBlockComponent = (props: any) => { // const isFirstContextItem = item.id === contextItems[0]?.id; const isFirstContextItem = false; // TODO: fix this, decided not worth the insane renders for now + // Not setting this as a "p" will cause issues with foreign keyboards + // See https://github.com/continuedev/continue/issues/3199 + const nodeViewWrapperTag: NodeViewWrapperProps["as"] = "p"; + return ( - + Date: Mon, 30 Dec 2024 17:19:56 -0600 Subject: [PATCH 037/114] bugfix(GUI): increase z-index on tippy mentionlist --- gui/src/components/mainInput/TipTapEditor.tsx | 17 +++++++---------- gui/src/components/mainInput/getSuggestion.ts | 4 +++- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx index bcd7328a2..0312b3f53 100644 --- a/gui/src/components/mainInput/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor.tsx @@ -175,6 +175,8 @@ interface TipTapEditorProps { historyKey: string; } +export const TIPPY_DIV_ID = "tippy-js-div"; + function TipTapEditor(props: TipTapEditorProps) { const dispatch = useAppDispatch(); @@ -976,22 +978,17 @@ function TipTapEditor(props: TipTapEditorProps) { {showDragOverMsg && modelSupportsImages( - defaultModel.provider, - defaultModel.model, - defaultModel.title, - defaultModel.capabilities, + defaultModel?.provider || "", + defaultModel?.model || "", + defaultModel?.title, + defaultModel?.capabilities, ) && ( <> Hold ⇧ to drop image )} -
+
); } diff --git a/gui/src/components/mainInput/getSuggestion.ts b/gui/src/components/mainInput/getSuggestion.ts index 41e6338c1..5ec1f778a 100644 --- a/gui/src/components/mainInput/getSuggestion.ts +++ b/gui/src/components/mainInput/getSuggestion.ts @@ -5,6 +5,7 @@ import tippy from "tippy.js"; import { IIdeMessenger } from "../../context/IdeMessenger"; import MentionList from "./MentionList"; import { ComboBoxItem, ComboBoxItemType, ComboBoxSubAction } from "./types"; +import { TIPPY_DIV_ID } from "./TipTapEditor"; function getSuggestion( items: (props: { query: string }) => Promise, @@ -37,7 +38,8 @@ function getSuggestion( return; } - const container = document.getElementById("tippy-js-div"); + const container = document.getElementById(TIPPY_DIV_ID); + if (!container) { console.log("no container"); return; From 79736c3108313204184bb7d833ac21e23341354f Mon Sep 17 00:00:00 2001 From: liuk Date: Wed, 1 Jan 2025 00:25:18 +0800 Subject: [PATCH 038/114] fix: Add directory checks and optimize token usage - Added check to skip directories when reading file content. - Optimized token usage by removing unnecessary `\r` characters. --- .../continueintellijextension/continue/IntelliJIde.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt index 39d7b3681..d304e8a02 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt @@ -262,7 +262,7 @@ class IntelliJIDE( content } else { val file = File(URI(filepath)) - if (!file.exists()) return "" + if (!file.exists() || file.isDirectory) return "" withContext(Dispatchers.IO) { FileInputStream(file).use { fis -> val sizeToRead = minOf(100000, file.length()).toInt() @@ -270,6 +270,8 @@ class IntelliJIDE( val bytesRead = fis.read(buffer, 0, sizeToRead) if (bytesRead <= 0) return@use "" String(buffer, 0, bytesRead, Charset.forName("UTF-8")) + // `\r` takes up unnecessary tokens + .lineSequence().joinToString("\n") } } } From cd37f23c4fcc48a64b919189da04d8e0751d5ff0 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 31 Dec 2024 15:11:08 -0600 Subject: [PATCH 039/114] only run onboarding test --- .../continuedev/continueintellijextension/e2e/Autocomplete.kt | 2 +- .../com/github/continuedev/continueintellijextension/e2e/GUI.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt index 25179123f..fdb271639 100644 --- a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt +++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Autocomplete.kt @@ -34,7 +34,7 @@ class Autocomplete { @AfterEach fun closeProject(remoteRobot: RemoteRobot) = CommonSteps(remoteRobot).closeProject() - @Test + // @Test @Video fun displayCompletion(remoteRobot: RemoteRobot): Unit = with(remoteRobot) { welcomeFrame { diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt index 4a47fb45a..cbc3a7272 100644 --- a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt +++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt @@ -39,7 +39,7 @@ class GUI { @AfterEach fun closeProject(remoteRobot: RemoteRobot) = CommonSteps(remoteRobot).closeProject() - @Test + // @Test @Video fun highlightCode(remoteRobot: RemoteRobot): Unit = with(remoteRobot) { welcomeFrame { From 54e41d6de6eb7685425ec79241894a787a4260b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20=C3=96berg?= Date: Wed, 1 Jan 2025 17:25:22 +0100 Subject: [PATCH 040/114] Update model-setup.md --- docs/docs/autocomplete/model-setup.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/docs/autocomplete/model-setup.md b/docs/docs/autocomplete/model-setup.md index 8aae88c75..221c17ddd 100644 --- a/docs/docs/autocomplete/model-setup.md +++ b/docs/docs/autocomplete/model-setup.md @@ -31,14 +31,14 @@ For those preferring local execution or self-hosting,`Qwen2.5-Coder 1.5B` offers ```json title="config.json"" { "tabAutocompleteModel": { - "title": "Qwen2.5-Coder 1.5B", - "model": "qwen2.5-coder:1.5b", + "title": "Qwen2.5-Coder 1.5B Base", + "model": "qwen2.5-coder:1.5b-base", "provider": "ollama" } } ``` -Have more compute? Use `qwen2.5-coder:7b` for potentially higher-quality suggestions. +Have more compute? Use `qwen2.5-coder:7b-base` for potentially higher-quality suggestions. :::note From 11b657a1546d2e03814205a4de0158ccdf65bf15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20=C3=96berg?= Date: Wed, 1 Jan 2025 17:30:37 +0100 Subject: [PATCH 041/114] Update model-setup.md Fixed typo for LM studio --- docs/docs/autocomplete/model-setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/autocomplete/model-setup.md b/docs/docs/autocomplete/model-setup.md index 221c17ddd..fc5233baa 100644 --- a/docs/docs/autocomplete/model-setup.md +++ b/docs/docs/autocomplete/model-setup.md @@ -42,7 +42,7 @@ Have more compute? Use `qwen2.5-coder:7b-base` for potentially higher-quality su :::note -For LM Studio users, navigate to the "My Models" section, find your desired model, and copy the path (e.g., `Qwen/Qwen2.5-Coder-1.5B-Instruct-GGUF/wen2.5-coder-1.5b-instruct-q4_k_m.gguf`). Use this path as the `model` value in your configuration. +For LM Studio users, navigate to the "My Models" section, find your desired model, and copy the path (e.g., `Qwen/Qwen2.5-Coder-1.5B-Instruct-GGUF/qwen2.5-coder-1.5b-instruct-q4_k_m.gguf`). Use this path as the `model` value in your configuration. ::: From 8c6e33ad803ac5009b0ce7d6280ad05ac6dace03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20=C3=96berg?= Date: Wed, 1 Jan 2025 17:31:32 +0100 Subject: [PATCH 042/114] Update autocomplete.md --- docs/docs/customize/model-types/autocomplete.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/customize/model-types/autocomplete.md b/docs/docs/customize/model-types/autocomplete.md index d85920605..7f5abc8e2 100644 --- a/docs/docs/customize/model-types/autocomplete.md +++ b/docs/docs/customize/model-types/autocomplete.md @@ -13,4 +13,4 @@ In Continue, these models are used to display inline [Autocomplete](../../autoco If you have the ability to use any model, we recommend `Codestral` with [Mistral](../model-providers/top-level/mistral.md#autocomplete-model) or [Vertex AI](../model-providers/top-level/vertexai.md#autocomplete-model). -If you want to run a model locally, we recommend `Qwen2.5-Coder 1.5B` with [Ollama](../model-providers/top-level/ollama.md#autocomplete-model). +If you want to run a model locally, we recommend `Qwen2.5-Coder 1.5B-base` with [Ollama](../model-providers/top-level/ollama.md#autocomplete-model). From fb9db1e12883435fad5cc6610312ff3240ef6803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20=C3=96berg?= Date: Wed, 1 Jan 2025 17:32:25 +0100 Subject: [PATCH 043/114] Update ollama.md --- docs/docs/customize/model-providers/top-level/ollama.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/docs/customize/model-providers/top-level/ollama.md b/docs/docs/customize/model-providers/top-level/ollama.md index ed96ac385..c307a9344 100644 --- a/docs/docs/customize/model-providers/top-level/ollama.md +++ b/docs/docs/customize/model-providers/top-level/ollama.md @@ -23,14 +23,14 @@ We recommend configuring **Llama3.1 8B** as your chat model. ## Autocomplete model -We recommend configuring **Qwen2.5-Coder 1.5B** as your autocomplete model. +We recommend configuring **Qwen2.5-Coder 1.5B-base** as your autocomplete model. ```json title="config.json" { "tabAutocompleteModel": { - "title": "Qwen2.5-Coder 1.5B", + "title": "Qwen2.5-Coder 1.5B-base", "provider": "ollama", - "model": "qwen2.5-coder:1.5b" + "model": "qwen2.5-coder:1.5b-base" } } ``` From 7bfea237ec023fee6ff20293266d32d5cf130731 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 1 Jan 2025 20:13:35 +0100 Subject: [PATCH 044/114] switch to strict null checks in gui --- gui/.eslintrc.json | 23 +- gui/package-lock.json | 355 ------------------ gui/package.json | 1 - gui/src/components/CheckDiv.tsx | 1 - .../InputToolbar/ToggleToolsButton.tsx | 4 +- gui/tsconfig.json | 3 +- gui/tsconfig.strictNullChecks.json | 31 -- 7 files changed, 10 insertions(+), 408 deletions(-) delete mode 100644 gui/tsconfig.strictNullChecks.json diff --git a/gui/.eslintrc.json b/gui/.eslintrc.json index 4962e7753..b20127eb0 100644 --- a/gui/.eslintrc.json +++ b/gui/.eslintrc.json @@ -1,23 +1,16 @@ { "root": true, "parser": "@typescript-eslint/parser", - "plugins": [ - "@typescript-eslint", - "strict-null-checks", - "eslint-plugin-react" - ], + "plugins": ["@typescript-eslint", "eslint-plugin-react"], "parserOptions": { - "project": "gui/tsconfig.strictNullChecks.json" - }, - // "extends": [ - // "eslint:recommended", - // "plugin:@typescript-eslint/recommended", - // "plugin:@typescript-eslint/recommended-requiring-type-checking" - // "plugin:react/recommended" - // ], - "rules": { - "strict-null-checks/all": "warn" + "project": "gui/tsconfig.json" }, + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking" + // "plugin:react/recommended" + ], "overrides": [ { "files": ["src/**/*.{js,ts,jsx,tsx}"] diff --git a/gui/package-lock.json b/gui/package-lock.json index 9ff6fc72d..23085939e 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -85,7 +85,6 @@ "autoprefixer": "^10.4.13", "eslint": "^8", "eslint-plugin-react": "^7.37.2", - "eslint-plugin-strict-null-checks": "^0.1.3", "jsdom": "^25.0.1", "postcss": "^8.4.21", "tailwindcss": "^3.2.7", @@ -2936,12 +2935,6 @@ "integrity": "sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA==", "dev": true }, - "node_modules/@types/json-schema": { - "version": "7.0.15", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", - "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", - "dev": true - }, "node_modules/@types/katex": { "version": "0.16.7", "resolved": "https://registry.npmjs.org/@types/katex/-/katex-0.16.7.tgz", @@ -3062,12 +3055,6 @@ "@types/node": "*" } }, - "node_modules/@types/semver": { - "version": "7.5.8", - "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.8.tgz", - "integrity": "sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==", - "dev": true - }, "node_modules/@types/styled-components": { "version": "5.1.34", "resolved": "https://registry.npmjs.org/@types/styled-components/-/styled-components-5.1.34.tgz", @@ -3602,15 +3589,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/array-union": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", - "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/array.prototype.findlast": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/array.prototype.findlast/-/array.prototype.findlast-1.2.5.tgz", @@ -4671,18 +4649,6 @@ "integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==", "dev": true }, - "node_modules/dir-glob": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", - "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", - "dev": true, - "dependencies": { - "path-type": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/direction": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/direction/-/direction-1.0.4.tgz", @@ -5151,262 +5117,6 @@ "semver": "bin/semver.js" } }, - "node_modules/eslint-plugin-strict-null-checks": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/eslint-plugin-strict-null-checks/-/eslint-plugin-strict-null-checks-0.1.3.tgz", - "integrity": "sha512-c0bByePJytPXxZF9jBH17UQO41aCK08zThIXcAO3EnkdLhqUqIr+LVMfPstrN/9dLNzh4YKIbkbRPhRXRnNfNQ==", - "dev": true, - "dependencies": { - "@typescript-eslint/eslint-plugin": "^5.13.0", - "@typescript-eslint/experimental-utils": "^5.13.0", - "@typescript-eslint/parser": "^5.13.0", - "requireindex": "^1.2.0" - }, - "peerDependencies": { - "typescript": ">=3.9.4" - } - }, - "node_modules/eslint-plugin-strict-null-checks/node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.62.0.tgz", - "integrity": "sha512-TiZzBSJja/LbhNPvk6yc0JrX9XqhQ0hdh6M2svYfsHGejaKFIAGd9MQ+ERIMzLGlN/kZoYIgdxFV0PuljTKXag==", - "dev": true, - "dependencies": { - "@eslint-community/regexpp": "^4.4.0", - "@typescript-eslint/scope-manager": "5.62.0", - "@typescript-eslint/type-utils": "5.62.0", - "@typescript-eslint/utils": "5.62.0", - "debug": "^4.3.4", - "graphemer": "^1.4.0", - "ignore": "^5.2.0", - "natural-compare-lite": "^1.4.0", - "semver": "^7.3.7", - "tsutils": "^3.21.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "@typescript-eslint/parser": "^5.0.0", - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/eslint-plugin-strict-null-checks/node_modules/@typescript-eslint/experimental-utils": { - "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-5.62.0.tgz", - "integrity": "sha512-RTXpeB3eMkpoclG3ZHft6vG/Z30azNHuqY6wKPBHlVMZFuEvrtlEDe8gMqDb+SO+9hjC/pLekeSCryf9vMZlCw==", - "dev": true, - "dependencies": { - "@typescript-eslint/utils": "5.62.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" - } - }, - "node_modules/eslint-plugin-strict-null-checks/node_modules/@typescript-eslint/parser": { - "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.62.0.tgz", - "integrity": "sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA==", - "dev": true, - "dependencies": { - "@typescript-eslint/scope-manager": "5.62.0", - "@typescript-eslint/types": "5.62.0", - "@typescript-eslint/typescript-estree": "5.62.0", - "debug": "^4.3.4" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/eslint-plugin-strict-null-checks/node_modules/@typescript-eslint/scope-manager": { - "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.62.0.tgz", - "integrity": "sha512-VXuvVvZeQCQb5Zgf4HAxc04q5j+WrNAtNh9OwCsCgpKqESMTu3tF/jhZ3xG6T4NZwWl65Bg8KuS2uEvhSfLl0w==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "5.62.0", - "@typescript-eslint/visitor-keys": "5.62.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/eslint-plugin-strict-null-checks/node_modules/@typescript-eslint/type-utils": { - "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.62.0.tgz", - "integrity": "sha512-xsSQreu+VnfbqQpW5vnCJdq1Z3Q0U31qiWmRhr98ONQmcp/yhiPJFPq8MXiJVLiksmOKSjIldZzkebzHuCGzew==", - "dev": true, - "dependencies": { - "@typescript-eslint/typescript-estree": "5.62.0", - "@typescript-eslint/utils": "5.62.0", - "debug": "^4.3.4", - "tsutils": "^3.21.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "*" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/eslint-plugin-strict-null-checks/node_modules/@typescript-eslint/types": { - "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.62.0.tgz", - "integrity": "sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==", - "dev": true, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/eslint-plugin-strict-null-checks/node_modules/@typescript-eslint/typescript-estree": { - "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.62.0.tgz", - "integrity": "sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "5.62.0", - "@typescript-eslint/visitor-keys": "5.62.0", - "debug": "^4.3.4", - "globby": "^11.1.0", - "is-glob": "^4.0.3", - "semver": "^7.3.7", - "tsutils": "^3.21.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/eslint-plugin-strict-null-checks/node_modules/@typescript-eslint/utils": { - "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.62.0.tgz", - "integrity": "sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==", - "dev": true, - "dependencies": { - "@eslint-community/eslint-utils": "^4.2.0", - "@types/json-schema": "^7.0.9", - "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.62.0", - "@typescript-eslint/types": "5.62.0", - "@typescript-eslint/typescript-estree": "5.62.0", - "eslint-scope": "^5.1.1", - "semver": "^7.3.7" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" - } - }, - "node_modules/eslint-plugin-strict-null-checks/node_modules/@typescript-eslint/visitor-keys": { - "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.62.0.tgz", - "integrity": "sha512-07ny+LHRzQXepkGg6w0mFY41fVUNBrL2Roj/++7V1txKugfjm/Ci/qSND03r2RhlJhJYMcTn9AhhSSqQp0Ysyw==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "5.62.0", - "eslint-visitor-keys": "^3.3.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/eslint-plugin-strict-null-checks/node_modules/eslint-scope": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", - "dev": true, - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/eslint-plugin-strict-null-checks/node_modules/eslint-scope/node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/eslint-plugin-strict-null-checks/node_modules/eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", - "dev": true, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, "node_modules/eslint-scope": { "version": "7.2.2", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", @@ -6303,26 +6013,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/globby": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", - "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", - "dev": true, - "dependencies": { - "array-union": "^2.1.0", - "dir-glob": "^3.0.1", - "fast-glob": "^3.2.9", - "ignore": "^5.2.0", - "merge2": "^1.4.1", - "slash": "^3.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/gopd": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", @@ -8916,12 +8606,6 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, - "node_modules/natural-compare-lite": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", - "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", - "dev": true - }, "node_modules/node-releases": { "version": "2.0.18", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.18.tgz", @@ -9331,15 +9015,6 @@ "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", "dev": true }, - "node_modules/path-type": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", - "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/pathe": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz", @@ -10875,15 +10550,6 @@ "node": ">=0.10.0" } }, - "node_modules/requireindex": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/requireindex/-/requireindex-1.2.0.tgz", - "integrity": "sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww==", - "dev": true, - "engines": { - "node": ">=0.10.5" - } - }, "node_modules/reselect": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/reselect/-/reselect-5.1.1.tgz", @@ -12094,27 +11760,6 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==" }, - "node_modules/tsutils": { - "version": "3.21.0", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", - "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", - "dev": true, - "dependencies": { - "tslib": "^1.8.1" - }, - "engines": { - "node": ">= 6" - }, - "peerDependencies": { - "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" - } - }, - "node_modules/tsutils/node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true - }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", diff --git a/gui/package.json b/gui/package.json index d0150d999..23bde3349 100644 --- a/gui/package.json +++ b/gui/package.json @@ -93,7 +93,6 @@ "autoprefixer": "^10.4.13", "eslint": "^8", "eslint-plugin-react": "^7.37.2", - "eslint-plugin-strict-null-checks": "^0.1.3", "jsdom": "^25.0.1", "postcss": "^8.4.21", "tailwindcss": "^3.2.7", diff --git a/gui/src/components/CheckDiv.tsx b/gui/src/components/CheckDiv.tsx index eaea0dc1a..bb4bdaa00 100644 --- a/gui/src/components/CheckDiv.tsx +++ b/gui/src/components/CheckDiv.tsx @@ -1,4 +1,3 @@ -import { useState } from "react"; import styled from "styled-components"; import { defaultBorderRadius, vscBackground, vscForeground } from "."; import { CheckIcon } from "@heroicons/react/24/outline"; diff --git a/gui/src/components/mainInput/InputToolbar/ToggleToolsButton.tsx b/gui/src/components/mainInput/InputToolbar/ToggleToolsButton.tsx index 9dae27363..edb82fd3d 100644 --- a/gui/src/components/mainInput/InputToolbar/ToggleToolsButton.tsx +++ b/gui/src/components/mainInput/InputToolbar/ToggleToolsButton.tsx @@ -6,10 +6,8 @@ import { import { WrenchScrewdriverIcon as WrenchScrewdriverIconSolid } from "@heroicons/react/24/solid"; import { useEffect, useRef, useState } from "react"; import { useDispatch } from "react-redux"; -import styled from "styled-components"; -import { defaultBorderRadius, lightGray, vscForeground } from "../.."; +import { lightGray, vscForeground } from "../.."; import { toggleUseTools } from "../../../redux/slices/uiSlice"; -import { getFontSize } from "../../../util"; import InfoHover from "../../InfoHover"; import HoverItem from "./HoverItem"; import ToolDropdownItem from "./ToolDropdownItem"; diff --git a/gui/tsconfig.json b/gui/tsconfig.json index 64e59bd41..d41a6b9c3 100644 --- a/gui/tsconfig.json +++ b/gui/tsconfig.json @@ -7,7 +7,7 @@ "skipLibCheck": true, "esModuleInterop": false, "allowSyntheticDefaultImports": true, - "strict": false, + "strict": true, "forceConsistentCasingInFileNames": true, "module": "ESNext", "moduleResolution": "Node", @@ -18,7 +18,6 @@ "noEmitOnError": false, "types": ["vitest/globals"] // Disabled for now since it's causing too many errors - // "strictNullChecks": true }, "include": ["src", "../src/util/messenger.ts"], "references": [{ "path": "./tsconfig.node.json" }] diff --git a/gui/tsconfig.strictNullChecks.json b/gui/tsconfig.strictNullChecks.json deleted file mode 100644 index 2825e46eb..000000000 --- a/gui/tsconfig.strictNullChecks.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "compilerOptions": { - "strictNullChecks": true, - - - "target": "ESNext", - "useDefineForClassFields": true, - "lib": ["DOM", "DOM.Iterable", "ESNext"], - "allowJs": false, - "skipLibCheck": true, - "esModuleInterop": false, - "allowSyntheticDefaultImports": true, - "strict": false, - "forceConsistentCasingInFileNames": true, - "module": "ESNext", - "moduleResolution": "Node", - "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": true, - "jsx": "react-jsx", - "noEmitOnError": false, - "types": ["vitest/globals"] - }, - "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.js", "src/**/*.jsx"], - "exclude": ["dist", "node_modules"], - - - - - -} From fa18259a34a3b3940fbbe1a019136b94aa8c260f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20=C3=96berg?= Date: Wed, 1 Jan 2025 21:08:48 +0100 Subject: [PATCH 045/114] Update README.md --- core/autocomplete/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/autocomplete/README.md b/core/autocomplete/README.md index 1136b54ab..ab6e9adfb 100644 --- a/core/autocomplete/README.md +++ b/core/autocomplete/README.md @@ -7,7 +7,7 @@ Continue now provides support for tab autocomplete in [VS Code](https://marketpl We recommend setting up tab-autocomplete with a local Ollama instance. To do this, first download the latest version of Ollama from [here](https://ollama.ai). Then, run the following command to download our recommended model: ```bash -ollama run qwen2.5-coder:1.5b +ollama run qwen2.5-coder:1.5b-base ``` Once it has been downloaded, you should begin to see completions in VS Code. @@ -101,7 +101,7 @@ This object allows you to customize the behavior of tab-autocomplete. The availa "tabAutocompleteModel": { "title": "Tab Autocomplete Model", "provider": "ollama", - "model": "qwen2.5-coder:1.5b", + "model": "qwen2.5-coder:1.5b-base", "apiBase": "https://" }, "tabAutocompleteOptions": { @@ -123,9 +123,9 @@ Follow these steps to ensure that everything is set up correctly: 1. Make sure you have the "Enable Tab Autocomplete" setting checked (in VS Code, you can toggle by clicking the "Continue" button in the status bar). 2. Make sure you have downloaded Ollama. -3. Run `ollama run qwen2.5-coder:1.5b` to verify that the model is downloaded. +3. Run `ollama run qwen2.5-coder:1.5b-base` to verify that the model is downloaded. 4. Make sure that any other completion providers are disabled (e.g. Copilot), as they may interfere. -5. Make sure that you aren't also using another Ollama model for chat. This will cause Ollama to constantly load and unload the models from memory, resulting in slow responses (or none at all) for both. +5. If you are using another Ollama model for chat and your resources are limited, this will cause Ollama to constantly load and unload the models from memory, resulting in slow responses (or none at all) for both. A resolution for this could be using the same model for chat and autocomplete. 6. Check the output of the logs to find any potential errors (cmd/ctrl+shift+p -> "Toggle Developer Tools" -> "Console" tab in VS Code, ~/.continue/logs/core.log in JetBrains). 7. If you are still having issues, please let us know in our [Discord](https://discord.gg/vapESyrFmJ) and we'll help as soon as possible. From 96200c094f89141ac33e10e9daa0a78ff2ef30e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20=C3=96berg?= Date: Wed, 1 Jan 2025 21:22:10 +0100 Subject: [PATCH 046/114] removed base from title --- docs/docs/autocomplete/model-setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/autocomplete/model-setup.md b/docs/docs/autocomplete/model-setup.md index fc5233baa..2312123a0 100644 --- a/docs/docs/autocomplete/model-setup.md +++ b/docs/docs/autocomplete/model-setup.md @@ -31,7 +31,7 @@ For those preferring local execution or self-hosting,`Qwen2.5-Coder 1.5B` offers ```json title="config.json"" { "tabAutocompleteModel": { - "title": "Qwen2.5-Coder 1.5B Base", + "title": "Qwen2.5-Coder 1.5B", "model": "qwen2.5-coder:1.5b-base", "provider": "ollama" } From 2966c9c57d7b4317504f1e8952d2367fc3d221a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20=C3=96berg?= Date: Wed, 1 Jan 2025 21:24:21 +0100 Subject: [PATCH 047/114] removed base since its a name and not specific model --- docs/docs/customize/model-types/autocomplete.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/customize/model-types/autocomplete.md b/docs/docs/customize/model-types/autocomplete.md index 7f5abc8e2..d85920605 100644 --- a/docs/docs/customize/model-types/autocomplete.md +++ b/docs/docs/customize/model-types/autocomplete.md @@ -13,4 +13,4 @@ In Continue, these models are used to display inline [Autocomplete](../../autoco If you have the ability to use any model, we recommend `Codestral` with [Mistral](../model-providers/top-level/mistral.md#autocomplete-model) or [Vertex AI](../model-providers/top-level/vertexai.md#autocomplete-model). -If you want to run a model locally, we recommend `Qwen2.5-Coder 1.5B-base` with [Ollama](../model-providers/top-level/ollama.md#autocomplete-model). +If you want to run a model locally, we recommend `Qwen2.5-Coder 1.5B` with [Ollama](../model-providers/top-level/ollama.md#autocomplete-model). From 5516ba86ff0cbed6b0777380c273805094c9ac20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20=C3=96berg?= Date: Wed, 1 Jan 2025 21:25:26 +0100 Subject: [PATCH 048/114] removed base from title --- docs/docs/customize/model-providers/top-level/ollama.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/customize/model-providers/top-level/ollama.md b/docs/docs/customize/model-providers/top-level/ollama.md index c307a9344..e1f3e53e8 100644 --- a/docs/docs/customize/model-providers/top-level/ollama.md +++ b/docs/docs/customize/model-providers/top-level/ollama.md @@ -23,12 +23,12 @@ We recommend configuring **Llama3.1 8B** as your chat model. ## Autocomplete model -We recommend configuring **Qwen2.5-Coder 1.5B-base** as your autocomplete model. +We recommend configuring **Qwen2.5-Coder 1.5B** as your autocomplete model. ```json title="config.json" { "tabAutocompleteModel": { - "title": "Qwen2.5-Coder 1.5B-base", + "title": "Qwen2.5-Coder 1.5B", "provider": "ollama", "model": "qwen2.5-coder:1.5b-base" } From abf1d89a3966498d7529ae2ca1747ac6bb1f9b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20=C3=96berg?= Date: Wed, 1 Jan 2025 22:24:09 +0100 Subject: [PATCH 049/114] added -base to the qwen-modelse --- docs/docs/customize/deep-dives/autocomplete.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/docs/customize/deep-dives/autocomplete.md b/docs/docs/customize/deep-dives/autocomplete.md index 4aa5f768d..221a6d49f 100644 --- a/docs/docs/customize/deep-dives/autocomplete.md +++ b/docs/docs/customize/deep-dives/autocomplete.md @@ -23,7 +23,7 @@ If you want to have the best autocomplete experience, we recommend using Codestr If you'd like to run your autocomplete model locally, we recommend using Ollama. To do this, first download the latest version of Ollama from [here](https://ollama.ai). Then, run the following command to download our recommended model: ```bash -ollama run qwen2.5-coder:1.5b +ollama run qwen2.5-coder:1.5b-base ``` Once it has been downloaded, you should begin to see completions in VS Code. @@ -37,7 +37,7 @@ All of the configuration options available for chat models are available to use "tabAutocompleteModel": { "title": "Tab Autocomplete Model", "provider": "ollama", - "model": "qwen2.5-coder:1.5b", + "model": "qwen2.5-coder:1.5b-base", "apiBase": "https://" }, ... @@ -76,7 +76,7 @@ This object allows you to customize the behavior of tab-autocomplete. The availa "tabAutocompleteModel": { "title": "Tab Autocomplete Model", "provider": "ollama", - "model": "qwen2.5-coder:1.5b", + "model": "qwen2.5-coder:1.5b-base", "apiBase": "https://" }, "tabAutocompleteOptions": { @@ -99,7 +99,7 @@ Follow these steps to ensure that everything is set up correctly: 1. Make sure you have the "Enable Tab Autocomplete" setting checked (in VS Code, you can toggle by clicking the "Continue" button in the status bar, and in JetBrains by going to Settings -> Tools -> Continue). 2. Make sure you have downloaded Ollama. -3. Run `ollama run qwen2.5-coder:1.5b` to verify that the model is downloaded. +3. Run `ollama run qwen2.5-coder:1.5b-base` to verify that the model is downloaded. 4. Make sure that any other completion providers are disabled (e.g. Copilot), as they may interfere. 5. Check the output of the logs to find any potential errors: cmd/ctrl + shift + P -> "Toggle Developer Tools" -> "Console" tab in VS Code, ~/.continue/logs/core.log in JetBrains. 6. Check VS Code settings to make sure that `"editor.inlineSuggest.enabled"` is set to `true` (use cmd/ctrl + , then search for this and check the box) From abfffd831abe960b4881472b2c7c3ca94f187a81 Mon Sep 17 00:00:00 2001 From: "Johnny.H" Date: Thu, 2 Jan 2025 15:53:12 +0800 Subject: [PATCH 050/114] fix `renderInlineAs` not working in `HttpContextProvider` --- core/context/providers/HttpContextProvider.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/context/providers/HttpContextProvider.ts b/core/context/providers/HttpContextProvider.ts index 05a50e15d..7b7228eee 100644 --- a/core/context/providers/HttpContextProvider.ts +++ b/core/context/providers/HttpContextProvider.ts @@ -22,6 +22,9 @@ class HttpContextProvider extends BaseContextProvider { this.options.description || "Retrieve a context item from a custom server", type: "normal", + renderInlineAs: + this.options.renderInlineAs || + HttpContextProvider.description.renderInlineAs, }; } From 0001e275e14b26aaabadbeb30ac4fdeb843d6122 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 2 Jan 2025 15:29:12 -0500 Subject: [PATCH 051/114] update reference --- docs/docs/reference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/reference.md b/docs/docs/reference.md index 527820556..b61357649 100644 --- a/docs/docs/reference.md +++ b/docs/docs/reference.md @@ -88,7 +88,7 @@ Specifies options for tab autocompletion behavior. - `debounceDelay`: Delay (in ms) before triggering autocomplete. - `maxSuffixPercentage`: Maximum percentage of prompt for suffix. - `prefixPercentage`: Percentage of input for prefix. -- `template`: Template string for autocomplete, using Mustache templating. +- `template`: Template string for autocomplete, using Mustache templating. You can use the `{{{ prefix }}}`, `{{{ suffix }}}`, `{{{ filename }}}`, `{{{ reponame }}}`, and `{{{ language }}}` variables. - `multilineCompletions`: Controls multiline completions (`"always"`, `"never"`, or `"auto"`). - `useCache`: If `true`, caches completions. - `onlyMyCode`: If `true`, only includes code within the repository. From 9cc844fb178a77667a4cd49b0d671f9631af67af Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 2 Jan 2025 15:33:08 -0500 Subject: [PATCH 052/114] update config_schema.json --- extensions/vscode/config_schema.json | 108 +++++++++++++-------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index f2c98642f..c9df4e976 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -2805,10 +2805,7 @@ "type": "object", "properties": { "model": { - "enum": [ - "cohere.rerank-v3-5:0", - "amazon.rerank-v1:0" - ] + "enum": ["cohere.rerank-v3-5:0", "amazon.rerank-v1:0"] } }, "required": ["model"] @@ -3132,62 +3129,65 @@ "description": "Allow tool use. Currently only supported with Claude 3.5 Sonnet", "default": true }, - "modelContextProtocolServer": { - "type": "object", - "properties": { - "transport": { - "oneOf": [ - { - "type": "object", - "properties": { - "type": { - "type": "string", - "enum": ["stdio"] - }, - "command": { - "type": "string" - }, - "args": { - "type": "array", - "items": { + "modelContextProtocolServers": { + "type": "array", + "items": { + "type": "object", + "properties": { + "transport": { + "oneOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": ["stdio"] + }, + "command": { "type": "string" + }, + "args": { + "type": "array", + "items": { + "type": "string" + } } - } - }, - "required": ["type", "command", "args"] - }, - { - "type": "object", - "properties": { - "type": { - "type": "string", - "enum": ["websocket"] }, - "url": { - "type": "string", - "format": "uri" - } + "required": ["type", "command", "args"] }, - "required": ["type", "url"] - }, - { - "type": "object", - "properties": { - "type": { - "type": "string", - "enum": ["sse"] + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": ["websocket"] + }, + "url": { + "type": "string", + "format": "uri" + } }, - "url": { - "type": "string", - "format": "uri" - } + "required": ["type", "url"] }, - "required": ["type", "url"] - } - ] - } - }, - "required": ["transport"] + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": ["sse"] + }, + "url": { + "type": "string", + "format": "uri" + } + }, + "required": ["type", "url"] + } + ] + } + }, + "required": ["transport"] + } } } } From e66b79d7bd0d0408dbb5689dd45193b3b818ce5f Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 2 Jan 2025 22:42:01 +0100 Subject: [PATCH 053/114] gui strict null checks p1 --- gui/.eslintrc.json | 6 +++--- gui/package-lock.json | 17 +++++++++++++++ gui/package.json | 2 ++ .../CodeToEditCard/AddFileCombobox.tsx | 8 +++---- .../CodeToEditCard/CodeToEditCard.tsx | 14 ++++++------- .../CodeToEditCard/CodeToEditListItem.tsx | 8 +++---- .../components/BestExperienceConfigForm.tsx | 2 +- gui/src/components/mainInput/MentionList.tsx | 20 +++++++++++------- .../components/modelSelection/ModelSelect.tsx | 10 ++++----- gui/src/context/SubmenuContextProviders.tsx | 4 +--- gui/src/context/VscTheme.tsx | 4 ++-- gui/src/forms/AddModelForm.tsx | 19 +++++++++++------ gui/src/hooks/useWebviewListener.ts | 4 ++-- gui/src/pages/gui/Chat.tsx | 3 +-- gui/src/pages/gui/StreamError.tsx | 21 +++++++++++-------- gui/src/pages/gui/ToolCallDiv/ThreadDiv.tsx | 3 +-- gui/src/pages/gui/ToolCallDiv/index.tsx | 2 -- gui/src/redux/selectors/selectLastToolCall.ts | 3 +-- gui/src/redux/slices/sessionSlice.ts | 11 +++++++--- gui/src/redux/thunks/streamNormalInput.ts | 2 +- .../thunks/streamResponseAfterToolCall.ts | 5 +++++ 21 files changed, 103 insertions(+), 65 deletions(-) diff --git a/gui/.eslintrc.json b/gui/.eslintrc.json index b20127eb0..346c650fe 100644 --- a/gui/.eslintrc.json +++ b/gui/.eslintrc.json @@ -6,9 +6,9 @@ "project": "gui/tsconfig.json" }, "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended", - "plugin:@typescript-eslint/recommended-requiring-type-checking" + // "eslint:recommended", + // "plugin:@typescript-eslint/recommended", + // "plugin:@typescript-eslint/recommended-requiring-type-checking" // "plugin:react/recommended" ], "overrides": [ diff --git a/gui/package-lock.json b/gui/package-lock.json index 23085939e..4c735e3ef 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -24,6 +24,7 @@ "@tiptap/react": "^2.1.13", "@tiptap/starter-kit": "^2.1.13", "@tiptap/suggestion": "^2.1.13", + "@types/uuid": "^10.0.0", "@types/vscode-webview": "^1.57.1", "core": "file:../core", "dompurify": "^3.0.6", @@ -70,6 +71,7 @@ "@testing-library/jest-dom": "^6.5.0", "@testing-library/react": "^16.0.1", "@testing-library/user-event": "^14.5.2", + "@types/dompurify": "^3.2.0", "@types/lodash": "^4.17.6", "@types/mustache": "^4.2.5", "@types/node": "^20.5.6", @@ -2893,6 +2895,16 @@ "@types/ms": "*" } }, + "node_modules/@types/dompurify": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@types/dompurify/-/dompurify-3.2.0.tgz", + "integrity": "sha512-Fgg31wv9QbLDA0SpTOXO3MaxySc4DKGLi8sna4/Utjo4r3ZRPdCt4UQee8BWr+Q5z21yifghREPJGYaEOEIACg==", + "deprecated": "This is a stub types definition. dompurify provides its own type definitions, so you do not need this installed.", + "dev": true, + "dependencies": { + "dompurify": "*" + } + }, "node_modules/@types/estree": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", @@ -3076,6 +3088,11 @@ "resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.6.tgz", "integrity": "sha512-zFDAD+tlpf2r4asuHEj0XH6pY6i0g5NeAHPn+15wk3BV6JA69eERFXC1gyGThDkVa1zCyKr5jox1+2LbV/AMLg==" }, + "node_modules/@types/uuid": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-10.0.0.tgz", + "integrity": "sha512-7gqG38EyHgyP1S+7+xomFtL+ZNHcKv6DwNaCZmJmo1vgMugyF3TCnXVg4t1uk89mLNwnLtnY3TpOpCOyp1/xHQ==" + }, "node_modules/@types/vscode-webview": { "version": "1.57.5", "resolved": "https://registry.npmjs.org/@types/vscode-webview/-/vscode-webview-1.57.5.tgz", diff --git a/gui/package.json b/gui/package.json index 23bde3349..58a4529d8 100644 --- a/gui/package.json +++ b/gui/package.json @@ -32,6 +32,7 @@ "@tiptap/react": "^2.1.13", "@tiptap/starter-kit": "^2.1.13", "@tiptap/suggestion": "^2.1.13", + "@types/uuid": "^10.0.0", "@types/vscode-webview": "^1.57.1", "core": "file:../core", "dompurify": "^3.0.6", @@ -78,6 +79,7 @@ "@testing-library/jest-dom": "^6.5.0", "@testing-library/react": "^16.0.1", "@testing-library/user-event": "^14.5.2", + "@types/dompurify": "^3.2.0", "@types/lodash": "^4.17.6", "@types/mustache": "^4.2.5", "@types/node": "^20.5.6", diff --git a/gui/src/components/CodeToEditCard/AddFileCombobox.tsx b/gui/src/components/CodeToEditCard/AddFileCombobox.tsx index b79365fb1..129c0f082 100644 --- a/gui/src/components/CodeToEditCard/AddFileCombobox.tsx +++ b/gui/src/components/CodeToEditCard/AddFileCombobox.tsx @@ -8,8 +8,8 @@ import FileIcon from "../FileIcon"; import { useAppSelector } from "../../redux/hooks"; export interface AddFileComboboxProps { - onSelect: (filepaths: string[]) => void; - onEscape: () => void; + onSelect: (filepaths: string[]) => void | Promise; + onEscape: () => void | Promise; } export default function AddFileCombobox({ @@ -50,7 +50,7 @@ export default function AddFileCombobox({ value={selectedFiles} onChange={(files) => { setSelectedFiles(files); - onSelect(files.map((file) => file.id)); + void onSelect(files.map((file) => file.id)); buttonRef.current?.click(); }} > @@ -72,7 +72,7 @@ export default function AddFileCombobox({ placeholder="Type to search files..." onKeyDown={(e) => { if (e.key === "Escape" && !open) { - onEscape(); + void onEscape(); } }} /> diff --git a/gui/src/components/CodeToEditCard/CodeToEditCard.tsx b/gui/src/components/CodeToEditCard/CodeToEditCard.tsx index 7bd469c24..99149ba5f 100644 --- a/gui/src/components/CodeToEditCard/CodeToEditCard.tsx +++ b/gui/src/components/CodeToEditCard/CodeToEditCard.tsx @@ -2,7 +2,7 @@ import { useContext, useState } from "react"; import { useDispatch } from "react-redux"; import { IdeMessengerContext } from "../../context/IdeMessenger"; import CodeToEditListItem from "./CodeToEditListItem"; -import type { CodeToEdit, RangeInFileWithContents } from "core"; +import type { CodeToEdit } from "core"; import AddFileButton from "./AddFileButton"; import AddFileCombobox from "./AddFileCombobox"; import { PlusIcon, XMarkIcon } from "@heroicons/react/24/outline"; @@ -25,19 +25,19 @@ export default function CodeToEditCard() { ? "Code to edit (1 item)" : `Code to edit (${codeToEdit.length} items)`; - function onDelete(rif: RangeInFileWithContents) { + function onDelete(rif: CodeToEdit) { dispatch(removeCodeToEdit(rif)); } - function onClickFilename(code: CodeToEdit) { + async function onClickFilename(code: CodeToEdit) { if ("range" in code) { - ideMessenger.ide.showLines( + await ideMessenger.ide.showLines( code.filepath, code.range.start.line, code.range.end.line, ); } else { - ideMessenger.ide.openFile(code.filepath); + await ideMessenger.ide.openFile(code.filepath); } } @@ -93,10 +93,10 @@ export default function CodeToEditCard() { />
{ + onClick={() => { setShowAddFileCombobox(false); }} - className="text-lightgray hover:bg-lightgray hover:text-vsc-foreground mb-2 h-3.5 w-3.5 cursor-pointer rounded-md rounded-sm p-0.5 hover:bg-opacity-20" + className="text-lightgray hover:bg-lightgray hover:text-vsc-foreground mb-2 h-3.5 w-3.5 cursor-pointer rounded-sm p-0.5 hover:bg-opacity-20" />
)} diff --git a/gui/src/components/CodeToEditCard/CodeToEditListItem.tsx b/gui/src/components/CodeToEditCard/CodeToEditListItem.tsx index 46380f084..f915f27d7 100644 --- a/gui/src/components/CodeToEditCard/CodeToEditListItem.tsx +++ b/gui/src/components/CodeToEditCard/CodeToEditListItem.tsx @@ -16,8 +16,8 @@ import { export interface CodeToEditListItemProps { code: CodeToEdit; - onDelete: (codeToEdit: CodeToEdit) => void; - onClickFilename: (codeToEdit: CodeToEdit) => void; + onDelete: (codeToEdit: CodeToEdit) => void | Promise; + onClickFilename: (codeToEdit: CodeToEdit) => void | Promise; } const NoPaddingWrapper = styled.div` @@ -87,7 +87,7 @@ export default function CodeToEditListItem({ className="flex-shrink-0 text-xs hover:underline" onClick={(e) => { e.stopPropagation(); - onClickFilename(code); + void onClickFilename(code); }} > {title} @@ -122,7 +122,7 @@ export default function CodeToEditListItem({ { e.stopPropagation(); - onDelete(code); + void onDelete(code); }} className="text-lightgray hover:bg-lightgray hover:text-vsc-foreground h-3.5 w-3.5 cursor-pointer rounded-sm p-0.5 hover:bg-opacity-20" /> diff --git a/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx b/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx index a76f6b57b..7e81bdf04 100644 --- a/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx +++ b/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx @@ -83,7 +83,7 @@ function BestExperienceConfigForm({
diff --git a/gui/src/components/mainInput/MentionList.tsx b/gui/src/components/mainInput/MentionList.tsx index f0f328a8d..754d436fe 100644 --- a/gui/src/components/mainInput/MentionList.tsx +++ b/gui/src/components/mainInput/MentionList.tsx @@ -66,11 +66,12 @@ const ICONS_FOR_DROPDOWN: { [key: string]: any } = { "/cmd": CommandLineIcon, }; -export function getIconFromDropdownItem(id: string, type: ComboBoxItemType) { - return ( - ICONS_FOR_DROPDOWN[id] ?? - (type === "contextProvider" ? AtSymbolIcon : BoltIcon) - ); +export function getIconFromDropdownItem( + id: string | undefined, + type: ComboBoxItemType, +) { + const typeIcon = type === "contextProvider" ? AtSymbolIcon : BoltIcon; + return id ? (ICONS_FOR_DROPDOWN[id] ?? typeIcon) : typeIcon; } function DropdownIcon(props: { className?: string; item: ComboBoxItem }) { @@ -238,7 +239,7 @@ const MentionList = forwardRef((props: MentionListProps, ref) => { } }, [querySubmenuItem]); - const selectItem = (index) => { + const selectItem = (index: number) => { const item = allItems[index]; if (item.type === "action" && item.action) { @@ -251,7 +252,9 @@ const MentionList = forwardRef((props: MentionListProps, ref) => { item.contextProvider?.type === "submenu" ) { setSubMenuTitle(item.description); - props.enterSubmenu(props.editor, item.id); + if (item.id) { + props.enterSubmenu?.(props.editor, item.id); + } return; } @@ -359,6 +362,9 @@ const MentionList = forwardRef((props: MentionListProps, ref) => { ref={queryInputRef} placeholder={querySubmenuItem.description} onKeyDown={(e) => { + if (!queryInputRef.current) { + return; + } if (e.key === "Enter") { if (e.shiftKey) { queryInputRef.current.innerText += "\n"; diff --git a/gui/src/components/modelSelection/ModelSelect.tsx b/gui/src/components/modelSelection/ModelSelect.tsx index c5edb5d7b..93047be18 100644 --- a/gui/src/components/modelSelection/ModelSelect.tsx +++ b/gui/src/components/modelSelection/ModelSelect.tsx @@ -6,7 +6,7 @@ import { PlusIcon, TrashIcon, } from "@heroicons/react/24/outline"; -import { useContext, useEffect, useRef, useState } from "react"; +import { MouseEvent, useContext, useEffect, useRef, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; import styled from "styled-components"; import { @@ -144,7 +144,7 @@ function ModelOption({ const dispatch = useDispatch(); const [hovered, setHovered] = useState(false); - function onClickDelete(e) { + function onClickDelete(e: MouseEvent) { e.stopPropagation(); e.preventDefault(); @@ -164,7 +164,7 @@ function ModelOption({ ); } - function onClickGear(e) { + function onClickGear(e: MouseEvent) { e.stopPropagation(); e.preventDefault(); @@ -173,7 +173,7 @@ function ModelOption({ }); } - function handleOptionClick(e) { + function handleOptionClick(e: MouseEvent) { if (showMissingApiKeyMsg) { e.preventDefault(); e.stopPropagation(); @@ -287,7 +287,7 @@ function ModelSelect() { setShowAbove(spaceBelow < dropdownHeight && spaceAbove > spaceBelow); } - function onClickAddModel(e) { + function onClickAddModel(e: MouseEvent) { e.stopPropagation(); e.preventDefault(); diff --git a/gui/src/context/SubmenuContextProviders.tsx b/gui/src/context/SubmenuContextProviders.tsx index c8ba17c77..673caec1c 100644 --- a/gui/src/context/SubmenuContextProviders.tsx +++ b/gui/src/context/SubmenuContextProviders.tsx @@ -82,8 +82,6 @@ export const SubmenuContextProvidersProvider = ({ const [isLoading, setIsLoading] = useState(false); const [autoLoadTriggered, setAutoLoadTriggered] = useState(false); - const config = useAppSelector((store) => store.config.config); - const ideMessenger = useContext(IdeMessengerContext); const getOpenFilesItems = useCallback(async () => { @@ -102,7 +100,7 @@ export const SubmenuContextProvidersProvider = ({ })); }, [ideMessenger]); - useWebviewListener("refreshSubmenuItems", async (data) => { + useWebviewListener("refreshSubmenuItems", async () => { if (!isLoading) { setInitialLoadComplete(false); setAutoLoadTriggered((prev) => !prev); // Toggle to trigger effect diff --git a/gui/src/context/VscTheme.tsx b/gui/src/context/VscTheme.tsx index c376ee2b4..2ca1dac59 100644 --- a/gui/src/context/VscTheme.tsx +++ b/gui/src/context/VscTheme.tsx @@ -58,7 +58,7 @@ function constructTheme( ): Record { const rules = tmTheme?.["rules"] || []; - const tokenToForeground = {}; + const tokenToForeground: Record = {}; rules.forEach(({ token, foreground }) => { if (!foreground || !token) { return; @@ -66,7 +66,7 @@ function constructTheme( tokenToForeground[token] = foreground; }); - const theme = {}; + const theme: Record = {}; Object.keys(hljsToTextMate).forEach((className) => { const tokens = hljsToTextMate[className]; for (const scope of tokens) { diff --git a/gui/src/forms/AddModelForm.tsx b/gui/src/forms/AddModelForm.tsx index 8753b4010..572251fd6 100644 --- a/gui/src/forms/AddModelForm.tsx +++ b/gui/src/forms/AddModelForm.tsx @@ -52,7 +52,8 @@ function AddModelForm({ const allProviders = Object.entries(providers) .filter(([key]) => !["freetrial", "openai-aiohttp"].includes(key)) - .map(([, provider]) => provider); + .map(([, provider]) => provider) + .filter((provider) => !!provider); const popularProviders = allProviders .filter((provider) => popularProviderTitles.includes(provider.title)) @@ -187,8 +188,9 @@ function AddModelForm({ setSelectedProvider={setSelectedModel} otherOptions={ Object.entries(providers).find( - ([, provider]) => provider.title === selectedProvider.title, - )?.[1].packages + ([, provider]) => + provider?.title === selectedProvider.title, + )?.[1]?.packages } />
@@ -220,9 +222,14 @@ function AddModelForm({ - ideMessenger.post("openUrl", selectedProviderApiKeyUrl) - } + onClick={() => { + if (selectedProviderApiKeyUrl) { + ideMessenger.post( + "openUrl", + selectedProviderApiKeyUrl, + ); + } + }} > Click here {" "} diff --git a/gui/src/hooks/useWebviewListener.ts b/gui/src/hooks/useWebviewListener.ts index 568084a2d..4bdd9f5dc 100644 --- a/gui/src/hooks/useWebviewListener.ts +++ b/gui/src/hooks/useWebviewListener.ts @@ -13,10 +13,10 @@ export function useWebviewListener( useEffect( () => { - let listener; + let listener: (event: { data: Message }) => Promise; if (!skip) { - listener = async (event: { data: Message }) => { + listener = async (event) => { if (event.data.messageType === messageType) { const result = await handler(event.data.data); ideMessenger.respond(messageType, result, event.data.messageId); diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index de8453445..0c8e5b696 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -407,9 +407,8 @@ export function Chat() { return (
); diff --git a/gui/src/pages/gui/StreamError.tsx b/gui/src/pages/gui/StreamError.tsx index 1694fe410..ca3bc04bc 100644 --- a/gui/src/pages/gui/StreamError.tsx +++ b/gui/src/pages/gui/StreamError.tsx @@ -44,15 +44,18 @@ const StreamErrorDialog = ({ error }: StreamErrorProps) => { let statusCode: undefined | number = undefined; // Attempt to get error message and status code from error - if (error && (error instanceof Error || typeof error === "object")) { - if (error["message"]) { - message = error["message"]; - const status = message?.split(" ")[0]; - if (status) { - const code = Number(status); - if (!Number.isNaN(statusCode)) { - statusCode = code; - } + if ( + error && + (error instanceof Error || typeof error === "object") && + "message" in error && + typeof error["message"] === "string" + ) { + message = error["message"]; + const status = message?.split(" ")[0]; + if (status) { + const code = Number(status); + if (!Number.isNaN(statusCode)) { + statusCode = code; } } } diff --git a/gui/src/pages/gui/ToolCallDiv/ThreadDiv.tsx b/gui/src/pages/gui/ToolCallDiv/ThreadDiv.tsx index e54345c5d..71d61c5a8 100644 --- a/gui/src/pages/gui/ToolCallDiv/ThreadDiv.tsx +++ b/gui/src/pages/gui/ToolCallDiv/ThreadDiv.tsx @@ -8,7 +8,6 @@ interface ThreadDivProps { icon: React.ReactNode; toolCall: ToolCall; toolCallState: ToolCallState; - reactKey: string; } const Container = styled.div` @@ -48,7 +47,7 @@ export function ThreadDiv(props: ThreadDivProps) { } return ( - +
) => { - state.history.at(-1).isGatheringContext = payload; + const curMessage = state.history.at(-1); + if (curMessage) { + curMessage.isGatheringContext = payload; + } }, clearLastEmptyResponse: (state) => { if (state.history.length < 2) { @@ -472,8 +475,10 @@ export const sessionSlice = createSlice({ state, { payload }: PayloadAction<{ filepath: string; content: string }>, ) => { - state.history[state.curCheckpointIndex].checkpoint[payload.filepath] = - payload.content; + const checkpoint = state.history[state.curCheckpointIndex].checkpoint; + if (checkpoint) { + checkpoint[payload.filepath] = payload.content; + } }, updateApplyState: (state, { payload }: PayloadAction) => { const applyState = state.codeBlockApplyStates.states.find( diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index aec7bb38e..6eed3ddb1 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -41,7 +41,7 @@ export const streamNormalInput = createAsyncThunk< (tool) => tool.function.name === toolName, ), ) - .filter(Boolean) + .filter((tool) => !!tool) : undefined, }, ); diff --git a/gui/src/redux/thunks/streamResponseAfterToolCall.ts b/gui/src/redux/thunks/streamResponseAfterToolCall.ts index fd503560e..396ab6075 100644 --- a/gui/src/redux/thunks/streamResponseAfterToolCall.ts +++ b/gui/src/redux/thunks/streamResponseAfterToolCall.ts @@ -30,6 +30,11 @@ export const streamResponseAfterToolCall = createAsyncThunk< const initialHistory = state.session.history; const defaultModel = selectDefaultModel(state); + if (!defaultModel) { + console.error("No default model found"); + return; + } + resetStateForNewMessage(); await new Promise((resolve) => setTimeout(resolve, 0)); From 0cf152ede652d975fd774faa40494020c7514196 Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 2 Jan 2025 17:41:28 -0600 Subject: [PATCH 054/114] feat: create SVG tooltip --- .../vscode/src/activation/InlineTipManager.ts | 427 ++++++++++++++++++ extensions/vscode/src/activation/activate.ts | 3 +- .../vscode/src/activation/inlineTips.ts | 122 ----- .../components/indexing/ChatIndexingPeeks.tsx | 2 +- package-lock.json | 8 + package.json | 3 + 6 files changed, 441 insertions(+), 124 deletions(-) create mode 100644 extensions/vscode/src/activation/InlineTipManager.ts delete mode 100644 extensions/vscode/src/activation/inlineTips.ts diff --git a/extensions/vscode/src/activation/InlineTipManager.ts b/extensions/vscode/src/activation/InlineTipManager.ts new file mode 100644 index 000000000..b335cc9dd --- /dev/null +++ b/extensions/vscode/src/activation/InlineTipManager.ts @@ -0,0 +1,427 @@ +/* eslint-disable @typescript-eslint/naming-convention */ +import { EXTENSION_NAME } from "core/control-plane/env"; +// @ts-ignore +import svgBuilder from "svg-builder"; +import * as vscode from "vscode"; + +import { getTheme } from "../util/getTheme"; +import { getMetaKeyLabel, getMetaKeyName } from "../util/util"; + +const SVG_CONFIG = { + stroke: "#999998", + strokeWidth: 1, + shortcutColor: "#999998", + filter: "drop-shadow(0 2px 2px rgba(0,0,0,0.2))", + radius: 4, + leftMargin: 40, + debounceDelay: 500, + chatLabel: "Add to Chat", + chatShortcut: `${getMetaKeyLabel()}L`, + editLabel: "Edit", + editShortcut: `${getMetaKeyLabel()}I`, + + get fontSize() { + return Math.ceil( + (vscode.workspace.getConfiguration("editor").get("fontSize") ?? + 14) * 0.7, + ); + }, + get fontFamily() { + return ( + vscode.workspace.getConfiguration("editor").get("fontFamily") || + "helvetica" + ); + }, + get paddingY() { + return Math.ceil(this.fontSize * 0.4); + }, + get paddingX() { + return Math.ceil(this.fontSize * 0.8); + }, + get gap() { + return this.fontSize * 2.5; + }, + get tipWidth() { + return ( + this.editShortcutX + + this.getEstimatedTextWidth(this.editShortcut) + + this.paddingX + ); + }, + get tipHeight() { + return this.fontSize + this.paddingY * 2; + }, + get textY() { + return this.tipHeight / 2 + this.fontSize * 0.35; + }, + get chatLabelX() { + return this.paddingX; + }, + get chatShortcutX() { + return this.chatLabelX + this.getEstimatedTextWidth(this.chatLabel) + 4; + }, + get editLabelX() { + return this.chatShortcutX + this.gap; + }, + get editShortcutX() { + return this.editLabelX + this.getEstimatedTextWidth(this.editLabel) + 4; + }, + getEstimatedTextWidth(text: string): number { + return text.length * this.fontSize * 0.6; + }, +} as const; + +export class InlineTipManager { + private static instance: InlineTipManager; + + private readonly excludedURIPrefixes = ["output:", "vscode://inline-chat"]; + private readonly hideCommand = "continue.hideInlineTip"; + private svgTooltip: vscode.Uri | undefined = undefined; + + private debounceTimer: NodeJS.Timeout | undefined; + private lastActiveEditor?: vscode.TextEditor; + private theme = getTheme(); + private svgTooltipDecoration = this.createSvgTooltipDecoration(); + private emptyFileTooltipDecoration = this.createEmptyFileTooltipDecoration(); + + public static getInstance(): InlineTipManager { + if (!InlineTipManager.instance) { + InlineTipManager.instance = new InlineTipManager(); + } + return InlineTipManager.instance; + } + + private constructor() { + this.createSvgTooltip(); + this.setupSvgTipListeners(); + } + + public setupInlineTips(context: vscode.ExtensionContext) { + context.subscriptions.push( + vscode.window.onDidChangeTextEditorSelection((e) => { + this.handleSelectionChange(e); + }), + ); + + this.setupEmptyFileTips(context); + + context.subscriptions.push(this); + } + + public handleSelectionChange(e: vscode.TextEditorSelectionChangeEvent) { + const selection = e.selections[0]; + const editor = e.textEditor; + + if (selection.isEmpty || !this.shouldRenderTip(editor.document.uri)) { + editor.setDecorations(this.svgTooltipDecoration, []); + return; + } + + this.debouncedSelectionChange(editor, selection); + } + + public dispose() { + this.svgTooltipDecoration.dispose(); + this.emptyFileTooltipDecoration.dispose(); + + if (this.debounceTimer) { + clearTimeout(this.debounceTimer); + } + } + + private debouncedSelectionChange( + editor: vscode.TextEditor, + selection: vscode.Selection, + ) { + if (this.debounceTimer) { + clearTimeout(this.debounceTimer); + } + + this.debounceTimer = setTimeout(() => { + // Clear decoration from previous editor + if (this.lastActiveEditor && this.lastActiveEditor !== editor) { + this.lastActiveEditor.setDecorations(this.svgTooltipDecoration, []); + } + + this.lastActiveEditor = editor; + + this.updateTooltipPosition(editor, selection); + }, SVG_CONFIG.debounceDelay); + } + + private setupSvgTipListeners() { + vscode.workspace.onDidChangeConfiguration((e) => { + if (e.affectsConfiguration("workbench.colorTheme")) { + this.theme = getTheme(); + this.createSvgTooltip(); + } + }); + + vscode.workspace.onDidChangeConfiguration((e) => { + if (e.affectsConfiguration("editor.fontSize")) { + this.createSvgTooltip(); + } + }); + } + + private shouldRenderTip(uri: vscode.Uri): boolean { + const isAllowedUri = + !this.excludedURIPrefixes.some((prefix) => + uri.toString().startsWith(prefix), + ) && uri.scheme !== "comment"; + + const isEnabled = + !!vscode.workspace + .getConfiguration(EXTENSION_NAME) + .get("showInlineTip") === true; + + return isAllowedUri && isEnabled; + } + + private setupEmptyFileTips(context: vscode.ExtensionContext) { + context.subscriptions.push( + vscode.window.onDidChangeActiveTextEditor((editor) => { + if ( + editor?.document.getText() === "" && + this.shouldRenderTip(editor.document.uri) + ) { + editor.setDecorations(this.emptyFileTooltipDecoration, [ + { + range: new vscode.Range( + new vscode.Position(0, Number.MAX_VALUE), + new vscode.Position(0, Number.MAX_VALUE), + ), + }, + ]); + } + }), + ); + + context.subscriptions.push( + vscode.workspace.onDidChangeTextDocument((e) => { + if ( + e.document.getText() === "" && + this.shouldRenderTip(e.document.uri) + ) { + vscode.window.visibleTextEditors.forEach((editor) => { + editor.setDecorations(this.emptyFileTooltipDecoration, [ + { + range: new vscode.Range( + new vscode.Position(0, Number.MAX_VALUE), + new vscode.Position(0, Number.MAX_VALUE), + ), + }, + ]); + }); + } else { + vscode.window.visibleTextEditors.forEach((editor) => { + editor.setDecorations(this.emptyFileTooltipDecoration, []); + }); + } + }), + ); + } + + private createEmptyFileTooltipDecoration() { + return vscode.window.createTextEditorDecorationType({ + after: { + contentText: `Use ${getMetaKeyName()} + I to generate code`, + color: "#888", + margin: "2em 0 0 0", + fontStyle: "italic", + }, + }); + } + + private createSvgTooltipDecoration() { + return vscode.window.createTextEditorDecorationType({ + after: { + contentIconPath: this.svgTooltip, + margin: `-2.5px 0 0 ${SVG_CONFIG.leftMargin}px`, + width: `${SVG_CONFIG.tipWidth}px`, + }, + }); + } + + private createSvgTooltip() { + const baseTextConfig = { + y: SVG_CONFIG.textY, + "font-family": SVG_CONFIG.fontFamily, + "font-size": SVG_CONFIG.fontSize, + }; + + if (!this.theme) { + return; + } + + try { + const svgContent = svgBuilder + .width(SVG_CONFIG.tipWidth) + .height(SVG_CONFIG.tipHeight) + // Main rectangle + .rect({ + x: 0, + y: 0, + width: SVG_CONFIG.tipWidth, + height: SVG_CONFIG.tipHeight, + rx: SVG_CONFIG.radius, + ry: SVG_CONFIG.radius, + fill: this.theme.colors["editor.background"], + stroke: SVG_CONFIG.stroke, + "stroke-width": SVG_CONFIG.strokeWidth, + filter: SVG_CONFIG.filter, + }) + // Chat + .text( + { + ...baseTextConfig, + x: SVG_CONFIG.chatLabelX, + fill: this.theme.colors["editor.foreground"], + }, + SVG_CONFIG.chatLabel, + ) + .text( + { + ...baseTextConfig, + x: SVG_CONFIG.chatShortcutX, + fill: SVG_CONFIG.shortcutColor, + }, + SVG_CONFIG.chatShortcut, + ) + // Edit + .text( + { + ...baseTextConfig, + x: SVG_CONFIG.editLabelX, + fill: this.theme.colors["editor.foreground"], + }, + SVG_CONFIG.editLabel, + ) + .text( + { + ...baseTextConfig, + x: SVG_CONFIG.editShortcutX, + fill: SVG_CONFIG.shortcutColor, + }, + SVG_CONFIG.editShortcut, + ) + .render(); + + const dataUri = `data:image/svg+xml;base64,${Buffer.from(svgContent).toString("base64")}`; + + this.svgTooltip = vscode.Uri.parse(dataUri); + this.svgTooltipDecoration.dispose(); + this.svgTooltipDecoration = this.createSvgTooltipDecoration(); + } catch (error) { + console.error("Error creating SVG for inline tip:", error); + } + } + + private buildHideTooltipHoverMsg() { + const hoverMarkdown = new vscode.MarkdownString( + `[Disable](command:${this.hideCommand})`, + ); + + hoverMarkdown.isTrusted = true; + hoverMarkdown.supportHtml = true; + return hoverMarkdown; + } + + /** + * Calculates tooltip position using these rules: + * 1. For single-line selection: Place after the line's content + * 2. For multi-line selection: Place after the longer line between: + * - The first non-empty selected line + * - The line above the selection + * Returns null if selection is empty or contains only empty lines + */ + private calculateTooltipPosition( + editor: vscode.TextEditor, + selection: vscode.Selection, + ): vscode.Position | null { + const document = editor.document; + + // Get selection info + const startLine = selection.start.line; + const endLine = selection.end.line; + const isFullLineSelection = + selection.start.character === 0 && + (selection.end.line > selection.start.line + ? selection.end.character === 0 + : selection.end.character === + document.lineAt(selection.end.line).text.length); + + // Helper functions + const isLineEmpty = (lineNumber: number): boolean => { + return document.lineAt(lineNumber).text.trim().length === 0; + }; + + const getLineEndChar = (lineNumber: number): number => { + return document.lineAt(lineNumber).text.trimEnd().length; + }; + + // If single empty line selected and not full line selection, return null + if ( + startLine === endLine && + isLineEmpty(startLine) && + !isFullLineSelection + ) { + return null; + } + + // Find topmost non-empty line + let topNonEmptyLine = startLine; + while (topNonEmptyLine <= endLine && isLineEmpty(topNonEmptyLine)) { + topNonEmptyLine++; + } + + // If all lines empty, return null + if (topNonEmptyLine > endLine) { + return null; + } + + const OFFSET = 4; // Characters to offset from end of line + + // Single line or full line selection + if (isFullLineSelection || startLine === endLine) { + return new vscode.Position( + topNonEmptyLine, + getLineEndChar(topNonEmptyLine) + OFFSET, + ); + } + + // Check line above selection + const lineAboveSelection = Math.max(0, startLine - 1); + + // Get end positions + const topNonEmptyEndChar = getLineEndChar(topNonEmptyLine); + const lineAboveEndChar = getLineEndChar(lineAboveSelection); + + const baseEndChar = Math.max(topNonEmptyEndChar, lineAboveEndChar); + + return new vscode.Position(topNonEmptyLine, baseEndChar + OFFSET); + } + + private updateTooltipPosition( + editor: vscode.TextEditor, + selection: vscode.Selection, + ) { + const position = this.calculateTooltipPosition(editor, selection); + + if (!position) { + editor.setDecorations(this.svgTooltipDecoration, []); + return; + } + + editor.setDecorations(this.svgTooltipDecoration, [ + { + range: new vscode.Range(position, position), + hoverMessage: [this.buildHideTooltipHoverMsg()], + }, + ]); + } +} + +export default function setupInlineTips(context: vscode.ExtensionContext) { + InlineTipManager.getInstance().setupInlineTips(context); +} diff --git a/extensions/vscode/src/activation/activate.ts b/extensions/vscode/src/activation/activate.ts index 7aa0ae4a9..d40aee740 100644 --- a/extensions/vscode/src/activation/activate.ts +++ b/extensions/vscode/src/activation/activate.ts @@ -7,7 +7,8 @@ import registerQuickFixProvider from "../lang-server/codeActions"; import { getExtensionVersion } from "../util/util"; import { VsCodeContinueApi } from "./api"; -import { setupInlineTips } from "./inlineTips"; +import setupInlineTips from "./InlineTipManager"; +// import { setupInlineTips } from "./inlineTips"; export async function activateExtension(context: vscode.ExtensionContext) { // Add necessary files diff --git a/extensions/vscode/src/activation/inlineTips.ts b/extensions/vscode/src/activation/inlineTips.ts deleted file mode 100644 index 49a8adf29..000000000 --- a/extensions/vscode/src/activation/inlineTips.ts +++ /dev/null @@ -1,122 +0,0 @@ -import { EXTENSION_NAME } from "core/control-plane/env"; -import * as vscode from "vscode"; - -import { getMetaKeyName } from "../util/util"; - -const inlineTipDecoration = vscode.window.createTextEditorDecorationType({ - after: { - contentText: `Add to chat (${getMetaKeyName()}+L) | Edit highlighted code (${getMetaKeyName()}+I).`, - color: "#888", - margin: "0 0 0 6em", - fontWeight: "bold", - }, -}); - -function showInlineTip() { - return vscode.workspace - .getConfiguration(EXTENSION_NAME) - .get("showInlineTip"); -} - -function handleSelectionChange(e: vscode.TextEditorSelectionChangeEvent) { - const selection = e.selections[0]; - const editor = e.textEditor; - - if (editor.document.uri.toString().startsWith("output:")) { - return; - } - - if (selection.isEmpty || showInlineTip() === false) { - editor.setDecorations(inlineTipDecoration, []); - return; - } - - const line = Math.max(0, selection.start.line - 1); - - const hoverMarkdown = new vscode.MarkdownString( - `Click [here](command:continue.hideInlineTip) to hide these suggestions`, - ); - hoverMarkdown.isTrusted = true; - hoverMarkdown.supportHtml = true; - editor.setDecorations(inlineTipDecoration, [ - { - range: new vscode.Range( - new vscode.Position(line, Number.MAX_VALUE), - new vscode.Position(line, Number.MAX_VALUE), - ), - hoverMessage: [hoverMarkdown], - }, - ]); -} - -const emptyFileTooltipDecoration = vscode.window.createTextEditorDecorationType( - { - after: { - contentText: `Use ${getMetaKeyName()}+I to generate code`, - color: "#888", - margin: "2em 0 0 0", - fontStyle: "italic", - }, - }, -); - -let selectionChangeDebounceTimer: NodeJS.Timeout | undefined; - -export function setupInlineTips(context: vscode.ExtensionContext) { - context.subscriptions.push( - vscode.window.onDidChangeTextEditorSelection((e) => { - if (selectionChangeDebounceTimer) { - clearTimeout(selectionChangeDebounceTimer); - } - selectionChangeDebounceTimer = setTimeout(() => { - handleSelectionChange(e); - }, 200); - }), - ); - - context.subscriptions.push( - vscode.window.onDidChangeActiveTextEditor((editor) => { - if (editor?.document.getText() === "" && showInlineTip() === true) { - if ( - editor.document.uri.toString().startsWith("output:") || - editor.document.uri.scheme === "comment" - ) { - return; - } - - editor.setDecorations(emptyFileTooltipDecoration, [ - { - range: new vscode.Range( - new vscode.Position(0, Number.MAX_VALUE), - new vscode.Position(0, Number.MAX_VALUE), - ), - }, - ]); - } - }), - ); - - context.subscriptions.push( - vscode.workspace.onDidChangeTextDocument((e) => { - if (e.document.uri.toString().startsWith("vscode://inline-chat")) { - return; - } - if (e.document.getText() === "" && showInlineTip() === true) { - vscode.window.visibleTextEditors.forEach((editor) => { - editor.setDecorations(emptyFileTooltipDecoration, [ - { - range: new vscode.Range( - new vscode.Position(0, Number.MAX_VALUE), - new vscode.Position(0, Number.MAX_VALUE), - ), - }, - ]); - }); - } else { - vscode.window.visibleTextEditors.forEach((editor) => { - editor.setDecorations(emptyFileTooltipDecoration, []); - }); - } - }), - ); -} diff --git a/gui/src/components/indexing/ChatIndexingPeeks.tsx b/gui/src/components/indexing/ChatIndexingPeeks.tsx index 1ec1076c0..66936597d 100644 --- a/gui/src/components/indexing/ChatIndexingPeeks.tsx +++ b/gui/src/components/indexing/ChatIndexingPeeks.tsx @@ -62,7 +62,7 @@ function ChatIndexingPeek({ state }: ChatIndexingPeekProps) {
{ dispatch( setIndexingChatPeekHidden({ type: state.type, hidden: true }), diff --git a/package-lock.json b/package-lock.json index c147efa72..da3272555 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,9 @@ "requires": true, "packages": { "": { + "dependencies": { + "svg-builder": "^2.0.0" + }, "devDependencies": { "@typescript-eslint/parser": "^7.8.0", "eslint-plugin-import": "^2.29.1", @@ -2828,6 +2831,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/svg-builder": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/svg-builder/-/svg-builder-2.0.0.tgz", + "integrity": "sha512-v89FptvyrOy1Gf9KPkIo2jxroCLEZLiGBRTSutL3pzqZe2xnCFltkCLnEjV8QOEJ99PzBa9NGPGEDP9l8MWIrw==" + }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", diff --git a/package.json b/package.json index c093fccd9..e3091f198 100644 --- a/package.json +++ b/package.json @@ -11,5 +11,8 @@ "eslint-plugin-import": "^2.29.1", "prettier": "^3.3.3", "prettier-plugin-tailwindcss": "^0.6.8" + }, + "dependencies": { + "svg-builder": "^2.0.0" } } From 5a13272d375c2630be03dc97e6234389fff2d02a Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 2 Jan 2025 17:56:20 -0600 Subject: [PATCH 055/114] Update InlineTipManager.ts --- extensions/vscode/src/activation/InlineTipManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode/src/activation/InlineTipManager.ts b/extensions/vscode/src/activation/InlineTipManager.ts index b335cc9dd..954dba19d 100644 --- a/extensions/vscode/src/activation/InlineTipManager.ts +++ b/extensions/vscode/src/activation/InlineTipManager.ts @@ -15,7 +15,7 @@ const SVG_CONFIG = { radius: 4, leftMargin: 40, debounceDelay: 500, - chatLabel: "Add to Chat", + chatLabel: "Chat", chatShortcut: `${getMetaKeyLabel()}L`, editLabel: "Edit", editShortcut: `${getMetaKeyLabel()}I`, From 02968fb1551c0a26af75340641312e1f9f5a1102 Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 2 Jan 2025 20:33:23 -0600 Subject: [PATCH 056/114] fix: correct package.json update --- extensions/vscode/package-lock.json | 10 ++++++++-- extensions/vscode/package.json | 1 + extensions/vscode/src/activation/InlineTipManager.ts | 4 ++-- extensions/vscode/src/activation/activate.ts | 1 - package-lock.json | 8 -------- package.json | 3 --- 6 files changed, 11 insertions(+), 16 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 8f5cad8a0..c6db7f103 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.247", + "version": "0.9.248", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.247", + "version": "0.9.248", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", @@ -48,6 +48,7 @@ "request": "^2.88.2", "socket.io-client": "^4.7.2", "strip-ansi": "^7.1.0", + "svg-builder": "^2.0.0", "systeminformation": "^5.22.10", "tailwindcss": "^3.3.2", "undici": "^6.2.0", @@ -12122,6 +12123,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/svg-builder": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/svg-builder/-/svg-builder-2.0.0.tgz", + "integrity": "sha512-v89FptvyrOy1Gf9KPkIo2jxroCLEZLiGBRTSutL3pzqZe2xnCFltkCLnEjV8QOEJ99PzBa9NGPGEDP9l8MWIrw==" + }, "node_modules/symbol-tree": { "version": "3.2.4", "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 6a416096c..550ed3538 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -703,6 +703,7 @@ "request": "^2.88.2", "socket.io-client": "^4.7.2", "strip-ansi": "^7.1.0", + "svg-builder": "^2.0.0", "systeminformation": "^5.22.10", "tailwindcss": "^3.3.2", "undici": "^6.2.0", diff --git a/extensions/vscode/src/activation/InlineTipManager.ts b/extensions/vscode/src/activation/InlineTipManager.ts index 954dba19d..0ea078c21 100644 --- a/extensions/vscode/src/activation/InlineTipManager.ts +++ b/extensions/vscode/src/activation/InlineTipManager.ts @@ -23,7 +23,7 @@ const SVG_CONFIG = { get fontSize() { return Math.ceil( (vscode.workspace.getConfiguration("editor").get("fontSize") ?? - 14) * 0.7, + 14) * 0.8, ); }, get fontFamily() { @@ -237,7 +237,7 @@ export class InlineTipManager { return vscode.window.createTextEditorDecorationType({ after: { contentIconPath: this.svgTooltip, - margin: `-2.5px 0 0 ${SVG_CONFIG.leftMargin}px`, + margin: `-5px 0 0 ${SVG_CONFIG.leftMargin}px`, width: `${SVG_CONFIG.tipWidth}px`, }, }); diff --git a/extensions/vscode/src/activation/activate.ts b/extensions/vscode/src/activation/activate.ts index d40aee740..1bd22c7f4 100644 --- a/extensions/vscode/src/activation/activate.ts +++ b/extensions/vscode/src/activation/activate.ts @@ -8,7 +8,6 @@ import { getExtensionVersion } from "../util/util"; import { VsCodeContinueApi } from "./api"; import setupInlineTips from "./InlineTipManager"; -// import { setupInlineTips } from "./inlineTips"; export async function activateExtension(context: vscode.ExtensionContext) { // Add necessary files diff --git a/package-lock.json b/package-lock.json index da3272555..c147efa72 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,9 +4,6 @@ "requires": true, "packages": { "": { - "dependencies": { - "svg-builder": "^2.0.0" - }, "devDependencies": { "@typescript-eslint/parser": "^7.8.0", "eslint-plugin-import": "^2.29.1", @@ -2831,11 +2828,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/svg-builder": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/svg-builder/-/svg-builder-2.0.0.tgz", - "integrity": "sha512-v89FptvyrOy1Gf9KPkIo2jxroCLEZLiGBRTSutL3pzqZe2xnCFltkCLnEjV8QOEJ99PzBa9NGPGEDP9l8MWIrw==" - }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", diff --git a/package.json b/package.json index e3091f198..c093fccd9 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,5 @@ "eslint-plugin-import": "^2.29.1", "prettier": "^3.3.3", "prettier-plugin-tailwindcss": "^0.6.8" - }, - "dependencies": { - "svg-builder": "^2.0.0" } } From 92a38ccf5f0639d815684bd786f75ebede9e950c Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 2 Jan 2025 23:24:32 -0600 Subject: [PATCH 057/114] bugfix: handle inline edit w/ myers diff --- .../vscode/src/diff/vertical/handler.ts | 75 ++++++++++--------- .../vscode/src/diff/vertical/manager.ts | 2 +- .../VerticalPerLineCodeLensProvider.ts | 9 --- 3 files changed, 40 insertions(+), 46 deletions(-) diff --git a/extensions/vscode/src/diff/vertical/handler.ts b/extensions/vscode/src/diff/vertical/handler.ts index a99c9c1c3..80331f805 100644 --- a/extensions/vscode/src/diff/vertical/handler.ts +++ b/extensions/vscode/src/diff/vertical/handler.ts @@ -343,6 +343,7 @@ export class VerticalDiffHandler implements vscode.Disposable { async run(diffLineGenerator: AsyncGenerator) { let diffLines = []; + try { // As an indicator of loading this.updateIndexLineDecorations(); @@ -481,9 +482,17 @@ export class VerticalDiffHandler implements vscode.Disposable { * we have received all of the diff lines. */ async reapplyWithMeyersDiff(diffLines: DiffLine[]) { + // First, we reset the original diff by deleting any new lines and clearing decorations + for (const range of this.greenDecorationManager.getRanges()) { + await this.deleteLinesAt( + range.start.line, + range.end.line - range.start.line + 1, + ); + } + this.clearDecorations(); - // First, get our old/new file content based on the diff lines + // Then, get our old/new file content based on the original lines const oldFileContent = diffLines .filter((line) => line.type === "same" || line.type === "old") .map((line) => line.line) @@ -497,55 +506,49 @@ export class VerticalDiffHandler implements vscode.Disposable { const diffs = myersDiff(oldFileContent, newFileContent); const meyersDiffLines = diffs.map((diff) => diff.line).join("\n"); - console.log({ newFileContent }); - - // Then, we overwrite the potentially miscalcualted diff blocks with our Meyers Diff - const fullRange = new vscode.Range( - this.editor.document.positionAt(0), - this.editor.document.positionAt(this.editor.document.getText().length), - ); + // Then, we insert our diff lines await this.editor.edit((editBuilder) => { - editBuilder.replace(fullRange, meyersDiffLines); + editBuilder.replace(this.range, meyersDiffLines), + { + undoStopAfter: false, + undoStopBefore: false, + }; }); - let currentBlock = { - start: 0, - numRed: 0, - numGreen: 0, - }; - - const blocks: VerticalDiffCodeLens[] = []; - // Lastly, we apply decorations + let numRed = 0; + let numGreen = 0; + + const codeLensBlocks: VerticalDiffCodeLens[] = []; + diffs.forEach((diff, index) => { if (diff.type === "old") { - this.redDecorationManager.addLine(index); - currentBlock.numRed++; + this.redDecorationManager.addLine(this.startLine + index); + numRed++; } else if (diff.type === "new") { - this.greenDecorationManager.addLine(index); - currentBlock.numGreen++; - } else if ( - diff.type === "same" && - (currentBlock.numRed > 0 || currentBlock.numGreen > 0) - ) { - blocks.push({ - ...currentBlock, - start: index - currentBlock.numRed - currentBlock.numGreen, + this.greenDecorationManager.addLine(this.startLine + index); + numGreen++; + } else if (diff.type === "same" && (numRed > 0 || numGreen > 0)) { + codeLensBlocks.push({ + numRed, + numGreen, + start: this.startLine + index - numRed - numGreen, }); - currentBlock = { - start: index + 1, - numRed: 0, - numGreen: 0, - }; + numRed = 0; + numGreen = 0; } }); - if (currentBlock.numRed > 0 || currentBlock.numGreen > 0) { - blocks.push(currentBlock); + if (numRed > 0 || numGreen > 0) { + codeLensBlocks.push({ + numGreen, + numRed, + start: this.startLine + diffs.length - 1 - numRed - numGreen, + }); } - this.editorToVerticalDiffCodeLens.set(this.fileUri, blocks); + this.editorToVerticalDiffCodeLens.set(this.fileUri, codeLensBlocks); this.refreshCodeLens(); } } diff --git a/extensions/vscode/src/diff/vertical/manager.ts b/extensions/vscode/src/diff/vertical/manager.ts index ee47fd173..1e1b41a17 100644 --- a/extensions/vscode/src/diff/vertical/manager.ts +++ b/extensions/vscode/src/diff/vertical/manager.ts @@ -3,13 +3,13 @@ import { ConfigHandler } from "core/config/ConfigHandler"; import { streamDiffLines } from "core/edit/streamDiffLines"; import { pruneLinesFromBottom, pruneLinesFromTop } from "core/llm/countTokens"; import { getMarkdownLanguageTagForFile } from "core/util"; +import * as URI from "uri-js"; import * as vscode from "vscode"; import EditDecorationManager from "../../quickEdit/EditDecorationManager"; import { VsCodeWebviewProtocol } from "../../webviewProtocol"; import { VerticalDiffHandler, VerticalDiffHandlerOptions } from "./handler"; -import * as URI from "uri-js"; export interface VerticalDiffCodeLens { start: number; diff --git a/extensions/vscode/src/lang-server/codeLens/providers/VerticalPerLineCodeLensProvider.ts b/extensions/vscode/src/lang-server/codeLens/providers/VerticalPerLineCodeLensProvider.ts index 52fd07f79..43c9015f1 100644 --- a/extensions/vscode/src/lang-server/codeLens/providers/VerticalPerLineCodeLensProvider.ts +++ b/extensions/vscode/src/lang-server/codeLens/providers/VerticalPerLineCodeLensProvider.ts @@ -53,15 +53,6 @@ export class VerticalDiffCodeLensProvider implements vscode.CodeLensProvider { arguments: [uri, i], }), ); - - if (codeLenses.length === 2) { - codeLenses.push( - new vscode.CodeLens(range, { - title: `${getMetaKeyLabel()}I to add instructions`, - command: "", - }), - ); - } } return codeLenses; From cb77d90a896918f64a62a8e5ad7d95ad7ff56b78 Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 2 Jan 2025 23:26:33 -0600 Subject: [PATCH 058/114] Update handler.ts --- extensions/vscode/src/diff/vertical/handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode/src/diff/vertical/handler.ts b/extensions/vscode/src/diff/vertical/handler.ts index 80331f805..a3a7f651f 100644 --- a/extensions/vscode/src/diff/vertical/handler.ts +++ b/extensions/vscode/src/diff/vertical/handler.ts @@ -544,7 +544,7 @@ export class VerticalDiffHandler implements vscode.Disposable { codeLensBlocks.push({ numGreen, numRed, - start: this.startLine + diffs.length - 1 - numRed - numGreen, + start: this.startLine + diffs.length - numRed - numGreen, }); } From 0cadb9f958765a702ad177c76ef98b024d6bfc41 Mon Sep 17 00:00:00 2001 From: henry Date: Fri, 3 Jan 2025 00:13:01 -0600 Subject: [PATCH 059/114] removed unused import --- extensions/vscode/src/commands.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index d3fe2eb43..d1b41b53b 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -37,7 +37,6 @@ import { Battery } from "./util/battery"; import { VsCodeIde } from "./VsCodeIde"; import type { VsCodeWebviewProtocol } from "./webviewProtocol"; -import { Disposable } from "vscode-languageclient"; let fullScreenPanel: vscode.WebviewPanel | undefined; From 2200b6eafd2773afbd7172e5fbd601464a5be906 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 3 Jan 2025 10:10:25 +0100 Subject: [PATCH 060/114] uri util fixes --- core/util/ideUtils.ts | 18 ++--- core/util/uri.test.ts | 22 ------ core/util/uri.ts | 71 ++++++++----------- .../StepContainerPreToolbar.tsx | 4 +- 4 files changed, 42 insertions(+), 73 deletions(-) diff --git a/core/util/ideUtils.ts b/core/util/ideUtils.ts index 93cb5008d..b969b2286 100644 --- a/core/util/ideUtils.ts +++ b/core/util/ideUtils.ts @@ -1,6 +1,10 @@ import { IDE } from ".."; -import { joinPathsToUri, pathToUriPathSegment } from "./uri"; +import { + joinEncodedUriPathSegmentToUri, + joinPathsToUri, + pathToUriPathSegment, +} from "./uri"; /* This function takes a relative (to workspace) filepath @@ -51,7 +55,7 @@ export async function inferResolvedUriFromRelativePath( for (const suffix of suffixes) { const uris = dirs.map((dir) => ({ dir, - partialUri: joinPathsToUri(dir, suffix), + partialUri: joinEncodedUriPathSegmentToUri(dir, suffix), })); const promises = uris.map(async ({ partialUri, dir }) => { const exists = await ide.fileExists(partialUri); @@ -67,15 +71,13 @@ export async function inferResolvedUriFromRelativePath( // If exactly one directory matches, use it if (existingUris.length === 1) { - return joinPathsToUri(existingUris[0].dir, segments.join("/")); + return joinEncodedUriPathSegmentToUri( + existingUris[0].dir, + segments.join("/"), + ); } } // If no unique match found, use the first directory return joinPathsToUri(dirs[0], path); } - -interface ResolveResult { - resolvedUri: string; - matchedDir: string; -} diff --git a/core/util/uri.test.ts b/core/util/uri.test.ts index 9e2471054..8a915d73f 100644 --- a/core/util/uri.test.ts +++ b/core/util/uri.test.ts @@ -1,9 +1,7 @@ // Generated by continue -import * as URI from "uri-js"; import { pathToUriPathSegment, findUriInDirs, - relativePathOrUriToUri, getUriPathBasename, getUriFileExtension, getFileExtensionFromBasename, @@ -141,26 +139,6 @@ describe("uri utils", () => { }); }); - describe("relativePathOrUriToUri", () => { - const consoleSpy = jest.spyOn(console, "trace").mockImplementation(); - - afterEach(() => { - consoleSpy.mockClear(); - }); - - it("should return original URI if scheme exists", () => { - const uri = "file:///path/to/file.txt"; - expect(relativePathOrUriToUri(uri, "file:///base")).toBe(uri); - }); - - it("should convert relative path to URI", () => { - expect(relativePathOrUriToUri("path/to/file.txt", "file:///base")).toBe( - "file:///base/path/to/file.txt", - ); - expect(consoleSpy).toHaveBeenCalledWith("Received path with no scheme"); - }); - }); - describe("getLastNUriRelativePathParts", () => { it("should get last N parts of URI relative path", () => { const dirUris = ["file:///workspace/project1"]; diff --git a/core/util/uri.ts b/core/util/uri.ts index 708408ce0..a1bcd7745 100644 --- a/core/util/uri.ts +++ b/core/util/uri.ts @@ -5,23 +5,21 @@ import * as URI from "uri-js"; \this\is\afile.ts -> this/is/afile.ts is/already/clean -> is/already/clean **/ - export function pathToUriPathSegment(path: string) { let clean = path.replace(/[\\]/g, "/"); // backslashes -> forward slashes clean = clean.replace(/^\//, ""); // remove start slash clean = clean.replace(/\/$/, ""); // remove end slash return clean .split("/") - .map((segment) => encodeURIComponent(segment)) + .map((part) => encodeURIComponent(part)) .join("/"); } export function getCleanUriPath(uri: string) { - const path = URI.parse(uri).path; - if (!path) { - return ""; - } - return pathToUriPathSegment(path); + const path = URI.parse(uri).path ?? ""; + let clean = path.replace(/^\//, ""); // remove start slash + clean = clean.replace(/\/$/, ""); // remove end slash + return clean; } export function findUriInDirs( @@ -36,6 +34,7 @@ export function findUriInDirs( if (!uriComps.scheme) { throw new Error(`Invalid uri: ${uri}`); } + const uriPathParts = getCleanUriPath(uri).split("/"); for (const dir of dirUriCandidates) { const dirComps = URI.parse(dir); @@ -51,14 +50,7 @@ export function findUriInDirs( // file:///folder/file is not within file:///fold // At this point we break the path up and check if each dir path part matches - const dirPathParts = (dirComps.path ?? "") - .replace(/^\//, "") - .split("/") - .map((part) => encodeURIComponent(part)); - const uriPathParts = (uriComps.path ?? "") - .replace(/^\//, "") - .split("/") - .map((part) => encodeURIComponent(part)); + const dirPathParts = getCleanUriPath(dir).split("/"); if (uriPathParts.length < dirPathParts.length) { continue; @@ -70,7 +62,10 @@ export function findUriInDirs( } } if (allDirPartsMatch) { - const relativePath = uriPathParts.slice(dirPathParts.length).join("/"); + const relativePath = uriPathParts + .slice(dirPathParts.length) + .map(decodeURIComponent) + .join("/"); return { uri, relativePathOrBasename: relativePath, @@ -86,28 +81,13 @@ export function findUriInDirs( }; } -/* - To smooth out the transition from path to URI will use this function to warn when path is used - This will NOT work consistently with full OS paths like c:\blah\blah or ~/Users/etc -*/ -export function relativePathOrUriToUri( - relativePathOrUri: string, - defaultDirUri: string, -): string { - const out = URI.parse(relativePathOrUri); - if (out.scheme) { - return relativePathOrUri; - } - console.trace("Received path with no scheme"); - return joinPathsToUri(defaultDirUri, out.path ?? ""); -} - /* Returns just the file or folder name of a URI */ export function getUriPathBasename(uri: string): string { - const cleanPath = getCleanUriPath(uri); - return cleanPath.split("/")?.pop() || ""; + const path = getCleanUriPath(uri); + const basename = path.split("/").pop() || ""; + return decodeURIComponent(basename); } export function getFileExtensionFromBasename(basename: string) { @@ -142,6 +122,15 @@ export function joinPathsToUri(uri: string, ...pathSegments: string[]) { return URI.serialize(components); } +export function joinEncodedUriPathSegmentToUri( + uri: string, + pathSegment: string, +) { + const components = URI.parse(uri); + components.path = `${components.path}/${pathSegment}`; + return URI.serialize(components); +} + export function getShortestUniqueRelativeUriPaths( uris: string[], dirUriCandidates: string[], @@ -153,8 +142,7 @@ export function getShortestUniqueRelativeUriPaths( const segmentCombinationsMap = new Map(); const segmentsInfo = uris.map((uri) => { const { relativePathOrBasename } = findUriInDirs(uri, dirUriCandidates); - const cleanPath = pathToUriPathSegment(relativePathOrBasename); - const segments = cleanPath.split("/"); + const segments = relativePathOrBasename.split("/"); const suffixes: string[] = []; // Generate all possible suffix combinations, starting from the shortest (basename) @@ -168,18 +156,19 @@ export function getShortestUniqueRelativeUriPaths( ); } - return { uri, segments, suffixes, cleanPath }; + return { uri, segments, suffixes, relativePathOrBasename }; }); // Find shortest unique path for each URI - return segmentsInfo.map(({ uri, suffixes, cleanPath }) => { + return segmentsInfo.map(({ uri, suffixes, relativePathOrBasename }) => { // Since suffixes are now ordered from shortest to longest, // the first unique one we find will be the shortest - const uniqueCleanPath = + const uniquePath = suffixes.find((suffix) => segmentCombinationsMap.get(suffix) === 1) ?? - cleanPath; // fallback to full path if no unique suffix found - return { uri, uniquePath: decodeURIComponent(uniqueCleanPath) }; + relativePathOrBasename; // fallback to full path if no unique suffix found + return { uri, uniquePath }; }); } + // Only used when working with system paths and relative paths // Since doesn't account for URI segements before workspace export function getLastNPathParts(filepath: string, n: number): string { diff --git a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx index c6a0d58f0..398ce5747 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx @@ -93,12 +93,12 @@ export default function StepContainerPreToolbar( if (!defaultModel) { return; } - + const fileUri = await inferResolvedUriFromRelativePath( props.relativeFilepath, ideMessenger.ide, ); - + ideMessenger.post("applyToFile", { streamId: streamIdRef.current, filepath: fileUri, From 821c841b43e7b054a207d645df61e93cbc15baa4 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 3 Jan 2025 10:47:33 +0100 Subject: [PATCH 061/114] fix multifile edit --- core/util/ideUtils.ts | 6 +++--- extensions/vscode/package-lock.json | 4 ++-- .../StepContainerPreToolbar.tsx | 1 + gui/src/util/getMultifileEditPrompt.ts | 18 ++++++++++++------ 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/core/util/ideUtils.ts b/core/util/ideUtils.ts index b969b2286..9ed4a47fc 100644 --- a/core/util/ideUtils.ts +++ b/core/util/ideUtils.ts @@ -34,7 +34,7 @@ export async function resolveRelativePathInDir( If no meaninful path match just concatenates to first dir's uri */ export async function inferResolvedUriFromRelativePath( - path: string, + relativePath: string, ide: IDE, dirCandidates?: string[], ): Promise { @@ -44,7 +44,7 @@ export async function inferResolvedUriFromRelativePath( throw new Error("inferResolvedUriFromRelativePath: no dirs provided"); } - const segments = pathToUriPathSegment(path).split("/"); + const segments = pathToUriPathSegment(relativePath).split("/"); // Generate all possible suffixes from shortest to longest const suffixes: string[] = []; for (let i = segments.length - 1; i >= 0; i--) { @@ -79,5 +79,5 @@ export async function inferResolvedUriFromRelativePath( } // If no unique match found, use the first directory - return joinPathsToUri(dirs[0], path); + return joinPathsToUri(dirs[0], relativePath); } diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 8f5cad8a0..0a2dd8330 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.247", + "version": "0.9.248", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.247", + "version": "0.9.248", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", diff --git a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx index 398ce5747..1ee03d2f5 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx @@ -98,6 +98,7 @@ export default function StepContainerPreToolbar( props.relativeFilepath, ideMessenger.ide, ); + console.log("HERE", props.relativeFilepath, fileUri); ideMessenger.post("applyToFile", { streamId: streamIdRef.current, diff --git a/gui/src/util/getMultifileEditPrompt.ts b/gui/src/util/getMultifileEditPrompt.ts index 8f526f1e2..13ee8ac78 100644 --- a/gui/src/util/getMultifileEditPrompt.ts +++ b/gui/src/util/getMultifileEditPrompt.ts @@ -1,16 +1,22 @@ -import { CodeToEdit } from "core"; +import { CodeToEdit, IDE } from "core"; +import { findUriInDirs } from "core/util/uri"; export default function getMultifileEditPrompt( codeToEdit: CodeToEdit[], + dirs?: string[], ): string { const codeToEditStr = codeToEdit - .map( - (code) => ` -\`\`\` ${code.filepath} + .map((code) => { + const { relativePathOrBasename } = findUriInDirs( + code.filepath, + dirs ?? window.workspacePaths ?? [], + ); + return ` +\`\`\` ${relativePathOrBasename} ${code.contents} \`\`\` - `, - ) + `; + }) .join("\n"); return ` From 02ab561b0191194fd9ddf7d47080ab896ac36b38 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 3 Jan 2025 16:00:42 +0100 Subject: [PATCH 062/114] gui strict null checks p3 --- gui/src/components/markdown/utils.ts | 2 +- gui/src/context/IdeMessenger.ts | 12 ++++-- gui/src/context/SubmenuContextProviders.tsx | 10 +++-- gui/src/redux/slices/sessionSlice.ts | 41 +++++++++------------ gui/src/redux/store.ts | 5 ++- gui/src/redux/thunks/callTool.ts | 2 +- gui/src/redux/thunks/gatherContext.ts | 6 ++- gui/src/redux/thunks/session.ts | 2 +- gui/src/redux/thunks/streamResponse.ts | 7 +++- 9 files changed, 49 insertions(+), 38 deletions(-) diff --git a/gui/src/components/markdown/utils.ts b/gui/src/components/markdown/utils.ts index 1044066d1..9b2329303 100644 --- a/gui/src/components/markdown/utils.ts +++ b/gui/src/components/markdown/utils.ts @@ -30,7 +30,7 @@ export function isTerminalCodeBlock( text: string, ) { return ( - terminalLanguages.includes(language) || + (language && terminalLanguages.includes(language)) || ((!language || language?.length === 0) && (text.trim().split("\n").length === 1 || commonTerminalCommands.some((c) => text.trim().startsWith(c)))) diff --git a/gui/src/context/IdeMessenger.ts b/gui/src/context/IdeMessenger.ts index 76881e9a7..46bc92538 100644 --- a/gui/src/context/IdeMessenger.ts +++ b/gui/src/context/IdeMessenger.ts @@ -164,18 +164,22 @@ export class IdeMessenger implements IIdeMessenger { messageType: T, data: FromWebviewProtocol[T][0], cancelToken?: AbortSignal, - ): AsyncGenerator { - // ): FromWebviewProtocol[T][1] { + ): AsyncGenerator { const messageId = uuidv4(); this.post(messageType, data, messageId); - const buffer: any[] = []; + const buffer: FromWebviewProtocol[T][1][] = []; let index = 0; let done = false; let returnVal = undefined; - const handler = (event: { data: Message }) => { + const handler = (event: { + data: Message<{ + done: boolean; + content: FromWebviewProtocol[T][1]; + }>; + }) => { if (event.data.messageId === messageId) { const responseData = event.data.data; if (responseData.done) { diff --git a/gui/src/context/SubmenuContextProviders.tsx b/gui/src/context/SubmenuContextProviders.tsx index 673caec1c..f99848665 100644 --- a/gui/src/context/SubmenuContextProviders.tsx +++ b/gui/src/context/SubmenuContextProviders.tsx @@ -144,7 +144,9 @@ export const SubmenuContextProvidersProvider = ({ [minisearches], ); - const lastOpenFilesRef = useRef([]); + const lastOpenFilesRef = useRef< + Awaited> + >([]); useEffect(() => { let isMounted = true; const refreshOpenFiles = async () => { @@ -214,12 +216,14 @@ export const SubmenuContextProvidersProvider = ({ try { const results = getSubmenuSearchResults(providerTitle, query); if (results.length === 0) { - const fallbackItems = (fallbackResults[providerTitle] ?? []) + const fallbackItems = ( + providerTitle ? (fallbackResults[providerTitle] ?? []) : [] + ) .slice(0, limit) .map((result) => { return { ...result, - providerTitle, + providerTitle: providerTitle || "unknown", }; }); diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 4888d5cb1..7cd06594b 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -281,16 +281,16 @@ export const sessionSlice = createSlice({ }, streamUpdate: (state, action: PayloadAction) => { if (state.history.length) { + const lastItem = state.history[state.history.length - 1]; + const lastMessage = lastItem.message; for (const message of action.payload) { - const lastMessage = state.history[state.history.length - 1]; - if ( message.role && - (lastMessage.message.role !== message.role || + (lastMessage.role !== message.role || // This is when a tool call comes after assistant text - (lastMessage.message.content !== "" && - message.role === "assistant" && - message.toolCalls?.length)) + (lastMessage.content !== "" && + message.role === "assistant" +)) ) { // Create a new message const historyItem: ChatHistoryItemWithMessageId = { @@ -300,8 +300,8 @@ export const sessionSlice = createSlice({ }, contextItems: [], }; - - if (message.role === "assistant" && message.toolCalls) { + const toolCalls = + if (message.role === "assistant" && message.toolCalls?.[0]) { const [_, parsedArgs] = incrementalParseJson( message.toolCalls[0].function.arguments, ); @@ -316,34 +316,29 @@ export const sessionSlice = createSlice({ state.history.push(historyItem); } else { // Add to the existing message - const msg = state.history[state.history.length - 1].message; if (message.content) { - msg.content += renderChatMessage(message); + lastMessage.content += renderChatMessage(message); } else if ( message.role === "assistant" && message.toolCalls && - msg.role === "assistant" + lastMessage.role === "assistant" ) { - if (!msg.toolCalls) { - msg.toolCalls = []; + if (!lastMessage.toolCalls) { + lastMessage.toolCalls = []; } message.toolCalls.forEach((toolCall, i) => { - if (msg.toolCalls.length <= i) { - msg.toolCalls.push(toolCall); + if (lastMessage.toolCalls!.length <= i) { + lastMessage.toolCalls!.push(toolCall); } else { - msg.toolCalls[i].function.arguments += + lastMessage.toolCalls[i].function.arguments += toolCall.function.arguments; const [_, parsedArgs] = incrementalParseJson( - msg.toolCalls[i].function.arguments, + lastMessage.toolCalls[i].function.arguments, ); - state.history[ - state.history.length - 1 - ].toolCallState.parsedArgs = parsedArgs; - state.history[ - state.history.length - 1 - ].toolCallState.toolCall.function.arguments += + lastItem.toolCallState.parsedArgs = parsedArgs; + lastItem.toolCallState.toolCall.function.arguments += toolCall.function.arguments; } }); diff --git a/gui/src/redux/store.ts b/gui/src/redux/store.ts index 5ddf55ee6..8a617d2e8 100644 --- a/gui/src/redux/store.ts +++ b/gui/src/redux/store.ts @@ -63,7 +63,10 @@ const persistConfig = { migrate: createMigrate(migrations, { debug: false }), }; -const persistedReducer = persistReducer(persistConfig, rootReducer); +const persistedReducer = persistReducer>( + persistConfig, + rootReducer, +); export function setupStore() { return configureStore({ diff --git a/gui/src/redux/thunks/callTool.ts b/gui/src/redux/thunks/callTool.ts index 184ad6e6a..7f9af5b04 100644 --- a/gui/src/redux/thunks/callTool.ts +++ b/gui/src/redux/thunks/callTool.ts @@ -14,10 +14,10 @@ export const callTool = createAsyncThunk( const state = getState(); const toolCallState = selectCurrentToolCall(state); - console.log("calling tool", toolCallState.toolCall); if (!toolCallState) { return; } + console.log("calling tool", toolCallState.toolCall); if (toolCallState.status !== "generated") { return; diff --git a/gui/src/redux/thunks/gatherContext.ts b/gui/src/redux/thunks/gatherContext.ts index 7f59a0547..125012479 100644 --- a/gui/src/redux/thunks/gatherContext.ts +++ b/gui/src/redux/thunks/gatherContext.ts @@ -39,8 +39,10 @@ export const gatherContext = createAsyncThunk< state.config.config.experimental?.defaultContext ?? []; if (!state.config.defaultModelTitle) { - console.error("Failed to gather context, no model selected"); - return; + console.error( + "gatherContext thunk: Cannot gather context, no model selected", + ); + throw new Error("No chat model selected"); } // Resolve context providers and construct new history diff --git a/gui/src/redux/thunks/session.ts b/gui/src/redux/thunks/session.ts index 9e4bbddc2..d9f35cfd6 100644 --- a/gui/src/redux/thunks/session.ts +++ b/gui/src/redux/thunks/session.ts @@ -192,7 +192,7 @@ export const saveCurrentSession = createAsyncThunk< } // Fallbacks if above doesn't work out or getChatTitles = false if (title === NEW_SESSION_TITLE) { - title = getChatTitleFromMessage(history[0].message); + title = getChatTitleFromMessage(state.session.history[0].message); } } // More fallbacks in case of no title diff --git a/gui/src/redux/thunks/streamResponse.ts b/gui/src/redux/thunks/streamResponse.ts index 3b70ecba1..0ad5f2fbe 100644 --- a/gui/src/redux/thunks/streamResponse.ts +++ b/gui/src/redux/thunks/streamResponse.ts @@ -66,6 +66,10 @@ export const streamResponseThunk = createAsyncThunk< const slashCommands = state.config.config.slashCommands || []; const inputIndex = index ?? state.session.history.length; + if (!defaultModel) { + throw new Error("No chat model selected"); + } + dispatch(submitEditorAndInitAtIndex({ index, editorState })); resetStateForNewMessage(); @@ -115,7 +119,6 @@ export const streamResponseThunk = createAsyncThunk< unwrapResult(await dispatch(streamNormalInput(messages))); } else { const [slashCommand, commandInput] = commandAndInput; - let updatedContextItems = []; posthog.capture("step run", { step_name: slashCommand.name, params: {}, @@ -132,7 +135,7 @@ export const streamResponseThunk = createAsyncThunk< input: commandInput, historyIndex: inputIndex, selectedCode, - contextItems: updatedContextItems, + contextItems: [], }), ); } From c7ed2aa62e2b142f5e80448afc264bdc18d44c79 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 3 Jan 2025 16:41:14 +0100 Subject: [PATCH 063/114] gui strict null checks continued --- .../StepContainer/UndoAndRedoButtons.tsx | 13 +++++----- gui/src/components/mainInput/resolveInput.ts | 18 ++++++------- .../StepContainerPreActionButtons.tsx | 2 +- .../StepContainerPreToolbar.tsx | 6 ++--- .../markdown/StyledMarkdownPreview.tsx | 6 ++--- gui/src/components/markdown/utils.ts | 2 +- gui/src/redux/slices/sessionSlice.ts | 26 +++++++++---------- 7 files changed, 37 insertions(+), 36 deletions(-) diff --git a/gui/src/components/StepContainer/UndoAndRedoButtons.tsx b/gui/src/components/StepContainer/UndoAndRedoButtons.tsx index a57b29bd2..e0e57c3e1 100644 --- a/gui/src/components/StepContainer/UndoAndRedoButtons.tsx +++ b/gui/src/components/StepContainer/UndoAndRedoButtons.tsx @@ -12,9 +12,7 @@ export default function UndoAndRedoButtons() { const dispatch = useDispatch(); const ideMessenger = useContext(IdeMessengerContext); - const checkpoints = useAppSelector( - (store) => store.session.history.at(-1).checkpoint, - ); + const history = useAppSelector((store) => store.session.history); const curCheckpointIndex = useAppSelector( (store) => store.session.curCheckpointIndex, @@ -28,10 +26,13 @@ export default function UndoAndRedoButtons() { type === "undo" ? curCheckpointIndex - 1 : curCheckpointIndex + 1, ); - const checkpoint = checkpoints[checkpointIndex]; + const checkpoint = history[checkpointIndex]?.checkpoint ?? {}; - for (const [filepath, prevFileContent] of Object.entries(checkpoint)) { - ideMessenger.post("overwriteFile", { filepath, prevFileContent }); + for (const [filepath, cachedFileContent] of Object.entries(checkpoint)) { + ideMessenger.post("overwriteFile", { + filepath, + prevFileContent: cachedFileContent, + }); } dispatch(setCurCheckpointIndex(checkpointIndex)); diff --git a/gui/src/components/mainInput/resolveInput.ts b/gui/src/components/mainInput/resolveInput.ts index 9c5107d1b..535a3074f 100644 --- a/gui/src/components/mainInput/resolveInput.ts +++ b/gui/src/components/mainInput/resolveInput.ts @@ -122,8 +122,8 @@ async function resolveEditorContent({ let contextItems: ContextItemWithId[] = []; for (const item of contextItemAttrs) { const result = await ideMessenger.request("context/getContextItems", { - name: item.itemType === "contextProvider" ? item.id : item.itemType, - query: item.query, + name: item.itemType === "contextProvider" ? item.id : item.itemType!, + query: item.query ?? "", fullInput: stripImages(parts), selectedCode, selectedModelTitle, @@ -211,22 +211,22 @@ function resolveParagraph( p: JSONContent, ): [string, MentionAttrs[], string | undefined] { let text = ""; - const contextItems = []; + const contextItems: MentionAttrs[] = []; let slashCommand: string | undefined = undefined; for (const child of p.content || []) { if (child.type === "text") { - text += text === "" ? child.text.trimStart() : child.text; + text += text === "" ? child.text?.trimStart() : child.text; } else if (child.type === "mention") { text += - typeof child.attrs.renderInlineAs === "string" + typeof child.attrs?.renderInlineAs === "string" ? child.attrs.renderInlineAs - : child.attrs.label; - contextItems.push(child.attrs); + : child.attrs?.label; + contextItems.push(child.attrs as MentionAttrs); } else if (child.type === "slashcommand") { if (typeof slashCommand === "undefined") { - slashCommand = child.attrs.id; + slashCommand = child.attrs?.id; } else { - text += child.attrs.label; + text += child.attrs?.label; } } else { console.warn("Unexpected child type", child.type); diff --git a/gui/src/components/markdown/StepContainerPreActionButtons.tsx b/gui/src/components/markdown/StepContainerPreActionButtons.tsx index 1afbe2a27..4ecce8315 100644 --- a/gui/src/components/markdown/StepContainerPreActionButtons.tsx +++ b/gui/src/components/markdown/StepContainerPreActionButtons.tsx @@ -50,7 +50,7 @@ const InnerHoverDiv = styled.div<{ isBottomToolbarPosition: boolean }>` `; interface StepContainerPreActionButtonsProps { - language: string; + language: string | null; codeBlockContent: string; codeBlockIndex: number; children: any; diff --git a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx index c6a0d58f0..45b55f10b 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx @@ -44,7 +44,7 @@ const ToolbarDiv = styled.div<{ isExpanded: boolean }>` export interface StepContainerPreToolbarProps { codeBlockContent: string; - language: string; + language: string | null; relativeFilepath: string; isGeneratingCodeBlock: boolean; codeBlockIndex: number; // To track which codeblock we are applying @@ -93,12 +93,12 @@ export default function StepContainerPreToolbar( if (!defaultModel) { return; } - + const fileUri = await inferResolvedUriFromRelativePath( props.relativeFilepath, ideMessenger.ide, ); - + ideMessenger.post("applyToFile", { streamId: streamIdRef.current, filepath: fileUri, diff --git a/gui/src/components/markdown/StyledMarkdownPreview.tsx b/gui/src/components/markdown/StyledMarkdownPreview.tsx index a6eb2c569..5ad8c52c2 100644 --- a/gui/src/components/markdown/StyledMarkdownPreview.tsx +++ b/gui/src/components/markdown/StyledMarkdownPreview.tsx @@ -228,7 +228,7 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( ], rehypeReactOptions: { components: { - a: ({ node, ...aProps }) => { + a: ({ ...aProps }) => { const tooltipId = uuidv4(); return ( @@ -247,7 +247,7 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( ); }, - pre: ({ node, ...preProps }) => { + pre: ({ ...preProps }) => { const codeBlockIndex = preProps["data-codeblockindex"]; const preChildProps = preProps?.children?.[0]?.props ?? {}; @@ -293,7 +293,7 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( ); }, - code: ({ node, ...codeProps }) => { + code: ({ ...codeProps }) => { const content = getCodeChildrenContent(codeProps.children); if (content && previousFileContextItemsRef.current) { diff --git a/gui/src/components/markdown/utils.ts b/gui/src/components/markdown/utils.ts index 9b2329303..9435abe47 100644 --- a/gui/src/components/markdown/utils.ts +++ b/gui/src/components/markdown/utils.ts @@ -26,7 +26,7 @@ export function getTerminalCommand(text: string): string { } export function isTerminalCodeBlock( - language: string | undefined, + language: string | undefined | null, text: string, ) { return ( diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 7cd06594b..2ad3ee89e 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -288,9 +288,7 @@ export const sessionSlice = createSlice({ message.role && (lastMessage.role !== message.role || // This is when a tool call comes after assistant text - (lastMessage.content !== "" && - message.role === "assistant" -)) + (lastMessage.content !== "" && message.role === "assistant")) ) { // Create a new message const historyItem: ChatHistoryItemWithMessageId = { @@ -300,17 +298,19 @@ export const sessionSlice = createSlice({ }, contextItems: [], }; - const toolCalls = if (message.role === "assistant" && message.toolCalls?.[0]) { - const [_, parsedArgs] = incrementalParseJson( - message.toolCalls[0].function.arguments, - ); - historyItem.toolCallState = { - status: "generating", - toolCall: message.toolCalls[0] as ToolCall, - toolCallId: message.toolCalls[0].id, - parsedArgs, - }; + const toolCalls = message.toolCalls?.[0]; + if (toolCalls) { + const [_, parsedArgs] = incrementalParseJson( + message.toolCalls[0].function.arguments, + ); + historyItem.toolCallState = { + status: "generating", + toolCall: message.toolCalls[0] as ToolCall, + toolCallId: message.toolCalls[0].id, + parsedArgs, + }; + } } state.history.push(historyItem); From 877f1cf812f4bb22ef4b2cc9c3d8915bd66de73f Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 3 Jan 2025 17:20:28 +0100 Subject: [PATCH 064/114] null checks p4 --- .../components/mainInput/FillerExtension.tsx | 20 +++++ gui/src/components/mainInput/MentionList.tsx | 2 +- gui/src/components/mainInput/TipTapEditor.tsx | 78 ++++++++++++++----- .../modelSelection/ModelSelectionListbox.tsx | 7 +- gui/src/hooks/useSetup.ts | 10 ++- gui/src/pages/AddNewModel/AddNewModel.tsx | 39 ++++++---- 6 files changed, 107 insertions(+), 49 deletions(-) create mode 100644 gui/src/components/mainInput/FillerExtension.tsx diff --git a/gui/src/components/mainInput/FillerExtension.tsx b/gui/src/components/mainInput/FillerExtension.tsx new file mode 100644 index 000000000..9b8baac86 --- /dev/null +++ b/gui/src/components/mainInput/FillerExtension.tsx @@ -0,0 +1,20 @@ +import { Node } from "@tiptap/core"; + +export const MockExtension = Node.create({ + name: "mockExtension", + + addOptions() { + return { + enabled: false, + }; + }, + addCommands() { + return {}; + }, + addKeyboardShortcuts() { + return {}; + }, + addProseMirrorPlugins() { + return []; + }, +}); diff --git a/gui/src/components/mainInput/MentionList.tsx b/gui/src/components/mainInput/MentionList.tsx index 754d436fe..8143fe507 100644 --- a/gui/src/components/mainInput/MentionList.tsx +++ b/gui/src/components/mainInput/MentionList.tsx @@ -311,7 +311,7 @@ const MentionList = forwardRef((props: MentionListProps, ref) => { useEffect(() => setSelectedIndex(0), [allItems]); useImperativeHandle(ref, () => ({ - onKeyDown: ({ event }) => { + onKeyDown: ({ event }: { event: KeyboardEvent }) => { if (event.key === "ArrowUp") { upHandler(); return true; diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx index 00838ad91..8b360457d 100644 --- a/gui/src/components/mainInput/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor.tsx @@ -5,7 +5,13 @@ import Paragraph from "@tiptap/extension-paragraph"; import Placeholder from "@tiptap/extension-placeholder"; import Text from "@tiptap/extension-text"; import { Plugin } from "@tiptap/pm/state"; -import { Editor, EditorContent, JSONContent, useEditor } from "@tiptap/react"; +import { + AnyExtension, + Editor, + EditorContent, + JSONContent, + useEditor, +} from "@tiptap/react"; import { ContextProviderDescription, InputModifiers } from "core"; import { rifWithContentsToContextItem } from "core/commands/util"; import { modelSupportsImages } from "core/llm/autodetect"; @@ -71,6 +77,7 @@ import { handleVSCMetaKeyIssues, } from "./handleMetaKeyIssues"; import { ComboBoxItem } from "./types"; +import { MockExtension } from "./FillerExtension"; const InputBoxDiv = styled.div<{ border?: string }>` resize: none; @@ -301,7 +308,7 @@ function TipTapEditor(props: TipTapEditorProps) { const { prevRef, nextRef, addRef } = useInputHistory(props.historyKey); - const editor: Editor = useEditor({ + const editor: Editor | null = useEditor({ extensions: [ Document, History, @@ -392,6 +399,7 @@ function TipTapEditor(props: TipTapEditorProps) { if (isStreamingRef.current) { return true; } + return false; }, "Shift-Enter": () => this.editor.commands.first(({ commands }) => [ @@ -417,6 +425,7 @@ function TipTapEditor(props: TipTapEditorProps) { }, 0); return true; } + return false; }, Escape: () => { if (inDropdownRef.current || !isInEditModeRef.current) { @@ -449,6 +458,7 @@ function TipTapEditor(props: TipTapEditorProps) { }, 0); return true; } + return false; }, }; }, @@ -530,7 +540,7 @@ function TipTapEditor(props: TipTapEditorProps) { return props.node.attrs.label; }, }) - : undefined, + : MockExtension, CodeBlockExtension, ], editorProps: { @@ -562,6 +572,9 @@ function TipTapEditor(props: TipTapEditorProps) { } useEffect(() => { + if (!editor) { + return; + } const placeholder = getPlaceholderText( props.placeholder, historyLengthRef.current, @@ -576,9 +589,9 @@ function TipTapEditor(props: TipTapEditorProps) { useEffect(() => { if (props.isMainInput) { - editor.commands.clearContent(true); + editor?.commands.clearContent(true); } - }, [isInEditMode, props.isMainInput]); + }, [editor, isInEditMode, props.isMainInput]); useEffect(() => { if (editor) { @@ -615,6 +628,10 @@ function TipTapEditor(props: TipTapEditorProps) { * with those key actions. */ const handleKeyDown = async (e: KeyboardEvent) => { + if (!editor) { + return; + } + setActiveKey(e.key); if (!editorFocusedRef?.current || !isMetaEquivalentKeyPressed(e)) return; @@ -632,6 +649,9 @@ function TipTapEditor(props: TipTapEditorProps) { const onEnterRef = useUpdatingRef( (modifiers: InputModifiers) => { + if (!editor) { + return; + } if (isStreaming || isEditModeAndNoCodeToEdit) { return; } @@ -659,7 +679,7 @@ function TipTapEditor(props: TipTapEditorProps) { * commands are redundant, especially the ones inside * useTimeout. */ - editor.commands.focus(); + editor?.commands.focus(); } }, [props.isMainInput, editor]); @@ -679,7 +699,7 @@ function TipTapEditor(props: TipTapEditorProps) { return; } queueMicrotask(() => { - editor.commands.setContent(mainInputContentTrigger); + editor?.commands.setContent(mainInputContentTrigger); }); dispatch(setMainEditorContentTrigger(undefined)); }, [editor, props.isMainInput, mainInputContentTrigger]); @@ -852,7 +872,7 @@ function TipTapEditor(props: TipTapEditorProps) { useWebviewListener( "isContinueInputFocused", async () => { - return props.isMainInput && editorFocusedRef.current; + return props.isMainInput && !!editorFocusedRef.current; }, [editorFocusedRef, props.isMainInput], !props.isMainInput, @@ -902,6 +922,9 @@ function TipTapEditor(props: TipTapEditorProps) { const insertCharacterWithWhitespace = useCallback( (char: string) => { + if (!editor) { + return; + } const text = editor.getText(); if (!text.endsWith(char)) { if (text.length > 0 && !text.endsWith(" ")) { @@ -921,7 +944,7 @@ function TipTapEditor(props: TipTapEditorProps) { onKeyUp={handleKeyUp} className="cursor-text" onClick={() => { - editor && editor.commands.focus(); + editor?.commands.focus(); }} onDragOver={(event) => { event.preventDefault(); @@ -941,6 +964,7 @@ function TipTapEditor(props: TipTapEditorProps) { }} onDrop={(event) => { if ( + !defaultModel || !modelSupportsImages( defaultModel.provider, defaultModel.model, @@ -952,11 +976,17 @@ function TipTapEditor(props: TipTapEditorProps) { } setShowDragOverMsg(false); let file = event.dataTransfer.files[0]; - handleImageFile(file).then(([img, dataUrl]) => { - const { schema } = editor.state; - const node = schema.nodes.image.create({ src: dataUrl }); - const tr = editor.state.tr.insert(0, node); - editor.view.dispatch(tr); + handleImageFile(file).then((result) => { + if (!editor) { + return; + } + if (result) { + const [_, dataUrl] = result; + const { schema } = editor.state; + const node = schema.nodes.image.create({ src: dataUrl }); + const tr = editor.state.tr.insert(0, node); + editor.view.dispatch(tr); + } }); event.preventDefault(); }} @@ -977,13 +1007,19 @@ function TipTapEditor(props: TipTapEditorProps) { onAddSlashCommand={() => insertCharacterWithWhitespace("/")} onEnter={onEnterRef.current} onImageFileSelected={(file) => { - handleImageFile(file).then(([img, dataUrl]) => { - const { schema } = editor.state; - const node = schema.nodes.image.create({ src: dataUrl }); - editor.commands.command(({ tr }) => { - tr.insert(0, node); - return true; - }); + handleImageFile(file).then((result) => { + if (!editor) { + return; + } + if (result) { + const [_, dataUrl] = result; + const { schema } = editor.state; + const node = schema.nodes.image.create({ src: dataUrl }); + editor.commands.command(({ tr }) => { + tr.insert(0, node); + return true; + }); + } }); }} disabled={isStreaming} diff --git a/gui/src/components/modelSelection/ModelSelectionListbox.tsx b/gui/src/components/modelSelection/ModelSelectionListbox.tsx index d043632b9..306f48ede 100644 --- a/gui/src/components/modelSelection/ModelSelectionListbox.tsx +++ b/gui/src/components/modelSelection/ModelSelectionListbox.tsx @@ -17,7 +17,7 @@ import { vscListActiveBackground, vscListActiveForeground, } from ".."; -import { providers } from "../../pages/AddNewModel/configs/providers"; +import { DisplayInfo } from "../../pages/AddNewModel/configs/models"; export const StyledListbox = styled(Listbox)` background-color: ${vscBackground}; @@ -98,11 +98,6 @@ export const StyledListboxOption = styled(Listbox.Option)<{ } `; -interface DisplayInfo { - title: string; - icon?: string; -} - interface ModelSelectionListboxProps { selectedProvider: DisplayInfo; setSelectedProvider: Dispatch>; diff --git a/gui/src/hooks/useSetup.ts b/gui/src/hooks/useSetup.ts index 65d72557c..ee8ced33f 100644 --- a/gui/src/hooks/useSetup.ts +++ b/gui/src/hooks/useSetup.ts @@ -119,10 +119,12 @@ function useSetup() { if (isJetBrains()) { // Save theme colors to local storage for immediate loading in JetBrains ideMessenger.request("jetbrains/getColors", undefined).then((result) => { - Object.keys(result).forEach((key) => { - document.body.style.setProperty(key, result[key]); - document.documentElement.style.setProperty(key, result[key]); - }); + if (result.status === "success") { + Object.entries(result.content).forEach(([key, value]) => { + document.body.style.setProperty(key, value); + document.documentElement.style.setProperty(key, value); + }); + } }); // Tell JetBrains the webview is ready diff --git a/gui/src/pages/AddNewModel/AddNewModel.tsx b/gui/src/pages/AddNewModel/AddNewModel.tsx index 89212e9e3..5b9687537 100644 --- a/gui/src/pages/AddNewModel/AddNewModel.tsx +++ b/gui/src/pages/AddNewModel/AddNewModel.tsx @@ -122,22 +122,24 @@ function AddNewModel() {
- {Object.entries(providers).map(([providerName, modelInfo], i) => ( - { - console.log(`/addModel/provider/${providerName}`); - navigate(`/addModel/provider/${providerName}`); - }} - /> - ))} + {Object.entries(providers).map(([providerName, modelInfo], i) => + modelInfo ? ( + { + console.log(`/addModel/provider/${providerName}`); + navigate(`/addModel/provider/${providerName}`); + }} + /> + ) : null, + )} ) : ( @@ -176,6 +178,9 @@ function AddNewModel() { dimensions={config.dimensions} providerOptions={config.providerOptions} onClick={(e, dimensionChoices, selectedProvider) => { + if (!selectedProvider) { + return; + } const model = { ...config.params, ..._.merge( @@ -187,7 +192,7 @@ function AddNewModel() { }; }) || []), ), - provider: providers[selectedProvider].provider, + provider: providers[selectedProvider]?.provider, }; ideMessenger.post("config/addModel", { model }); dispatch( From 49bda15a2f7063b94392206fa2b25530a9ad1726 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 3 Jan 2025 17:36:37 +0100 Subject: [PATCH 065/114] guinull-chekc-continued --- gui/src/components/FileIcon.tsx | 1 + .../components/BestExperienceConfigForm.tsx | 6 ++-- .../components/StepContainer/EditActions.tsx | 2 +- .../ToolbarButtonWithTooltip.tsx | 11 +++++-- gui/src/forms/AddModelForm.tsx | 8 ++--- gui/src/pages/AddNewModel/configs/models.ts | 29 ++++++++++--------- .../FunctionSpecificToolCallDiv.tsx | 6 ++-- gui/src/pages/gui/ToolCallDiv/ThreadDiv.tsx | 6 ++-- gui/src/pages/gui/ToolCallDiv/index.tsx | 4 +-- gui/src/redux/thunks/streamNormalInput.ts | 12 ++++---- 10 files changed, 47 insertions(+), 38 deletions(-) diff --git a/gui/src/components/FileIcon.tsx b/gui/src/components/FileIcon.tsx index 995b59be1..6f96e498d 100644 --- a/gui/src/components/FileIcon.tsx +++ b/gui/src/components/FileIcon.tsx @@ -1,3 +1,4 @@ +// @ts-ignore import DOMPurify from "dompurify"; import { useMemo } from "react"; import { themeIcons } from "seti-file-icons"; diff --git a/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx b/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx index 7e81bdf04..575e1e8a3 100644 --- a/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx +++ b/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx @@ -1,6 +1,6 @@ import { CubeIcon } from "@heroicons/react/24/outline"; import { DEFAULT_CHAT_MODEL_CONFIG } from "core/config/default"; -import { useContext, useState } from "react"; +import { FormEventHandler, useContext, useState } from "react"; import { useDispatch } from "react-redux"; import { Button, Input, InputSubtext, lightGray } from "../.."; import { IdeMessengerContext } from "../../../context/IdeMessenger"; @@ -33,7 +33,7 @@ function BestExperienceConfigForm({ const [autocompleteApiKey, setAutocompleteApiKey] = useState(""); const [chatApiKey, setChatApiKey] = useState(""); - async function handleSubmit(e) { + const handleSubmit: FormEventHandler = async (e) => { e.preventDefault(); const chatModelConfig = { @@ -74,7 +74,7 @@ function BestExperienceConfigForm({ } onComplete(); - } + }; return (
diff --git a/gui/src/components/StepContainer/EditActions.tsx b/gui/src/components/StepContainer/EditActions.tsx index bd1f1f5d9..d40ed72b9 100644 --- a/gui/src/components/StepContainer/EditActions.tsx +++ b/gui/src/components/StepContainer/EditActions.tsx @@ -36,7 +36,7 @@ export default function EditActions({ index, item }: EditActionsProps) { // const isCurCheckpoint = Math.floor(index / 2) === curCheckpointIndex; const hasPendingApplies = pendingApplyStates.length > 0; - if (isStreaming) return; + if (isStreaming) return null; return (
void; + children: ReactNode; + tooltipContent: string; +} + export function ToolbarButtonWithTooltip({ onClick, children, tooltipContent, -}) { +}: ToolbarButtonWithTooltipProps) { const tooltipId = useMemo( () => `tooltip-${Math.random().toString(36).slice(2, 11)}`, [], diff --git a/gui/src/forms/AddModelForm.tsx b/gui/src/forms/AddModelForm.tsx index 572251fd6..021014a7b 100644 --- a/gui/src/forms/AddModelForm.tsx +++ b/gui/src/forms/AddModelForm.tsx @@ -78,13 +78,13 @@ function AddModelForm({ } const required = selectedProvider.collectInputFor - .filter((input) => input.required) + ?.filter((input) => input.required) .map((input) => { const value = formMethods.watch(input.key); return value; }); - return !required.every((value) => value !== undefined && value.length > 0); + return !required?.every((value) => value !== undefined && value.length > 0); } useEffect(() => { @@ -94,8 +94,8 @@ function AddModelForm({ function onSubmit() { const apiKey = formMethods.watch("apiKey"); const hasValidApiKey = apiKey !== undefined && apiKey !== ""; - const reqInputFields = {}; - for (let input of selectedProvider.collectInputFor) { + const reqInputFields: Record = {}; + for (let input of selectedProvider.collectInputFor ?? []) { reqInputFields[input.key] = formMethods.watch(input.key); } diff --git a/gui/src/pages/AddNewModel/configs/models.ts b/gui/src/pages/AddNewModel/configs/models.ts index a9802ef12..d1ce4e071 100644 --- a/gui/src/pages/AddNewModel/configs/models.ts +++ b/gui/src/pages/AddNewModel/configs/models.ts @@ -9,9 +9,13 @@ export interface PackageDimension { description: string; options: { [key: string]: { [key: string]: any } }; } -export interface ModelPackage { + +export interface DisplayInfo { title: string; icon?: string; +} + +export interface ModelPackage extends DisplayInfo { collectInputFor?: InputDescriptor[]; description: string; refUrl?: string; @@ -70,7 +74,7 @@ export const models: { [key: string]: ModelPackage } = { "sambanova", "cerebras", "nebius", - "scaleway" + "scaleway", ], isOpenSource: true, }, @@ -1085,8 +1089,7 @@ export const models: { [key: string]: ModelPackage } = { }, asksagegpt35gov: { title: "GPT-3.5-Turbo gov", - description: - "U.S. Government. Inexpensive and good ROI.", + description: "U.S. Government. Inexpensive and good ROI.", params: { model: "gpt-gov", contextLength: 8096, @@ -1122,7 +1125,7 @@ export const models: { [key: string]: ModelPackage } = { contextLength: 8_192, title: "GPT-4", }, - providerOptions: ["openai",], + providerOptions: ["openai"], icon: "openai.png", isOpenSource: false, }, @@ -1135,7 +1138,7 @@ export const models: { [key: string]: ModelPackage } = { contextLength: 32_768, title: "GPT-4-32k", }, - providerOptions: ["openai",], + providerOptions: ["openai"], icon: "openai.png", isOpenSource: false, }, @@ -1148,7 +1151,7 @@ export const models: { [key: string]: ModelPackage } = { contextLength: 128_000, title: "GPT-o1", systemMessage: - "You are an expert software developer. You give helpful and concise responses.", + "You are an expert software developer. You give helpful and concise responses.", }, providerOptions: ["askSage"], icon: "openai.png", @@ -1163,7 +1166,7 @@ export const models: { [key: string]: ModelPackage } = { contextLength: 128_000, title: "GPT-o1-mini", systemMessage: - "You are an expert software developer. You give helpful and concise responses.", + "You are an expert software developer. You give helpful and concise responses.", }, providerOptions: ["askSage"], icon: "openai.png", @@ -1178,7 +1181,7 @@ export const models: { [key: string]: ModelPackage } = { contextLength: 200_000, title: "Claude 3.5 Sonnet gov", systemMessage: - "You are an expert software developer. You give helpful and concise responses.", + "You are an expert software developer. You give helpful and concise responses.", }, providerOptions: ["askSage"], icon: "anthropic.png", @@ -1186,8 +1189,7 @@ export const models: { [key: string]: ModelPackage } = { }, asksagegroqllama33: { title: "Llama 3.3", - description: - "Llama-3.3 is a large language model customized by Groq.", + description: "Llama-3.3 is a large language model customized by Groq.", params: { title: "Llama 3.3", model: "groq-llama33", @@ -1198,8 +1200,7 @@ export const models: { [key: string]: ModelPackage } = { }, asksagegroq70b: { title: "Groq-70B", - description: - "A large language model customized by Groq.", + description: "A large language model customized by Groq.", params: { title: "Groq-70B", model: "groq-70b", @@ -1244,7 +1245,7 @@ export const models: { [key: string]: ModelPackage } = { }, icon: "qwen.png", providerOptions: ["scaleway"], - isOpenSource: true, + isOpenSource: true, }, grokBeta: { title: "Grok Beta", diff --git a/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx b/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx index be4905398..52b41f505 100644 --- a/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx +++ b/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx @@ -1,4 +1,4 @@ -import { ToolCall, ToolCallState } from "core"; +import { ToolCall, ToolCallDelta, ToolCallState } from "core"; import { CreateFile } from "./CreateFile"; import { RunTerminalCommand } from "./RunTerminalCommand"; @@ -6,12 +6,12 @@ function FunctionSpecificToolCallDiv({ toolCall, toolCallState, }: { - toolCall: ToolCall; + toolCall: ToolCallDelta; toolCallState: ToolCallState; }) { const args = toolCallState.parsedArgs; - switch (toolCall.function.name) { + switch (toolCall.function?.name) { case "builtin_create_new_file": return ( props.toolCall.function.name === tool.function.name, + (tool) => props.toolCall.function?.name === tool.function.name, ), props.toolCallState, )} diff --git a/gui/src/pages/gui/ToolCallDiv/index.tsx b/gui/src/pages/gui/ToolCallDiv/index.tsx index fdc16f6ae..9e3e1fc0f 100644 --- a/gui/src/pages/gui/ToolCallDiv/index.tsx +++ b/gui/src/pages/gui/ToolCallDiv/index.tsx @@ -3,14 +3,14 @@ import { CheckIcon, XMarkIcon, } from "@heroicons/react/24/outline"; -import { ToolCall, ToolCallState, ToolStatus } from "core"; +import { ToolCall, ToolCallDelta, ToolCallState, ToolStatus } from "core"; import { vscButtonBackground } from "../../../components"; import Spinner from "../../../components/gui/Spinner"; import FunctionSpecificToolCallDiv from "./FunctionSpecificToolCallDiv"; import { ThreadDiv } from "./ThreadDiv"; interface ToolCallDivProps { - toolCall: ToolCall; + toolCall: ToolCallDelta; toolCallState: ToolCallState; } diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index 6eed3ddb1..ee1d8167a 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -32,18 +32,18 @@ export const streamNormalInput = createAsyncThunk< defaultModel.title, streamAborter.signal, messages, - { - tools: useTools - ? Object.keys(toolSettings) + useTools + ? { + tools: Object.keys(toolSettings) .filter((tool) => toolSettings[tool] !== "disabled") .map((toolName) => state.config.config.tools.find( (tool) => tool.function.name === toolName, ), ) - .filter((tool) => !!tool) - : undefined, - }, + .filter((tool) => !!tool), + } + : {}, ); // Stream response From eccff7ba08fadc21e6e25f7f9463f74915fe1853 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 3 Jan 2025 18:21:05 +0100 Subject: [PATCH 066/114] gui strict null checks part 17 --- gui/src/components/markdown/utils.ts | 2 +- .../modelSelection/ModelSelectionListbox.tsx | 12 +++++++++--- gui/src/forms/AddModelForm.tsx | 3 ++- gui/src/pages/AddNewModel/configs/models.ts | 4 +++- gui/src/pages/AddNewModel/configs/providers.ts | 3 ++- gui/src/redux/slices/sessionSlice.ts | 2 +- gui/src/redux/thunks/streamNormalInput.ts | 3 ++- 7 files changed, 20 insertions(+), 9 deletions(-) diff --git a/gui/src/components/markdown/utils.ts b/gui/src/components/markdown/utils.ts index 9435abe47..d34044089 100644 --- a/gui/src/components/markdown/utils.ts +++ b/gui/src/components/markdown/utils.ts @@ -37,7 +37,7 @@ export function isTerminalCodeBlock( ); } -function childToText(child: any) { +function childToText(child: any): string { if (typeof child === "string") { return child; } else if (child?.props) { diff --git a/gui/src/components/modelSelection/ModelSelectionListbox.tsx b/gui/src/components/modelSelection/ModelSelectionListbox.tsx index 306f48ede..0fc8e7dee 100644 --- a/gui/src/components/modelSelection/ModelSelectionListbox.tsx +++ b/gui/src/components/modelSelection/ModelSelectionListbox.tsx @@ -17,7 +17,11 @@ import { vscListActiveBackground, vscListActiveForeground, } from ".."; -import { DisplayInfo } from "../../pages/AddNewModel/configs/models"; +import { + DisplayInfo, + ModelPackage, +} from "../../pages/AddNewModel/configs/models"; +import { ProviderInfo } from "../../pages/AddNewModel/configs/providers"; export const StyledListbox = styled(Listbox)` background-color: ${vscBackground}; @@ -99,8 +103,10 @@ export const StyledListboxOption = styled(Listbox.Option)<{ `; interface ModelSelectionListboxProps { - selectedProvider: DisplayInfo; - setSelectedProvider: Dispatch>; + selectedProvider: DisplayInfo | ProviderInfo | ModelPackage; + setSelectedProvider: Dispatch< + SetStateAction + >; topOptions?: DisplayInfo[]; otherOptions?: DisplayInfo[]; } diff --git a/gui/src/forms/AddModelForm.tsx b/gui/src/forms/AddModelForm.tsx index 021014a7b..ac535d862 100644 --- a/gui/src/forms/AddModelForm.tsx +++ b/gui/src/forms/AddModelForm.tsx @@ -53,7 +53,8 @@ function AddModelForm({ const allProviders = Object.entries(providers) .filter(([key]) => !["freetrial", "openai-aiohttp"].includes(key)) .map(([, provider]) => provider) - .filter((provider) => !!provider); + .filter((provider) => !!provider) + .map((provider) => provider!); // for type checking const popularProviders = allProviders .filter((provider) => popularProviderTitles.includes(provider.title)) diff --git a/gui/src/pages/AddNewModel/configs/models.ts b/gui/src/pages/AddNewModel/configs/models.ts index d1ce4e071..ab469f130 100644 --- a/gui/src/pages/AddNewModel/configs/models.ts +++ b/gui/src/pages/AddNewModel/configs/models.ts @@ -15,7 +15,9 @@ export interface DisplayInfo { icon?: string; } -export interface ModelPackage extends DisplayInfo { +export interface ModelPackage { + title: string; + icon?: string; collectInputFor?: InputDescriptor[]; description: string; refUrl?: string; diff --git a/gui/src/pages/AddNewModel/configs/providers.ts b/gui/src/pages/AddNewModel/configs/providers.ts index f3d3a9ccb..94da86ef2 100644 --- a/gui/src/pages/AddNewModel/configs/providers.ts +++ b/gui/src/pages/AddNewModel/configs/providers.ts @@ -165,7 +165,8 @@ export const providers: Partial> = { title: "Scaleway", provider: "scaleway", refPage: "scaleway", - description: "Use the Scaleway Generative APIs to instantly access leading open models", + description: + "Use the Scaleway Generative APIs to instantly access leading open models", longDescription: `Hosted in European data centers, ideal for developers requiring low latency, full data privacy, and compliance with EU AI Act. You can generate your API key in [Scaleway's console](https://console.scaleway.com/generative-api/models). Get started:\n1. Create an API key [here](https://console.scaleway.com/iam/api-keys/)\n2. Paste below\n3. Select a model preset`, params: { apiKey: "", diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 2ad3ee89e..04b4ed9f4 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -306,7 +306,7 @@ export const sessionSlice = createSlice({ ); historyItem.toolCallState = { status: "generating", - toolCall: message.toolCalls[0] as ToolCall, + toolCall: message.toolCalls[0], toolCallId: message.toolCalls[0].id, parsedArgs, }; diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index ee1d8167a..d37575ce2 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -41,7 +41,8 @@ export const streamNormalInput = createAsyncThunk< (tool) => tool.function.name === toolName, ), ) - .filter((tool) => !!tool), + .filter((tool) => !!tool) + .map((tool) => tool!), // for type safety } : {}, ); From 9d59ebdc7bf70484e03910902cc70d88cea8813d Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 3 Jan 2025 18:21:20 +0100 Subject: [PATCH 067/114] almost there --- core/protocol/ideWebview.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/protocol/ideWebview.ts b/core/protocol/ideWebview.ts index 4ca7b0574..586afedf4 100644 --- a/core/protocol/ideWebview.ts +++ b/core/protocol/ideWebview.ts @@ -43,7 +43,7 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { vscMediaUrl: string; }, ]; - "jetbrains/getColors": [undefined, void]; + "jetbrains/getColors": [undefined, Record]; "vscode/openMoveRightMarkdown": [undefined, void]; setGitHubAuthToken: [{ token: string }, void]; acceptDiff: [{ filepath: string; streamId?: string }, void]; From f2820feca92490a4eff42aa6773dec2f6de471bd Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 3 Jan 2025 13:45:24 -0500 Subject: [PATCH 068/114] add env option to MCP --- core/context/mcp/index.ts | 1 + core/index.d.ts | 1 + extensions/vscode/config_schema.json | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/core/context/mcp/index.ts b/core/context/mcp/index.ts index e214b1e02..26be2f471 100644 --- a/core/context/mcp/index.ts +++ b/core/context/mcp/index.ts @@ -72,6 +72,7 @@ class MCPConnection { return new StdioClientTransport({ command: options.transport.command, args: options.transport.args, + env: options.transport.env, }); case "websocket": return new WebSocketClientTransport(new URL(options.transport.url)); diff --git a/core/index.d.ts b/core/index.d.ts index d916a19f1..2d7622895 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -940,6 +940,7 @@ export interface StdioOptions { type: "stdio"; command: string; args: string[]; + env?: Record; } export interface WebSocketOptions { diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index c9df4e976..c0ffddd3a 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -3151,6 +3151,13 @@ "items": { "type": "string" } + }, + "env": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Environment variables to pass to the command" } }, "required": ["type", "command", "args"] From efd3b7bf715f16cd29f2825e0e3d84f871829e63 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 3 Jan 2025 13:55:06 -0500 Subject: [PATCH 069/114] fix merge conflicts --- core/indexing/docs/DocsService.ts | 2 -- gui/src/components/dialogs/AddDocsDialog.tsx | 16 ++++++++-------- gui/src/redux/slices/configSlice.ts | 14 ++++++++++++-- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index 3d9cb0fd7..1696466dc 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -18,8 +18,6 @@ import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbed import { FromCoreProtocol, ToCoreProtocol } from "../../protocol"; import { IMessenger } from "../../protocol/messenger"; import { fetchFavicon, getFaviconBase64 } from "../../util/fetchFavicon"; -import { IMessenger } from "../../protocol/messenger"; -import { GlobalContext } from "../../util/GlobalContext"; import { editConfigJson, getDocsSqlitePath, diff --git a/gui/src/components/dialogs/AddDocsDialog.tsx b/gui/src/components/dialogs/AddDocsDialog.tsx index f816369c8..01f924425 100644 --- a/gui/src/components/dialogs/AddDocsDialog.tsx +++ b/gui/src/components/dialogs/AddDocsDialog.tsx @@ -5,19 +5,19 @@ import { PlusIcon, } from "@heroicons/react/24/outline"; import { IndexingStatus, PackageDocsResult, SiteIndexingConfig } from "core"; +import preIndexedDocs from "core/indexing/docs/preIndexedDocs"; import { usePostHog } from "posthog-js/react"; import { useContext, useLayoutEffect, useMemo, useRef, useState } from "react"; import { useDispatch } from "react-redux"; import { Input, SecondaryButton } from ".."; import { IdeMessengerContext } from "../../context/IdeMessenger"; -import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice"; -import { ToolTip } from "../gui/Tooltip"; -import FileIcon from "../FileIcon"; -import DocsIndexingPeeks from "../indexing/DocsIndexingPeeks"; -import preIndexedDocs from "core/indexing/docs/preIndexedDocs"; -import { updateIndexingStatus } from "../../redux/slices/indexingSlice"; import { useAppSelector } from "../../redux/hooks"; -import { setConfig } from "../../redux/slices/configSlice"; +import { updateConfig } from "../../redux/slices/configSlice"; +import { updateIndexingStatus } from "../../redux/slices/indexingSlice"; +import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice"; +import FileIcon from "../FileIcon"; +import { ToolTip } from "../gui/Tooltip"; +import DocsIndexingPeeks from "../indexing/DocsIndexingPeeks"; function AddDocsDialog() { const config = useAppSelector((store) => store.config.config); @@ -146,7 +146,7 @@ function AddDocsDialog() { // Optimistic status update dispatch( - setConfig({ + updateConfig({ ...config, docs: [ ...(config.docs?.filter( diff --git a/gui/src/redux/slices/configSlice.ts b/gui/src/redux/slices/configSlice.ts index 35e530e47..99401fe05 100644 --- a/gui/src/redux/slices/configSlice.ts +++ b/gui/src/redux/slices/configSlice.ts @@ -55,6 +55,12 @@ export const configSlice = createSlice({ state.config = config; state.defaultModelTitle = defaultModelTitle; }, + updateConfig: ( + state, + { payload: config }: PayloadAction, + ) => { + state.config = config; + }, setConfigError: ( state, { payload: error }: PayloadAction, @@ -93,8 +99,12 @@ export const configSlice = createSlice({ }, }); -export const { setDefaultModel, setConfigResult, setConfigError } = - configSlice.actions; +export const { + setDefaultModel, + updateConfig, + setConfigResult, + setConfigError, +} = configSlice.actions; export const { selectDefaultModel, From 9fdd9a53484e73b6cf72da98b39365c348f51800 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 3 Jan 2025 14:28:29 -0500 Subject: [PATCH 070/114] bump --- extensions/vscode/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 550ed3538..08cb25e3a 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "0.9.248", + "version": "0.9.249", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From 5b31f75e5a35e20bb34b5db8cefe83e3464905cf Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 3 Jan 2025 20:36:09 +0100 Subject: [PATCH 071/114] symbols working for codeblock toolbars --- .../markdown/StyledMarkdownPreview.tsx | 28 +------------- gui/src/redux/thunks/updateFileSymbols.ts | 38 +++++++++++++++++-- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/gui/src/components/markdown/StyledMarkdownPreview.tsx b/gui/src/components/markdown/StyledMarkdownPreview.tsx index 92b09458a..dfe9d9ef0 100644 --- a/gui/src/components/markdown/StyledMarkdownPreview.tsx +++ b/gui/src/components/markdown/StyledMarkdownPreview.tsx @@ -29,6 +29,7 @@ import { selectUIConfig } from "../../redux/slices/configSlice"; import { ToolTip } from "../gui/Tooltip"; import { v4 as uuidv4 } from "uuid"; import { ContextItemWithId, RangeInFileWithContents } from "core"; +import { getContextItemsFromHistory } from "../../redux/thunks/updateFileSymbols"; const StyledMarkdown = styled.div<{ fontSize?: number; @@ -154,32 +155,7 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( rifs: [], }; } - const pastHistoryItems = history.filter((_, i) => i <= index); - - const pastNormalContextItems = pastHistoryItems.flatMap((item) => { - return ( - item.contextItems?.filter( - (item) => item.uri?.type === "file" && item.uri?.value, - ) ?? [] - ); - }); - - const pastToolbarContextItems: ContextItemWithId[] = pastHistoryItems - .filter((item) => item.editorState && Array.isArray(item.editorState)) - .flatMap((item) => item.editorState) - .filter( - (content) => - content?.type === "codeBlock" && - content?.attrs?.item && - content.attrs.item.uri?.type === "file" && - content.attrs.item.uri?.value, - ) - .map((content) => content.attrs!.item!); - - const pastContextItems = [ - ...pastNormalContextItems, - ...pastToolbarContextItems, - ]; + const pastContextItems = getContextItemsFromHistory(history, index); const rifs = pastContextItems.map((item) => ctxItemToRifWithContents(item, true), ); diff --git a/gui/src/redux/thunks/updateFileSymbols.ts b/gui/src/redux/thunks/updateFileSymbols.ts index 6ddc28a04..05396c3ed 100644 --- a/gui/src/redux/thunks/updateFileSymbols.ts +++ b/gui/src/redux/thunks/updateFileSymbols.ts @@ -1,7 +1,38 @@ import { createAsyncThunk } from "@reduxjs/toolkit"; import { ThunkApiType } from "../store"; import { updateFileSymbols } from "../slices/sessionSlice"; -import { ContextItemWithId, RangeInFile } from "core"; +import { ChatHistoryItem, ContextItemWithId } from "core"; + +export function getContextItemsFromHistory( + historyItems: ChatHistoryItem[], + priorToIndex?: number, +) { + const pastHistoryItems = historyItems.filter( + (_, i) => i <= (priorToIndex ?? historyItems.length - 1), + ); + + const pastNormalContextItems = pastHistoryItems.flatMap((item) => { + return ( + item.contextItems?.filter( + (item) => item.uri?.type === "file" && item.uri?.value, + ) ?? [] + ); + }); + const pastToolbarContextItems: ContextItemWithId[] = pastHistoryItems + .filter( + (item) => item.editorState && Array.isArray(item.editorState.content), + ) + .flatMap((item) => item.editorState.content) + .filter( + (content) => + content?.type === "codeBlock" && + content?.attrs?.item?.uri?.value && + content.attrs.item.uri?.type === "file", + ) + .map((content) => content.attrs!.item!); + + return [...pastNormalContextItems, ...pastToolbarContextItems]; +} /* Get file symbols for given context items @@ -48,9 +79,8 @@ export const updateFileSymbolsFromHistory = createAsyncThunk< const state = getState(); // Get unique context item file uris from all history - const contextItems = state.session.history.flatMap( - (item) => item.contextItems, - ); + const contextItems = getContextItemsFromHistory(state.session.history); + const uniqueUris = new Set( contextItems .filter((item) => item.uri?.type === "file" && item?.uri?.value) From a0eb5bba93933dd112f9e38b1310d8ddca92b7b1 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 3 Jan 2025 15:38:07 -0500 Subject: [PATCH 072/114] remove authentication provider registration to avoid inability to disable extension per workspace --- extensions/vscode/package.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 08cb25e3a..0d37aa237 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -57,12 +57,6 @@ ], "main": "./out/extension.js", "contributes": { - "authentication": [ - { - "id": "continue", - "label": "Continue" - } - ], "languages": [ { "filenames": [ From 064749116463f63bac47223e18eda0a13b750775 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 3 Jan 2025 22:54:03 -0500 Subject: [PATCH 073/114] don't show all webview message errors --- extensions/vscode/src/webviewProtocol.ts | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/extensions/vscode/src/webviewProtocol.ts b/extensions/vscode/src/webviewProtocol.ts index 0632d44b9..fea6a3e8e 100644 --- a/extensions/vscode/src/webviewProtocol.ts +++ b/extensions/vscode/src/webviewProtocol.ts @@ -1,7 +1,7 @@ import { FromWebviewProtocol, ToWebviewProtocol } from "core/protocol"; +import { Message } from "core/protocol/messenger"; import { WebviewMessengerResult } from "core/protocol/util"; import { extractMinimalStackTraceInfo } from "core/util/extractMinimalStackTraceInfo"; -import { Message } from "core/protocol/messenger"; import { Telemetry } from "core/util/posthog"; import { v4 as uuidv4 } from "uuid"; import * as vscode from "vscode"; @@ -140,25 +140,6 @@ export class VsCodeWebviewProtocol }, false, ); - vscode.window - .showErrorMessage( - message.split("\n\n")[0], - "Show Logs", - "Troubleshooting", - ) - .then((selection) => { - if (selection === "Show Logs") { - vscode.commands.executeCommand( - "workbench.action.toggleDevTools", - ); - } else if (selection === "Troubleshooting") { - vscode.env.openExternal( - vscode.Uri.parse( - "https://docs.continue.dev/troubleshooting", - ), - ); - } - }); } } } From 723a75ca00e641a9ed6758f55ec6d0ef9ea6fe34 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 3 Jan 2025 22:55:16 -0500 Subject: [PATCH 074/114] bump --- extensions/vscode/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 08cb25e3a..4d4b2b8c7 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "0.9.249", + "version": "0.9.250", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From 04a3b5c3715e15c95a1c3eaa9a3c4d0f6acf3f70 Mon Sep 17 00:00:00 2001 From: Akshay Gulabrao Date: Sat, 4 Jan 2025 01:20:21 -0800 Subject: [PATCH 075/114] Update cohere.md for reranking, json is expecting name not provider --- docs/docs/customize/model-providers/more/cohere.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/customize/model-providers/more/cohere.md b/docs/docs/customize/model-providers/more/cohere.md index 24f2a7f88..8a1f069a6 100644 --- a/docs/docs/customize/model-providers/more/cohere.md +++ b/docs/docs/customize/model-providers/more/cohere.md @@ -46,7 +46,7 @@ We recommend configuring **rerank-english-v3.0** as your reranking model. ```json title="config.json" { "reranker": { - "provider": "cohere", + "name": "cohere", "params": { "model": "rerank-english-v3.0", "apiKey": "" From 41357cd00c72b61cd54b80aa3963d047c0bb4184 Mon Sep 17 00:00:00 2001 From: liuk Date: Sat, 4 Jan 2025 19:38:39 +0800 Subject: [PATCH 076/114] fix: Clear all diff blocks before streaming and ensure dispose is run on EDT - Clear all diff blocks before running the diff stream. - Ensure that inlay executes dispose on the Event Dispatch Thread (EDT). --- .../continue/IdeProtocolClient.kt | 5 ++++- .../editor/VerticalDiffBlock.kt | 11 ++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt index b4078beea..5921300cf 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt @@ -469,6 +469,10 @@ class IdeProtocolClient( } + val diffStreamService = project.service() + // Clear all diff blocks before running the diff stream + diffStreamService.reject(editor) + val llmTitle = (llm as? Map<*, *>)?.get("title") as? String ?: "" val prompt = @@ -501,7 +505,6 @@ class IdeProtocolClient( rif?.range?.end?.line ?: (editor.document.lineCount - 1), {}, {}) - val diffStreamService = project.service() diffStreamService.register(diffStreamHandler, editor) diffStreamHandler.streamDiffLinesToEditor( diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffBlock.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffBlock.kt index 64f1d1bb7..6f311c29b 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffBlock.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffBlock.kt @@ -3,6 +3,7 @@ package com.github.continuedev.continueintellijextension.editor import com.github.continuedev.continueintellijextension.utils.getAltKeyLabel import com.github.continuedev.continueintellijextension.utils.getShiftKeyLabel import com.intellij.openapi.Disposable +import com.intellij.openapi.application.invokeLater import com.intellij.openapi.command.WriteCommandAction import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.LogicalPosition @@ -11,6 +12,7 @@ import com.intellij.openapi.editor.markup.HighlighterLayer import com.intellij.openapi.project.Project import com.intellij.openapi.util.TextRange import com.intellij.ui.JBColor +import com.intellij.util.application import java.awt.* import javax.swing.BorderFactory import javax.swing.JButton @@ -41,7 +43,14 @@ class VerticalDiffBlock( } fun clearEditorUI() { - deletionInlay?.dispose() + deletionInlay?.let { + // Ensure that dispose is executed on EDT + if (application.isDispatchThread) { + it.dispose() + } else { + invokeLater { it.dispose() } + } + } removeGreenHighlighters() removeButtons() } From 1fb430ddb3c1685ee8608981c9a3aea6bacf8eef Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Sat, 4 Jan 2025 18:59:17 +0100 Subject: [PATCH 077/114] convert config json to file url for local config --- core/config/ConfigHandler.ts | 3 ++- core/tools/implementations/createNewFile.ts | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index 9ef3cc8d2..2c91148ba 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -25,6 +25,7 @@ import { ProfileDescription, ProfileLifecycleManager, } from "./ProfileLifecycleManager.js"; +import { pathToFileURL } from "url"; export type { ProfileDescription }; @@ -88,7 +89,7 @@ export class ConfigHandler { async openConfigProfile(profileId?: string) { let openProfileId = profileId || this.selectedProfileId; if (openProfileId === "local") { - await this.ide.openFile(getConfigJsonPath()); + await this.ide.openFile(pathToFileURL(getConfigJsonPath()).toString()); } else { await this.ide.openUrl( "https://app.continue.dev/", diff --git a/core/tools/implementations/createNewFile.ts b/core/tools/implementations/createNewFile.ts index 1b733da01..b5d5e6c1b 100644 --- a/core/tools/implementations/createNewFile.ts +++ b/core/tools/implementations/createNewFile.ts @@ -3,13 +3,13 @@ import { inferResolvedUriFromRelativePath } from "../../util/ideUtils"; import { ToolImpl } from "."; export const createNewFileImpl: ToolImpl = async (args, extras) => { - const resolvedFilepath = await inferResolvedUriFromRelativePath( + const resolvedFileUri = await inferResolvedUriFromRelativePath( args.filepath, extras.ide, ); - if (resolvedFilepath) { - await extras.ide.writeFile(resolvedFilepath, args.contents); - await extras.ide.openFile(resolvedFilepath); + if (resolvedFileUri) { + await extras.ide.writeFile(resolvedFileUri, args.contents); + await extras.ide.openFile(resolvedFileUri); } return []; }; From 26b9315c3afba1042b109c425c808eb4b4784567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20=C3=96berg?= Date: Sat, 4 Jan 2025 22:27:17 +0100 Subject: [PATCH 078/114] Added remote instance configuration --- docs/docs/autocomplete/model-setup.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/docs/docs/autocomplete/model-setup.md b/docs/docs/autocomplete/model-setup.md index 2312123a0..7d8c98944 100644 --- a/docs/docs/autocomplete/model-setup.md +++ b/docs/docs/autocomplete/model-setup.md @@ -5,6 +5,10 @@ keywords: [model, autocomplete] sidebar_position: 2 --- +:::info +This page recommends models and providers for Autocomplete. Read more about how to set up your `config.json` [here](../reference.md). +::: + ## Best overall experience For the best Autocomplete experience, we recommend using Codestral through the [Mistral API](https://console.mistral.ai/). This model offers high-quality completions with an excellent understanding of code context: @@ -26,7 +30,7 @@ The API keys for Codestral and the general Mistral APIs are different. If you ar ## Local, offline / self-hosted experience -For those preferring local execution or self-hosting,`Qwen2.5-Coder 1.5B` offers a good balance of performance and quality for most users: +For those preferring local execution or self-hosting,`Qwen2.5-Coder 1.5B` offers a good balance of performance and quality for most users (e.g. using [Ollama](../customize/model-providers/top-level/ollama.md) or [LM Studio](../customize/model-providers/more/lmstudio.md)). ```json title="config.json"" { @@ -45,7 +49,20 @@ Have more compute? Use `qwen2.5-coder:7b-base` for potentially higher-quality su For LM Studio users, navigate to the "My Models" section, find your desired model, and copy the path (e.g., `Qwen/Qwen2.5-Coder-1.5B-Instruct-GGUF/qwen2.5-coder-1.5b-instruct-q4_k_m.gguf`). Use this path as the `model` value in your configuration. ::: +### Using a remote instance +When using a remote instance you need to set the `"apiBase"` value in the configuration: + +```json title="config.json"" +{ + "tabAutocompleteModel": { + "title": "Qwen2.5-Coder 1.5B", + "model": "qwen2.5-coder:1.5b-base", + "provider": "ollama" + "apiBase": "http://:11434" + } +} +``` ## Other experiences -There are many more models and providers you can use with Autocomplete. Check them out [here](../customize/model-types/autocomplete.md). +There are many more models and providers you can use with Autocomplete. Check them out [here](../customize/model-types/autocomplete.md). You can also see more examples of Autocomplete configuration [here](../customize/deep-dives/autocomplete.md) From 69b5d07e05b982f03eca29357d9a039e9ef3aff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20=C3=96berg?= Date: Sat, 4 Jan 2025 22:47:56 +0100 Subject: [PATCH 079/114] Added example of remote instance configuration --- .../model-providers/top-level/ollama.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/docs/customize/model-providers/top-level/ollama.md b/docs/docs/customize/model-providers/top-level/ollama.md index e1f3e53e8..d4ab43003 100644 --- a/docs/docs/customize/model-providers/top-level/ollama.md +++ b/docs/docs/customize/model-providers/top-level/ollama.md @@ -53,3 +53,20 @@ We recommend configuring **Nomic Embed Text** as your embeddings model. Ollama currently does not offer any reranking models. [Click here](../../model-types/reranking.md) to see a list of reranking model providers. + +## Setting up a remote instance + +To configure a remote instance of Ollama, add the `"apiBase"` property to your model in config.json: + +```json title="config.json" +{ + "models": [ + { + "title": "Llama3.1 8B", + "provider": "ollama", + "model": "llama3.1:8b" + "apiBase": "http://:11434" + } + ] +} +``` From 9a9e43d0846121d7b5716895e766571a698a51ce Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Sun, 5 Jan 2025 14:51:17 +0100 Subject: [PATCH 080/114] revert idemessenger --- extensions/vscode/package-lock.json | 4 ++-- gui/src/context/IdeMessenger.ts | 12 ++++-------- gui/src/forms/AddModelForm.tsx | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index c6db7f103..389aeae95 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.248", + "version": "0.9.250", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.248", + "version": "0.9.250", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", diff --git a/gui/src/context/IdeMessenger.ts b/gui/src/context/IdeMessenger.ts index 46bc92538..76881e9a7 100644 --- a/gui/src/context/IdeMessenger.ts +++ b/gui/src/context/IdeMessenger.ts @@ -164,22 +164,18 @@ export class IdeMessenger implements IIdeMessenger { messageType: T, data: FromWebviewProtocol[T][0], cancelToken?: AbortSignal, - ): AsyncGenerator { + ): AsyncGenerator { + // ): FromWebviewProtocol[T][1] { const messageId = uuidv4(); this.post(messageType, data, messageId); - const buffer: FromWebviewProtocol[T][1][] = []; + const buffer: any[] = []; let index = 0; let done = false; let returnVal = undefined; - const handler = (event: { - data: Message<{ - done: boolean; - content: FromWebviewProtocol[T][1]; - }>; - }) => { + const handler = (event: { data: Message }) => { if (event.data.messageId === messageId) { const responseData = event.data.data; if (responseData.done) { diff --git a/gui/src/forms/AddModelForm.tsx b/gui/src/forms/AddModelForm.tsx index ac535d862..7b25e5997 100644 --- a/gui/src/forms/AddModelForm.tsx +++ b/gui/src/forms/AddModelForm.tsx @@ -186,7 +186,7 @@ function AddModelForm({ From 2d3af82ad742c98030bb7f451bb149c467a09c6f Mon Sep 17 00:00:00 2001 From: Carl Gerlach Date: Mon, 6 Jan 2025 02:04:16 +0800 Subject: [PATCH 081/114] Active file is alt+enter instead of ctrl+alt+enter. Active file is alt+enter instead of ctrl+alt+enter. --- docs/docs/chat/context-selection.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/chat/context-selection.md b/docs/docs/chat/context-selection.md index 7bd8fe927..4ec425e81 100644 --- a/docs/docs/chat/context-selection.md +++ b/docs/docs/chat/context-selection.md @@ -15,7 +15,7 @@ The highlighted code you’ve selected by pressing cmd/ctrl + L< ## Active file -You can include the currently open file as context by pressing cmd + opt + enter (Mac) or ctrl + alt + enter (Windows) when you send your request. +You can include the currently open file as context by pressing cmd + opt + enter (Mac) or alt + enter (Windows) when you send your request at Chat window(Prompt can't be empty). ## Specific file From 98c2b7a39fb0b34fab9ca5b5f265d6ac6da8500e Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Sun, 5 Jan 2025 22:00:36 +0100 Subject: [PATCH 082/114] gui strict null checks finish up --- core/core.ts | 1 - core/protocol/core.ts | 20 +++++++++- core/protocol/messenger/index.ts | 2 +- .../modelSelection/ModelSelectionListbox.tsx | 6 +-- gui/src/context/IdeMessenger.ts | 22 +++++++---- gui/src/forms/AddModelForm.tsx | 24 +++++++++++- gui/src/hooks/useWebviewListener.ts | 2 +- gui/src/pages/gui/Chat.tsx | 2 +- gui/src/redux/slices/sessionSlice.ts | 38 +++++++++++++------ gui/src/redux/thunks/streamNormalInput.ts | 7 ++-- 10 files changed, 89 insertions(+), 35 deletions(-) diff --git a/core/core.ts b/core/core.ts index 4c14fff02..415b621bd 100644 --- a/core/core.ts +++ b/core/core.ts @@ -421,7 +421,6 @@ export class Core { const chunk = next.value; - // @ts-ignore yield { content: chunk }; next = await gen.next(); } diff --git a/core/protocol/core.ts b/core/protocol/core.ts index 3849f2702..19f1942fe 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -23,10 +23,26 @@ import type { } from "../"; import { ConfigResult } from "../config/load"; -export type ProtocolGeneratorType = AsyncGenerator<{ +export type ProtocolGeneratorYield = { done?: boolean; content: T; -}>; +}; +export type ProtocolGeneratorType = AsyncGenerator< + ProtocolGeneratorYield +>; + +export type AsyncGeneratorYieldType = + T extends AsyncGenerator + ? Y extends ProtocolGeneratorYield + ? PR + : never + : never; +// export type AsyncGeneratorReturnType = +// T extends AsyncGenerator +// ? R extends ProtocolGeneratorYield +// ? PR +// : never +// : never; export type OnboardingModes = | "Local" diff --git a/core/protocol/messenger/index.ts b/core/protocol/messenger/index.ts index 8b7245224..dd5519b7f 100644 --- a/core/protocol/messenger/index.ts +++ b/core/protocol/messenger/index.ts @@ -2,7 +2,7 @@ import { v4 as uuidv4 } from "uuid"; import type { IProtocol } from "../index"; -export interface Message { +export interface Message { messageType: string; messageId: string; data: T; diff --git a/gui/src/components/modelSelection/ModelSelectionListbox.tsx b/gui/src/components/modelSelection/ModelSelectionListbox.tsx index 0fc8e7dee..aadf4319c 100644 --- a/gui/src/components/modelSelection/ModelSelectionListbox.tsx +++ b/gui/src/components/modelSelection/ModelSelectionListbox.tsx @@ -103,10 +103,8 @@ export const StyledListboxOption = styled(Listbox.Option)<{ `; interface ModelSelectionListboxProps { - selectedProvider: DisplayInfo | ProviderInfo | ModelPackage; - setSelectedProvider: Dispatch< - SetStateAction - >; + selectedProvider: DisplayInfo; + setSelectedProvider: (val: DisplayInfo) => void; topOptions?: DisplayInfo[]; otherOptions?: DisplayInfo[]; } diff --git a/gui/src/context/IdeMessenger.ts b/gui/src/context/IdeMessenger.ts index 76881e9a7..1955f4f4c 100644 --- a/gui/src/context/IdeMessenger.ts +++ b/gui/src/context/IdeMessenger.ts @@ -7,6 +7,10 @@ import { createContext } from "react"; import { v4 as uuidv4 } from "uuid"; import "vscode-webview"; import { isJetBrains } from "../util"; +import { + AsyncGeneratorYieldType, + ProtocolGeneratorYield, +} from "core/protocol/core"; interface vscode { postMessage(message: any): vscode; @@ -164,24 +168,28 @@ export class IdeMessenger implements IIdeMessenger { messageType: T, data: FromWebviewProtocol[T][0], cancelToken?: AbortSignal, - ): AsyncGenerator { - // ): FromWebviewProtocol[T][1] { + ): AsyncGenerator[], any> { + type GenYield = AsyncGeneratorYieldType; + // type GenReturn = AsyncGeneratorReturnType; + const messageId = uuidv4(); this.post(messageType, data, messageId); - const buffer: any[] = []; + const buffer: GenYield[] = []; let index = 0; let done = false; let returnVal = undefined; - const handler = (event: { data: Message }) => { + const handler = (event: { + data: Message>; + }) => { if (event.data.messageId === messageId) { const responseData = event.data.data; if (responseData.done) { window.removeEventListener("message", handler); done = true; - returnVal = responseData; + returnVal = responseData.content; } else { buffer.push(responseData.content); } @@ -239,8 +247,8 @@ export class IdeMessenger implements IIdeMessenger { next = await gen.next(); } - if (next.value.error) { - throw new Error(next.value.error); + if (!next.done) { + throw new Error(); } return { diff --git a/gui/src/forms/AddModelForm.tsx b/gui/src/forms/AddModelForm.tsx index 7b25e5997..e96349f1b 100644 --- a/gui/src/forms/AddModelForm.tsx +++ b/gui/src/forms/AddModelForm.tsx @@ -14,6 +14,7 @@ import { import { FREE_TRIAL_LIMIT_REQUESTS, hasPassedFTL } from "../util/freeTrial"; import { completionParamsInputs } from "../pages/AddNewModel/configs/completionParamsInputs"; import { setDefaultModel } from "../redux/slices/configSlice"; +import { DisplayInfo } from "../pages/AddNewModel/configs/models"; interface QuickModelSetupProps { onDone: () => void; @@ -149,7 +150,14 @@ function AddModelForm({ { + const match = [...popularProviders, ...otherProviders].find( + (provider) => provider.title === val.title, + ); + if (match) { + setSelectedProvider(match); + } + }} topOptions={popularProviders} otherOptions={otherProviders} /> @@ -186,7 +194,19 @@ function AddModelForm({ { + const options = + Object.entries(providers).find( + ([, provider]) => + provider?.title === selectedProvider.title, + )?.[1]?.packages ?? []; + const match = options.find( + (option) => option.title === val.title, + ); + if (match) { + setSelectedModel(match); + } + }} otherOptions={ Object.entries(providers).find( ([, provider]) => diff --git a/gui/src/hooks/useWebviewListener.ts b/gui/src/hooks/useWebviewListener.ts index 4bdd9f5dc..797df3e61 100644 --- a/gui/src/hooks/useWebviewListener.ts +++ b/gui/src/hooks/useWebviewListener.ts @@ -13,7 +13,7 @@ export function useWebviewListener( useEffect( () => { - let listener: (event: { data: Message }) => Promise; + let listener: (event: { data: Message}) => Promise; if (!skip) { listener = async (event) => { diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 0c8e5b696..99c61a71c 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -407,7 +407,7 @@ export function Chat() { return (
diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 04b4ed9f4..6fcb0a622 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -288,7 +288,9 @@ export const sessionSlice = createSlice({ message.role && (lastMessage.role !== message.role || // This is when a tool call comes after assistant text - (lastMessage.content !== "" && message.role === "assistant")) + (lastMessage.content !== "" && + message.role === "assistant" && + message.toolCalls?.length)) ) { // Create a new message const historyItem: ChatHistoryItemWithMessageId = { @@ -302,12 +304,12 @@ export const sessionSlice = createSlice({ const toolCalls = message.toolCalls?.[0]; if (toolCalls) { const [_, parsedArgs] = incrementalParseJson( - message.toolCalls[0].function.arguments, + message.toolCalls[0].function?.arguments ?? "{}", ); historyItem.toolCallState = { status: "generating", - toolCall: message.toolCalls[0], - toolCallId: message.toolCalls[0].id, + toolCall: message.toolCalls[0] as ToolCall, + toolCallId: message.toolCalls[0].id as ToolCall["id"], parsedArgs, }; } @@ -330,16 +332,28 @@ export const sessionSlice = createSlice({ if (lastMessage.toolCalls!.length <= i) { lastMessage.toolCalls!.push(toolCall); } else { - lastMessage.toolCalls[i].function.arguments += - toolCall.function.arguments; + if ( + toolCall?.function?.arguments && + lastMessage?.toolCalls?.[i]?.function?.arguments && + lastItem.toolCallState + ) { + lastMessage.toolCalls[i].function!.arguments += + toolCall.function.arguments; - const [_, parsedArgs] = incrementalParseJson( - lastMessage.toolCalls[i].function.arguments, - ); + const [_, parsedArgs] = incrementalParseJson( + lastMessage.toolCalls[i].function!.arguments!, + ); - lastItem.toolCallState.parsedArgs = parsedArgs; - lastItem.toolCallState.toolCall.function.arguments += - toolCall.function.arguments; + lastItem.toolCallState.parsedArgs = parsedArgs; + lastItem.toolCallState.toolCall.function.arguments += + toolCall.function.arguments; + } else { + console.error( + "Unexpected tool call format received - this message added during gui strict null checks", + message, + lastMessage, + ); + } } }); } diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index d37575ce2..d09a59fa2 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -55,15 +55,14 @@ export const streamNormalInput = createAsyncThunk< break; } - const updates = next.value as ChatMessage[]; + const updates = next.value; dispatch(streamUpdate(updates)); next = await gen.next(); } // Attach prompt log - let returnVal = next.value as PromptLog; - if (returnVal) { - dispatch(addPromptCompletionPair([returnVal])); + if (next.done) { + dispatch(addPromptCompletionPair([next.value])); } // If it's a tool call that is automatically accepted, we should call it From 78fcd97dda81375bae56d4a855cd193f2fffabf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20=C3=96berg?= Date: Mon, 6 Jan 2025 10:55:08 +0100 Subject: [PATCH 083/114] Added remote instance example --- docs/docs/customize/model-providers/top-level/ollama.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/customize/model-providers/top-level/ollama.md b/docs/docs/customize/model-providers/top-level/ollama.md index d4ab43003..d2a4749c0 100644 --- a/docs/docs/customize/model-providers/top-level/ollama.md +++ b/docs/docs/customize/model-providers/top-level/ollama.md @@ -54,7 +54,7 @@ Ollama currently does not offer any reranking models. [Click here](../../model-types/reranking.md) to see a list of reranking model providers. -## Setting up a remote instance +## Using a remote instance To configure a remote instance of Ollama, add the `"apiBase"` property to your model in config.json: From 73a5f206ad02cafb087c4acd5abda84b3ab1651d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20=C3=96berg?= Date: Mon, 6 Jan 2025 10:59:16 +0100 Subject: [PATCH 084/114] fix broken link --- docs/docs/customize/model-providers/more/vllm.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/customize/model-providers/more/vllm.md b/docs/docs/customize/model-providers/more/vllm.md index 72d79c645..37775b7b1 100644 --- a/docs/docs/customize/model-providers/more/vllm.md +++ b/docs/docs/customize/model-providers/more/vllm.md @@ -1,6 +1,6 @@ # vLLM -Run the OpenAI-compatible server by vLLM using `vllm serve`. See their [server documentation](https://docs.vllm.ai/en/latest/serving/openai_compatible_server.html) and the [engine arguments documentation](https://docs.vllm.ai/en/latest/models/engine_args.html). +Run the OpenAI-compatible server by vLLM using `vllm serve`. See their [server documentation](https://docs.vllm.ai/en/latest/serving/openai_compatible_server.html) and the [engine arguments documentation](https://docs.vllm.ai/en/latest/usage/engine_args.html). ```shell vllm serve NousResearch/Meta-Llama-3-8B-Instruct --max-model-len 1024 From 0a3fb194763a55d8e1543dbcbc9fe159e950a703 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 6 Jan 2025 12:50:14 +0100 Subject: [PATCH 085/114] revert to message any type --- core/protocol/messenger/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/protocol/messenger/index.ts b/core/protocol/messenger/index.ts index dd5519b7f..8b7245224 100644 --- a/core/protocol/messenger/index.ts +++ b/core/protocol/messenger/index.ts @@ -2,7 +2,7 @@ import { v4 as uuidv4 } from "uuid"; import type { IProtocol } from "../index"; -export interface Message { +export interface Message { messageType: string; messageId: string; data: T; From 6637dcc729ec61df743fa1718b3c070c4ac32ba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20=C3=96berg?= Date: Mon, 6 Jan 2025 19:31:48 +0100 Subject: [PATCH 086/114] improved vllm docs --- .../customize/model-providers/more/vllm.md | 49 ++++++++++++++++--- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/docs/docs/customize/model-providers/more/vllm.md b/docs/docs/customize/model-providers/more/vllm.md index 37775b7b1..db6554b47 100644 --- a/docs/docs/customize/model-providers/more/vllm.md +++ b/docs/docs/customize/model-providers/more/vllm.md @@ -1,22 +1,59 @@ # vLLM -Run the OpenAI-compatible server by vLLM using `vllm serve`. See their [server documentation](https://docs.vllm.ai/en/latest/serving/openai_compatible_server.html) and the [engine arguments documentation](https://docs.vllm.ai/en/latest/usage/engine_args.html). +vLLM is an open-source library for fast LLM inference which typically is used to serve multiple users at the same due its high performance but it can also be used to run a large model on multiple GPU:s (e.g. when it doesn´t fit in a single GPU). Run their OpenAI-compatible server using `vllm serve`. See their [server documentation](https://docs.vllm.ai/en/latest/serving/openai_compatible_server.html) and the [engine arguments documentation](https://docs.vllm.ai/en/latest/usage/engine_args.html). ```shell -vllm serve NousResearch/Meta-Llama-3-8B-Instruct --max-model-len 1024 +vllm serve meta-llama/Meta-Llama-3.1-8B-Instruct ``` +## Chat model -The continue implementation uses [OpenAI](../top-level/openai.md) under the hood and automatically selects the available model. You only need to set the `apiBase` like this: +We recommend configuring **Llama3.1 8B** as your chat model. ```json title="config.json" { "models": [ { - "title": "My vLLM OpenAI-compatible server", - "apiBase": "http://localhost:8000/v1" + "title": "Llama3.1 8B Instruct", + "provider": "vllm", + "model": "meta-llama/Meta-Llama-3.1-8B-Instruct" + "apiBase": "http:///v1" } ] } ``` -[View the source](https://github.com/continuedev/continue/blob/main/core/llm/llms/Vllm.ts) +## Autocomplete model + +We recommend configuring **Qwen2.5-Coder 1.5B** as your autocomplete model. + +```json title="config.json" +{ + "tabAutocompleteModel": { + "title": "Qwen2.5-Coder 1.5B", + "provider": "vllm", + "model": "Qwen/Qwen2.5-Coder-1.5B" + "apiBase": "http:///v1" + } +} +``` + +## Embeddings model + +We recommend configuring **Nomic Embed Text** as your embeddings model. + +```json title="config.json" +{ + "embeddingsProvider": { + "provider": "vllm", + "model": "nomic-ai/nomic-embed-text-v1" + "apiBase": "http:///v1" + } +} +``` + +## Reranking model + +[Click here](../../model-types/reranking.md) to see a list of reranking model providers. + + +The continue implementation uses [OpenAI](../top-level/openai.md) under the hood. [View the source](https://github.com/continuedev/continue/blob/main/core/llm/llms/Vllm.ts) From 4282909b0bf780d2347078f20daa6840b375a620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20=C3=96berg?= Date: Mon, 6 Jan 2025 19:34:59 +0100 Subject: [PATCH 087/114] vllm docs improvement --- docs/docs/customize/model-providers/more/vllm.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/customize/model-providers/more/vllm.md b/docs/docs/customize/model-providers/more/vllm.md index db6554b47..d54baeb88 100644 --- a/docs/docs/customize/model-providers/more/vllm.md +++ b/docs/docs/customize/model-providers/more/vllm.md @@ -1,6 +1,6 @@ # vLLM -vLLM is an open-source library for fast LLM inference which typically is used to serve multiple users at the same due its high performance but it can also be used to run a large model on multiple GPU:s (e.g. when it doesn´t fit in a single GPU). Run their OpenAI-compatible server using `vllm serve`. See their [server documentation](https://docs.vllm.ai/en/latest/serving/openai_compatible_server.html) and the [engine arguments documentation](https://docs.vllm.ai/en/latest/usage/engine_args.html). +vLLM is an open-source library for fast LLM inference which typically is used to serve multiple users at the same. It can also be used to run a large model on multiple GPU:s (e.g. when it doesn´t fit in a single GPU). Run their OpenAI-compatible server using `vllm serve`. See their [server documentation](https://docs.vllm.ai/en/latest/serving/openai_compatible_server.html) and the [engine arguments documentation](https://docs.vllm.ai/en/latest/usage/engine_args.html). ```shell vllm serve meta-llama/Meta-Llama-3.1-8B-Instruct From c61012c2b9fe795d30f0ff122ca662b9b922e074 Mon Sep 17 00:00:00 2001 From: hbernie Date: Mon, 6 Jan 2025 12:02:59 -0800 Subject: [PATCH 088/114] Update docs to remove deepseek coder. --- docs/docs/customize/model-providers/more/kindo.md | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/docs/docs/customize/model-providers/more/kindo.md b/docs/docs/customize/model-providers/more/kindo.md index 4915a1ee2..9e205c66e 100644 --- a/docs/docs/customize/model-providers/more/kindo.md +++ b/docs/docs/customize/model-providers/more/kindo.md @@ -1,6 +1,6 @@ # Kindo -Kindo offers centralized control over your organization's AI operations, ensuring data protection and compliance with internal policies while supporting various commercial and open-source models. To get started, sign up [here](https://app.kindo.ai/), create your API key on the [API keys page](https://app.kindo.ai/settings/api), and choose a model from the list of supported models in the [plugins tab](https://app.kindo.ai/plugins). +Kindo offers centralized control over your organization's AI operations, ensuring data protection and compliance with internal policies while supporting various commercial and open-source models. To get started, sign up [here](https://app.kindo.ai/), create an API key in [Settings > API > API Keys](https://app.kindo.ai/settings/api), and choose a model from the list of supported models in the "Available Models" tab or copy and paste the config in [Plugins > Your Configuration](https://app.kindo.ai/plugins). ## Config Example @@ -10,7 +10,7 @@ Kindo offers centralized control over your organization's AI operations, ensurin { "title": "Claude 3.5 Sonnet", "provider": "kindo", - "model": "claude-3-5-sonnet-20240620", + "model": "claude-3-5-sonnet", "apiKey": "" } ] @@ -26,13 +26,8 @@ Kindo offers centralized control over your organization's AI operations, ensurin "title": "WhiteRabbitNeo", "provider": "kindo", "model": "/models/WhiteRabbitNeo-33B-DeepSeekCoder", - "apiKey": "" - }, - { - "title": "DeepSeek", - "provider": "kindo", - "model": "deepseek-ai/deepseek-coder-33b-instruct", - "apiKey": "" + "apiKey": "", + "template": "none" } ] } From 6216c06153394014cac017a4f9758fce39c3686e Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 7 Jan 2025 01:33:01 +0100 Subject: [PATCH 089/114] split up docs sqlite migrations --- core/indexing/docs/DocsService.ts | 19 +++++++++++++++++-- core/indexing/docs/migrations.ts | 24 ++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index 1696466dc..1f56de495 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -743,10 +743,17 @@ export default class DocsService { } async getFavicon(startUrl: string) { + if (!this.config.embeddingsProvider) { + console.warn( + "Attempting to get favicon without embeddings provider specified", + ); + return; + } const db = await this.getOrCreateSqliteDb(); const result = await db.get( - `SELECT favicon FROM ${DocsService.sqlitebTableName} WHERE startUrl = ?`, + `SELECT favicon FROM ${DocsService.sqlitebTableName} WHERE startUrl = ? AND embeddingsProviderId = ?`, startUrl, + this.config.embeddingsProvider.embeddingId, ); if (!result) { @@ -1011,10 +1018,18 @@ export default class DocsService { } private async deleteMetadataFromSqlite(startUrl: string) { + if (!this.config.embeddingsProvider) { + console.warn( + `Attempting to delete metadata for ${startUrl} without embeddings provider specified`, + ); + return; + } const db = await this.getOrCreateSqliteDb(); + await db.run( - `DELETE FROM ${DocsService.sqlitebTableName} WHERE startUrl = ?`, + `DELETE FROM ${DocsService.sqlitebTableName} WHERE startUrl = ? AND embeddingsProviderId = ?`, startUrl, + this.config.embeddingsProvider.embeddingId, ); } diff --git a/core/indexing/docs/migrations.ts b/core/indexing/docs/migrations.ts index b84b0b842..1a09b8b5a 100644 --- a/core/indexing/docs/migrations.ts +++ b/core/indexing/docs/migrations.ts @@ -27,7 +27,7 @@ export async function runLanceMigrations(table: Table) { export async function runSqliteMigrations(db: Database) { await new Promise((resolve) => { - void migrate( + await migrate( "sqlite_modify_docs_columns_and_copy_to_config", async () => { try { @@ -52,7 +52,7 @@ export async function runSqliteMigrations(db: Database) { `ALTER TABLE ${DocsService.sqlitebTableName} RENAME COLUMN baseUrl TO startUrl;`, ); } - + const hasEmbeddingsProviderColumn = pragma.some( (pragma) => pragma.name === "embeddingsProviderId", ); @@ -77,5 +77,25 @@ export async function runSqliteMigrations(db: Database) { }, () => resolve(undefined), ); + await migrate( + "sqlite_delete_docs_with_no_embeddingsProviderId", + async () => { + try { + const pragma = await db.all( + `PRAGMA table_info(${DocsService.sqlitebTableName});`, + ); + const hasEmbeddingsProviderColumn = pragma.some( + (pragma) => pragma.name === "embeddingsProviderId", + ); + if (!hasEmbeddingsProviderColumn) { + // gotta just delete in this case since old docs will be unusable anyway + await db.exec(`DROP TABLE ${DocsService.sqlitebTableName};`); + } + } finally { + resolve(undefined); + } + }, + () => resolve(undefined), + ); }); } From 630d0fb76d16a2b23ececc6678778be371c3086a Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 7 Jan 2025 01:49:13 +0100 Subject: [PATCH 090/114] fix migration async logic sqlite docs --- core/indexing/docs/migrations.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/indexing/docs/migrations.ts b/core/indexing/docs/migrations.ts index 1a09b8b5a..baa658940 100644 --- a/core/indexing/docs/migrations.ts +++ b/core/indexing/docs/migrations.ts @@ -27,7 +27,7 @@ export async function runLanceMigrations(table: Table) { export async function runSqliteMigrations(db: Database) { await new Promise((resolve) => { - await migrate( + void migrate( "sqlite_modify_docs_columns_and_copy_to_config", async () => { try { @@ -52,7 +52,7 @@ export async function runSqliteMigrations(db: Database) { `ALTER TABLE ${DocsService.sqlitebTableName} RENAME COLUMN baseUrl TO startUrl;`, ); } - + const hasEmbeddingsProviderColumn = pragma.some( (pragma) => pragma.name === "embeddingsProviderId", ); @@ -77,7 +77,10 @@ export async function runSqliteMigrations(db: Database) { }, () => resolve(undefined), ); - await migrate( + }); + + await new Promise((resolve) => { + void migrate( "sqlite_delete_docs_with_no_embeddingsProviderId", async () => { try { From c3bd2ca6c2cd5a006bae9c53c1ffb0d87a429601 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 7 Jan 2025 01:50:12 +0100 Subject: [PATCH 091/114] docs sqlite migrations fix p3 --- core/indexing/docs/migrations.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/core/indexing/docs/migrations.ts b/core/indexing/docs/migrations.ts index baa658940..38aa987b3 100644 --- a/core/indexing/docs/migrations.ts +++ b/core/indexing/docs/migrations.ts @@ -53,14 +53,6 @@ export async function runSqliteMigrations(db: Database) { ); } - const hasEmbeddingsProviderColumn = pragma.some( - (pragma) => pragma.name === "embeddingsProviderId", - ); - if (!hasEmbeddingsProviderColumn) { - // gotta just delete in this case since old docs will be unusable anyway - await db.exec(`DROP TABLE ${DocsService.sqlitebTableName};`); - } - const needsToUpdateConfig = !hasFaviconCol || hasBaseUrlCol; if (needsToUpdateConfig) { const sqliteDocs = await db.all< From c17c3a2f891412dac212919fc405f196f00bcc1b Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 7 Jan 2025 02:27:18 +0100 Subject: [PATCH 092/114] filenameLink: endswith detection --- .../markdown/StyledMarkdownPreview.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/gui/src/components/markdown/StyledMarkdownPreview.tsx b/gui/src/components/markdown/StyledMarkdownPreview.tsx index a6eb2c569..66ceb2395 100644 --- a/gui/src/components/markdown/StyledMarkdownPreview.tsx +++ b/gui/src/components/markdown/StyledMarkdownPreview.tsx @@ -296,14 +296,16 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( code: ({ node, ...codeProps }) => { const content = getCodeChildrenContent(codeProps.children); - if (content && previousFileContextItemsRef.current) { + if (content) { // Insert file links for matching previous context items - const ctxItem = previousFileContextItemsRef.current.find((item) => - item.uri!.value!.includes(content), - ); - if (ctxItem) { - const rif = ctxItemToRifWithContents(ctxItem); - return ; + if (previousFileContextItemsRef.current?.length) { + const ctxItem = previousFileContextItemsRef.current.find((item) => + item.uri!.value!.endsWith(content), + ); + if (ctxItem) { + const rif = ctxItemToRifWithContents(ctxItem); + return ; + } } // Insert symbols for exact matches From c97c88f16af2d04c907fed4eead1dbb28755d845 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 7 Jan 2025 02:36:02 +0100 Subject: [PATCH 093/114] filename link: exact match last uri segment --- .../components/markdown/StyledMarkdownPreview.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/gui/src/components/markdown/StyledMarkdownPreview.tsx b/gui/src/components/markdown/StyledMarkdownPreview.tsx index 66ceb2395..acac40ae3 100644 --- a/gui/src/components/markdown/StyledMarkdownPreview.tsx +++ b/gui/src/components/markdown/StyledMarkdownPreview.tsx @@ -298,10 +298,16 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( if (content) { // Insert file links for matching previous context items - if (previousFileContextItemsRef.current?.length) { - const ctxItem = previousFileContextItemsRef.current.find((item) => - item.uri!.value!.endsWith(content), + // With some reasonable limitations on what might be a filename + if ( + previousFileContextItemsRef.current?.length && + content.includes(".") && + content.length > 2 + ) { + const ctxItem = previousFileContextItemsRef.current.find( + (item) => item.uri!.value!.split("/").pop() === content, // Exact match for last segment of URI ); + if (ctxItem) { const rif = ctxItemToRifWithContents(ctxItem); return ; From 06e98ac8a4df4a569a6472f94a38399e59483a9f Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 7 Jan 2025 10:34:36 -0800 Subject: [PATCH 094/114] docs updates --- CONTRIBUTING.md | 4 +-- docs/docs/chat/context-selection.md | 2 +- docs/docs/chat/model-setup.mdx | 26 +------------------ docs/docs/customize/tutorials/llama3.1.md | 22 ---------------- .../current/chat/model-setup.mdx | 2 +- .../current/customize/tutorials/llama3.1.md | 21 --------------- .../pages/AddNewModel/configs/providers.ts | 14 +++++----- 7 files changed, 12 insertions(+), 79 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index eddf7b45b..ca26d38fe 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -188,7 +188,7 @@ After you've written your context provider, make sure to complete the following: ### Adding an LLM Provider -Continue has support for more than a dozen different LLM "providers", making it easy to use models running on OpenAI, Ollama, Together, Novita AI, LM Studio, Msty, and more. You can find all of the existing providers [here](https://github.com/continuedev/continue/tree/main/core/llm/llms), and if you see one missing, you can add it with the following steps: +Continue has support for more than a dozen different LLM "providers", making it easy to use models running on OpenAI, Ollama, Together, LM Studio, Msty, and more. You can find all of the existing providers [here](https://github.com/continuedev/continue/tree/main/core/llm/llms), and if you see one missing, you can add it with the following steps: 1. Create a new file in the `core/llm/llms` directory. The name of the file should be the name of the provider, and it should export a class that extends `BaseLLM`. This class should contain the following minimal implementation. We recommend viewing pre-existing providers for more details. The [LlamaCpp Provider](./core/llm/llms/LlamaCpp.ts) is a good simple example. @@ -209,7 +209,7 @@ While any model that works with a supported provider can be used with Continue, 1. Add a `ModelPackage` entry for the model into [configs/models.ts](./gui/src/pages/AddNewModel/configs/models.ts), following the lead of the many examples near the top of the file 2. Add the model within its provider's array to [AddNewModel.tsx](./gui/src/pages/AddNewModel/AddNewModel.tsx) (add provider if needed) - [index.d.ts](./core/index.d.ts) - This file defines the TypeScript types used throughout Continue. You'll find a `ModelName` type. Be sure to add the name of your model to this. -- LLM Providers: Since many providers use their own custom strings to identify models, you'll have to add the translation from Continue's model name (the one you added to `index.d.ts`) and the model string for each of these providers: [Ollama](./core/llm/llms/Ollama.ts), [Together](./core/llm/llms/Together.ts), [Novita AI](./core/llm/llms/Novita.ts), and [Replicate](./core/llm/llms/Replicate.ts). You can find their full model lists here: [Ollama](https://ollama.ai/library), [Together](https://docs.together.ai/docs/inference-models), [Novita AI](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link), [Replicate](https://replicate.com/collections/streaming-language-models). +- LLM Providers: Since many providers use their own custom strings to identify models, you'll have to add the translation from Continue's model name (the one you added to `index.d.ts`) and the model string for each of these providers: [Ollama](./core/llm/llms/Ollama.ts), [Together](./core/llm/llms/Together.ts), and [Replicate](./core/llm/llms/Replicate.ts). You can find their full model lists here: [Ollama](https://ollama.ai/library), [Together](https://docs.together.ai/docs/inference-models), [Replicate](https://replicate.com/collections/streaming-language-models). - [Prompt Templates](./core/llm/index.ts) - In this file you'll find the `autodetectTemplateType` function. Make sure that for the model name you just added, this function returns the correct template type. This is assuming that the chat template for that model is already built in Continue. If not, you will have to add the template type and corresponding edit and chat templates. ### Adding Pre-indexed Documentation diff --git a/docs/docs/chat/context-selection.md b/docs/docs/chat/context-selection.md index 4ec425e81..e4c35ddc5 100644 --- a/docs/docs/chat/context-selection.md +++ b/docs/docs/chat/context-selection.md @@ -15,7 +15,7 @@ The highlighted code you’ve selected by pressing cmd/ctrl + L< ## Active file -You can include the currently open file as context by pressing cmd + opt + enter (Mac) or alt + enter (Windows) when you send your request at Chat window(Prompt can't be empty). +You can include the currently open file as context by pressing opt + enter (Mac) or alt + enter (Windows) when you send your request at Chat window(Prompt can't be empty). ## Specific file diff --git a/docs/docs/chat/model-setup.mdx b/docs/docs/chat/model-setup.mdx index 832f2f837..eb7dc5430 100644 --- a/docs/docs/chat/model-setup.mdx +++ b/docs/docs/chat/model-setup.mdx @@ -33,7 +33,7 @@ Our current top recommendation is Claude Sonnet 3.5 from [Anthropic](../customiz ### Llama 3.1 405B from Meta -If you prefer to use an open-weight model, then Llama 3.1 405B from Meta is your best option right now. You will need to decide if you use it through a SaaS model provider (e.g. [Together](../customize/model-providers/more/together.md) or [Novita AI](../customize/model-providers/more/novita.md) or [Groq](../customize/model-providers/more/groq.md)) or self-host it (e.g. using [vLLM](../customize/model-providers//more/vllm.md) or [Ollama](../customize/model-providers/top-level/ollama.md)). +If you prefer to use an open-weight model, then Llama 3.1 405B from Meta is your best option right now. You will need to decide if you use it through a SaaS model provider (e.g. [Together](../customize/model-providers/more/together.md) or [Groq](../customize/model-providers/more/groq.md)) or self-host it (e.g. using [vLLM](../customize/model-providers//more/vllm.md) or [Ollama](../customize/model-providers/top-level/ollama.md)). @@ -48,18 +48,6 @@ If you prefer to use an open-weight model, then Llama 3.1 405B from Meta is your ] ``` - - ```json title="config.json" - "models": [ - { - "title": "Llama 3.1 405B", - "provider": "novita", - "model": "meta-llama/llama-3.1-405b-instruct", - "apiKey": "[NOVITA_API_KEY]" - } - ] - ``` - ```json title="config.json" "models": [ @@ -94,18 +82,6 @@ If you prefer to use an open-weight model, then Llama 3.1 405B from Meta is your ] ``` - - ```json title="config.json" - "models": [ - { - "title": "Llama 3.1 405B", - "provider": "nebius", - "model": "llama3.1-405b", - "apiKey": "[NEBIUS_API_KEY]" - } - ] - ``` - ### GPT-4o from OpenAI diff --git a/docs/docs/customize/tutorials/llama3.1.md b/docs/docs/customize/tutorials/llama3.1.md index 38e90bee9..e2ac72986 100644 --- a/docs/docs/customize/tutorials/llama3.1.md +++ b/docs/docs/customize/tutorials/llama3.1.md @@ -71,28 +71,6 @@ Together AI provides fast and reliable inference of open-source models. You'll b } ``` - -## Novita AI - -[Novita AI](https://novita.ai?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) offers an affordable, reliable, and simple inference platform with scalable [LLM API](https://novita.ai/docs/model-api/reference/introduction.html), empowering developers to build AI applications. Try the [Novita AI Llama 3 API Demo](https://novita.ai/model-api/product/llm-api/playground/meta-llama-llama-3.1-70b-instruct?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) today! - -1. Create an account [here](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) -2. Copy your API key that appears on the welcome screen -3. Update your Continue config file like this: - -```json title="config.json" -{ - "models": [ - { - "title": "Llama 3.1 405b", - "provider": "novita", - "model": "meta-llama/llama-3.1-405b-instruct", - "apiKey": "" - } - ] -} -``` - ## Replicate Replicate makes it easy to host and run open-source AI with an API. diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx index 4ef37a41e..cbbef8761 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx @@ -33,7 +33,7 @@ import TabItem from "@theme/TabItem"; ### 来自 Meta 的 Llama 3.1 405B -如果你倾向于使用开放权重模型,那么来自 Meta 的 Llama 3.1 405B 是你当前的最好选择。你需要决定,通过 SaaS 模型提供者使用它(比如 [Together](../customize/model-providers/more/together.md) 、[Novita AI](../customize/model-providers/more/novita.md)或 [Groq](../customize/model-providers/more/groq.md))或者自托管使用它(比如使用 [vLLM](../customize/model-providers//more/vllm.md) 或 [Ollama](../customize/model-providers/top-level/ollama.md)) 。 +如果你倾向于使用开放权重模型,那么来自 Meta 的 Llama 3.1 405B 是你当前的最好选择。你需要决定,通过 SaaS 模型提供者使用它(比如 [Together](../customize/model-providers/more/together.md)或 [Groq](../customize/model-providers/more/groq.md))或者自托管使用它(比如使用 [vLLM](../customize/model-providers//more/vllm.md) 或 [Ollama](../customize/model-providers/top-level/ollama.md)) 。 diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md index dc285627a..e02ba6741 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md @@ -71,27 +71,6 @@ Together AI 提供开源模型的快速和可信任的推理。你可以以良 } ``` -## Novita AI - -[Novita AI](https://novita.ai?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) 提供了一个经济实惠、可靠且简单的推理平台。你可以以良好的速度运行 405b 模型。 - -1. 创建账号 [在这里](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) -2. 复制[Key Management](https://novita.ai/settings/key-management?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link)中的你的 API key -3. 更新你的 Continue 配置文件,像这样: - -```json title="config.json" -{ - "models": [ - { - "title": "Llama 3.1 405b", - "provider": "novita", - "model": "meta-llama/llama-3.1-405b-instruct", - "apiKey": "" - } - ] -} -``` - ## Replicate Replicate 让使用 API 托管和运行开源 AI 变得简单。 diff --git a/gui/src/pages/AddNewModel/configs/providers.ts b/gui/src/pages/AddNewModel/configs/providers.ts index d1efcd262..4890d5c2b 100644 --- a/gui/src/pages/AddNewModel/configs/providers.ts +++ b/gui/src/pages/AddNewModel/configs/providers.ts @@ -165,7 +165,8 @@ export const providers: Partial> = { title: "Scaleway", provider: "scaleway", refPage: "scaleway", - description: "Use the Scaleway Generative APIs to instantly access leading open models", + description: + "Use the Scaleway Generative APIs to instantly access leading open models", longDescription: `Hosted in European data centers, ideal for developers requiring low latency, full data privacy, and compliance with EU AI Act. You can generate your API key in [Scaleway's console](https://console.scaleway.com/generative-api/models). Get started:\n1. Create an API key [here](https://console.scaleway.com/iam/api-keys/)\n2. Paste below\n3. Select a model preset`, params: { apiKey: "", @@ -426,13 +427,12 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n }, ...completionParamsInputsConfigs, ], - packages: [ - models.llama318BChat, models.mistralChat - ].map((p) => { + packages: [models.llama318BChat, models.mistralChat].map((p) => { p.params.contextLength = 4096; return p; }), - apiKeyUrl: "https://novita.ai/settings/key-management?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link", + apiKeyUrl: + "https://novita.ai/settings/key-management?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link", }, gemini: { title: "Google Gemini API", @@ -670,8 +670,8 @@ To get started, [register](https://dataplatform.cloud.ibm.com/registration/stepo provider: "free-trial", refPage: "freetrial", description: - "New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, Together, or Novita AI using our API key", - longDescription: `New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, Together or Novita AI using our API key. If you are ready to set up a model for long-term use or have used all ${FREE_TRIAL_LIMIT_REQUESTS} free uses, you can enter your API key or use a local model.`, + "New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, or Together using our API key", + longDescription: `New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, or Together using our API key. If you are ready to set up a model for long-term use or have used all ${FREE_TRIAL_LIMIT_REQUESTS} free uses, you can enter your API key or use a local model.`, icon: "openai.png", tags: [ModelProviderTags.Free], packages: [ From 184848b5eef68ebb249e494f55f010ba459c5853 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 7 Jan 2025 10:52:38 -0800 Subject: [PATCH 095/114] Update commit.ts --- core/commands/slash/commit.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/commands/slash/commit.ts b/core/commands/slash/commit.ts index c2d09adba..8fc1ae27b 100644 --- a/core/commands/slash/commit.ts +++ b/core/commands/slash/commit.ts @@ -5,7 +5,7 @@ const CommitMessageCommand: SlashCommand = { name: "commit", description: "Generate a commit message for current changes", run: async function* ({ ide, llm, params }) { - const includeUnstaged = params?.includeUnstaged ?? true; + const includeUnstaged = params?.includeUnstaged ?? false; const diff = await ide.getDiff(includeUnstaged); if (diff.length === 0) { From c7b80d346f0850019a8660eb0d9d1505c0e420b7 Mon Sep 17 00:00:00 2001 From: henry Date: Tue, 7 Jan 2025 15:57:14 -0600 Subject: [PATCH 096/114] fix fullscreen bug --- extensions/vscode/src/commands.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index b83d3d380..1c26bb45e 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -733,6 +733,10 @@ const getCommandsMap: ( "getCurrentSessionId", undefined, ); + + // Clear the sidebar to prevent overwriting changes made in fullscreen + vscode.commands.executeCommand("continue.newSession") + // Check if full screen is already open by checking open tabs const fullScreenTab = getFullScreenTab(); From 326132f18dc3574adc12a53f3b7f2778bb1295dd Mon Sep 17 00:00:00 2001 From: henry Date: Tue, 7 Jan 2025 16:46:06 -0600 Subject: [PATCH 097/114] stopped fullscreen refresh --- extensions/vscode/src/commands.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index 1c26bb45e..daf3d4991 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -734,19 +734,18 @@ const getCommandsMap: ( undefined, ); - // Clear the sidebar to prevent overwriting changes made in fullscreen - vscode.commands.executeCommand("continue.newSession") - // Check if full screen is already open by checking open tabs const fullScreenTab = getFullScreenTab(); if (fullScreenTab && fullScreenPanel) { // Full screen open, but not focused - focus it fullScreenPanel.reveal(); - vscode.commands.executeCommand("continue.focusContinueInput"); return; } + // Clear the sidebar to prevent overwriting changes made in fullscreen + vscode.commands.executeCommand("continue.newSession") + // Full screen not open - open it captureCommandTelemetry("openFullScreen"); From bd03c85c1cbf98e0c4f5699d9d132b780b4c3b7a Mon Sep 17 00:00:00 2001 From: henry Date: Tue, 7 Jan 2025 16:57:45 -0600 Subject: [PATCH 098/114] removed accidentally added whitespace --- extensions/vscode/src/commands.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index daf3d4991..ac4a86984 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -733,7 +733,6 @@ const getCommandsMap: ( "getCurrentSessionId", undefined, ); - // Check if full screen is already open by checking open tabs const fullScreenTab = getFullScreenTab(); From 951784c790664a80d87b54e33886a3582137ad50 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 7 Jan 2025 15:22:50 -0800 Subject: [PATCH 099/114] feat(VSC): give option to disable quick fix --- extensions/vscode/package.json | 5 +++++ extensions/vscode/src/lang-server/codeActions.ts | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index ac3bce14e..d6a288f41 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -101,6 +101,11 @@ "default": true, "description": "Show inline suggestion to use the Continue keyboard shortcuts (e.g. \"Cmd/Ctrl L to select code, Cmd/Ctrl I to edit\")." }, + "continue.disableQuickFix": { + "type": "boolean", + "default": false, + "description": "Disable the quick fix feature." + }, "continue.enableQuickActions": { "type": "boolean", "default": false, diff --git a/extensions/vscode/src/lang-server/codeActions.ts b/extensions/vscode/src/lang-server/codeActions.ts index b07ea149d..f39d5b926 100644 --- a/extensions/vscode/src/lang-server/codeActions.ts +++ b/extensions/vscode/src/lang-server/codeActions.ts @@ -1,3 +1,4 @@ +import { EXTENSION_NAME } from "core/control-plane/env"; import * as vscode from "vscode"; class ContinueQuickFixProvider implements vscode.CodeActionProvider { @@ -42,6 +43,15 @@ class ContinueQuickFixProvider implements vscode.CodeActionProvider { } export default function registerQuickFixProvider() { + const isDisabled = + !!vscode.workspace + .getConfiguration(EXTENSION_NAME) + .get("disableQuickFix") === true; + + if (isDisabled) { + return; + } + // In your extension's activate function: vscode.languages.registerCodeActionsProvider( { language: "*" }, From 9110904e7d4f727339666ce235388397b8c4ff99 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 7 Jan 2025 15:34:44 -0800 Subject: [PATCH 100/114] fix(JB+GUI): arrow keys in GUI on linux --- .../components/mainInput/handleMetaKeyIssues.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gui/src/components/mainInput/handleMetaKeyIssues.ts b/gui/src/components/mainInput/handleMetaKeyIssues.ts index baf824bd6..14bf3f792 100644 --- a/gui/src/components/mainInput/handleMetaKeyIssues.ts +++ b/gui/src/components/mainInput/handleMetaKeyIssues.ts @@ -17,8 +17,18 @@ export const handleJetBrainsOSRMetaKeyIssues = ( const handlers: Record void> = { Backspace: () => handleJetBrainsMetaBackspace(editor), - ArrowLeft: () => selection?.modify(alter, "backward", "lineboundary"), - ArrowRight: () => selection?.modify(alter, "forward", "lineboundary"), + ArrowLeft: () => + selection?.modify( + alter, + "backward", + platform === "mac" ? "lineboundary" : "word", + ), + ArrowRight: () => + selection?.modify( + alter, + "forward", + platform === "mac" ? "lineboundary" : "word", + ), ArrowDown: () => selection?.modify(alter, "forward", "documentboundary"), ArrowUp: () => { selection?.modify(alter, "backward", "documentboundary"); From 70eb8a96085c1f3ee9d7d60a0a730909b85f0649 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 7 Jan 2025 16:05:53 -0800 Subject: [PATCH 101/114] chore: update `maxTokens` for anthropic models --- core/llm/llms/Anthropic.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/llm/llms/Anthropic.ts b/core/llm/llms/Anthropic.ts index 31642ea66..234c16860 100644 --- a/core/llm/llms/Anthropic.ts +++ b/core/llm/llms/Anthropic.ts @@ -10,7 +10,7 @@ class Anthropic extends BaseLLM { contextLength: 200_000, completionOptions: { model: "claude-3-5-sonnet-latest", - maxTokens: 4096, + maxTokens: 8192, }, apiBase: "https://api.anthropic.com/v1/", }; From c36a1ae62851383978080bc5674e7ba4ca0e9cc1 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 7 Jan 2025 18:10:40 -0800 Subject: [PATCH 102/114] feat(JB): scroll to top of file on full file edit --- .../listeners/ContinuePluginSelectionListener.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/listeners/ContinuePluginSelectionListener.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/listeners/ContinuePluginSelectionListener.kt index 24d9787f5..d76791264 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/listeners/ContinuePluginSelectionListener.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/listeners/ContinuePluginSelectionListener.kt @@ -110,6 +110,19 @@ class ContinuePluginSelectionListener( ApplicationManager.getApplication().invokeLater { val document = editor.document val (startLine, endLine, isFullLineSelection) = getSelectionInfo(model, document) + + // Check if entire file is selected + val isEntireFileSelected = model.selectionStart == 0 && + model.selectionEnd == document.textLength + + // Scroll to top if entire file selected so that the user can see the input + if (isEntireFileSelected) { + editor.scrollingModel.scrollTo( + LogicalPosition(0, 0), + com.intellij.openapi.editor.ScrollType.CENTER + ) + } + val selectionTopY = calculateSelectionTopY(editor, startLine, endLine, isFullLineSelection) val tooltipX = calculateTooltipX(editor, document, startLine, endLine, isFullLineSelection) From f4fd9c8c5d2ef40bc697fdb2290cc4361d9fe965 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 7 Jan 2025 18:44:37 -0800 Subject: [PATCH 103/114] docs: remove function network from top-level --- .../model-providers/{top-level => more}/function-network.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/docs/customize/model-providers/{top-level => more}/function-network.md (100%) diff --git a/docs/docs/customize/model-providers/top-level/function-network.md b/docs/docs/customize/model-providers/more/function-network.md similarity index 100% rename from docs/docs/customize/model-providers/top-level/function-network.md rename to docs/docs/customize/model-providers/more/function-network.md From 821c3a9a7cdcb4d1f27adaec8ff44a9ff5039401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E5=90=95=E6=A5=B8?= Date: Wed, 8 Jan 2025 23:50:25 +0800 Subject: [PATCH 104/114] fix buttons position on accept --- .../editor/DiffStreamHandler.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt index 3f25b87cb..e44c08dd5 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt @@ -125,7 +125,9 @@ class DiffStreamHandler( diffBlocks.remove(diffBlock) - if (!didAccept) { + if (didAccept) { + updatePositionsOnAccept(diffBlock.startLine) + } else { updatePositionsOnReject(diffBlock.startLine, diffBlock.addedLines.size, diffBlock.deletedLines.size) } @@ -186,10 +188,16 @@ class DiffStreamHandler( } } + private fun updatePositionsOnAccept(startLine: Int) { + updatePositions(startLine, 0) + } private fun updatePositionsOnReject(startLine: Int, numAdditions: Int, numDeletions: Int) { val offset = -numAdditions + numDeletions + updatePositions(startLine, offset) + } + private fun updatePositions(startLine: Int, offset: Int) { diffBlocks.forEach { block -> if (block.startLine > startLine) { block.updatePosition(block.startLine + offset) From 98f07bef818cf5acc4de2828cbeaa0b4b499fc53 Mon Sep 17 00:00:00 2001 From: leafyy Date: Thu, 9 Jan 2025 21:51:28 +0800 Subject: [PATCH 105/114] fix: mcp context provider bug with issue 2467 --- core/context/providers/MCPContextProvider.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/context/providers/MCPContextProvider.ts b/core/context/providers/MCPContextProvider.ts index 7395e82c8..f239e3ee1 100644 --- a/core/context/providers/MCPContextProvider.ts +++ b/core/context/providers/MCPContextProvider.ts @@ -73,7 +73,15 @@ class MCPContextProvider extends BaseContextProvider { async loadSubmenuItems( args: LoadSubmenuItemsArgs, ): Promise { - return (this.options as MCPContextProviderOptions).submenuItems; + return (this.options as MCPContextProviderOptions).submenuItems.map( + (item, index) => ({ + ...item, + id: JSON.stringify({ + mcpId: String(index), + uri: item.id, + }), + }), + ); } } From f86ad3648b3ffc76ac4894acd1623cb815ca51bb Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 9 Jan 2025 11:37:53 -0800 Subject: [PATCH 106/114] merge main --- .../continueintellijextension/constants/MessageTypes.kt | 1 + .../com/github/continuedev/continueintellijextension/e2e/GUI.kt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt index aa1d7c4d6..585dd716f 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt @@ -79,6 +79,7 @@ class MessageTypes { "history/save", "devdata/log", "config/addModel", + "config/addContextProvider", "config/newPromptFile", "config/ideSettingsUpdate", "config/getSerializedProfileInfo", diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt index cbc3a7272..4a47fb45a 100644 --- a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt +++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt @@ -39,7 +39,7 @@ class GUI { @AfterEach fun closeProject(remoteRobot: RemoteRobot) = CommonSteps(remoteRobot).closeProject() - // @Test + @Test @Video fun highlightCode(remoteRobot: RemoteRobot): Unit = with(remoteRobot) { welcomeFrame { From 158a4a08472e7d706ef0cbec518a962d968dc776 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Thu, 9 Jan 2025 13:00:16 -0800 Subject: [PATCH 107/114] Update GUI.kt --- .../github/continuedev/continueintellijextension/e2e/GUI.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt index 4a47fb45a..5672debba 100644 --- a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt +++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/GUI.kt @@ -39,7 +39,7 @@ class GUI { @AfterEach fun closeProject(remoteRobot: RemoteRobot) = CommonSteps(remoteRobot).closeProject() - @Test + // @Test @Video fun highlightCode(remoteRobot: RemoteRobot): Unit = with(remoteRobot) { welcomeFrame { @@ -93,4 +93,4 @@ class GUI { } } } -} \ No newline at end of file +} From f61476a4936f364b4d0adc679da067d5f3ee8411 Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 9 Jan 2025 16:43:30 -0800 Subject: [PATCH 108/114] fix: comment out auto apply on MFE --- core/edit/lazy/deterministic.ts | 2 +- .../vscode/src/diff/vertical/handler.ts | 36 +++++++++++-------- .../CodeToEditCard/CodeToEditListItem.tsx | 2 +- .../StepContainerPreToolbar/ApplyActions.tsx | 2 +- .../StepContainerPreToolbar.tsx | 19 +++++----- 5 files changed, 35 insertions(+), 26 deletions(-) diff --git a/core/edit/lazy/deterministic.ts b/core/edit/lazy/deterministic.ts index 99d5c9a01..1e3a0ec4e 100644 --- a/core/edit/lazy/deterministic.ts +++ b/core/edit/lazy/deterministic.ts @@ -172,7 +172,7 @@ export async function deterministicApplyLazyEdit( oldText.slice(endIndex); } else { console.warn("No matching node found for lazy block"); - return []; + return undefined; } } } diff --git a/extensions/vscode/src/diff/vertical/handler.ts b/extensions/vscode/src/diff/vertical/handler.ts index a3a7f651f..4d8a99020 100644 --- a/extensions/vscode/src/diff/vertical/handler.ts +++ b/extensions/vscode/src/diff/vertical/handler.ts @@ -359,7 +359,7 @@ export class VerticalDiffHandler implements vscode.Disposable { // Clear deletion buffer await this.insertDeletionBuffer(); - this.reapplyWithMeyersDiff(diffLines); + await this.reapplyWithMeyersDiff(diffLines); this.options.onStatusUpdate( "done", @@ -386,6 +386,7 @@ export class VerticalDiffHandler implements vscode.Disposable { startLine: number, numGreen: number, numRed: number, + skipStatusUpdate?: boolean, ) { if (numGreen > 0) { // Delete the editor decoration @@ -415,15 +416,18 @@ export class VerticalDiffHandler implements vscode.Disposable { // Shift the codelens objects this.shiftCodeLensObjects(startLine, offset); - const numDiffs = - this.editorToVerticalDiffCodeLens.get(this.fileUri)?.length ?? 0; + if (!skipStatusUpdate) { + const numDiffs = + this.editorToVerticalDiffCodeLens.get(this.fileUri)?.length ?? 0; - const status = numDiffs === 0 ? "closed" : undefined; - this.options.onStatusUpdate( - status, - numDiffs, - this.editor.document.getText(), - ); + const status = numDiffs === 0 ? "closed" : undefined; + + this.options.onStatusUpdate( + status, + numDiffs, + this.editor.document.getText(), + ); + } } private shiftCodeLensObjects(startLine: number, offset: number) { @@ -482,11 +486,15 @@ export class VerticalDiffHandler implements vscode.Disposable { * we have received all of the diff lines. */ async reapplyWithMeyersDiff(diffLines: DiffLine[]) { - // First, we reset the original diff by deleting any new lines and clearing decorations - for (const range of this.greenDecorationManager.getRanges()) { - await this.deleteLinesAt( - range.start.line, - range.end.line - range.start.line + 1, + // First, we reset the original diff by rejecting all pending diff blocks + for (const block of this.editorToVerticalDiffCodeLens.get(this.fileUri) ?? + []) { + await this.acceptRejectBlock( + false, + block.start, + block.numGreen, + block.numRed, + true, ); } diff --git a/gui/src/components/CodeToEditCard/CodeToEditListItem.tsx b/gui/src/components/CodeToEditCard/CodeToEditListItem.tsx index f915f27d7..3d59ac239 100644 --- a/gui/src/components/CodeToEditCard/CodeToEditListItem.tsx +++ b/gui/src/components/CodeToEditCard/CodeToEditListItem.tsx @@ -98,7 +98,7 @@ export default function CodeToEditListItem({
-
+
{showCodeSnippet ? ( { setShowApplied(false); - }, 2_000); + }, 5_000); return () => clearTimeout(timer); } }, [isClosed, isSuccessful]); diff --git a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx index 45b55f10b..6ccedc74a 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx @@ -131,18 +131,19 @@ export default function StepContainerPreToolbar( } }, [props.children, codeBlockContent]); - useEffect(() => { - const hasCompletedGenerating = - wasGeneratingRef.current && !isGeneratingCodeBlock; + // Temporarily disabling auto apply for Edit mode + // useEffect(() => { + // const hasCompletedGenerating = + // wasGeneratingRef.current && !isGeneratingCodeBlock; - const shouldAutoApply = hasCompletedGenerating && isInEditMode; + // const shouldAutoApply = hasCompletedGenerating && isInEditMode; - if (shouldAutoApply) { - onClickApply(); - } + // if (shouldAutoApply) { + // onClickApply(); + // } - wasGeneratingRef.current = isGeneratingCodeBlock; - }, [isGeneratingCodeBlock]); + // wasGeneratingRef.current = isGeneratingCodeBlock; + // }, [isGeneratingCodeBlock]); async function onClickAcceptApply() { const fileUri = await inferResolvedUriFromRelativePath( From 668b58a7addcb186959d0e213df209249ed012ef Mon Sep 17 00:00:00 2001 From: Sherman Boyd Date: Thu, 9 Jan 2025 17:49:27 -0700 Subject: [PATCH 109/114] Add GH Issues template for documentation issues --- .github/ISSUE_TEMPLATE/docs_issue_report.yml | 75 ++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/docs_issue_report.yml diff --git a/.github/ISSUE_TEMPLATE/docs_issue_report.yml b/.github/ISSUE_TEMPLATE/docs_issue_report.yml new file mode 100644 index 000000000..febdf7a02 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/docs_issue_report.yml @@ -0,0 +1,75 @@ +--- +name: 📖 Documentation Issue Report +description: Use this form to report issues related to the documentation +labels: [area:docs] + +body: + - type: markdown + attributes: + value: | + ## Thank you for helping us improve our documentation! + + We appreciate your feedback. + + ## Contributing + + - Contribute directly by clicking "Edit this page" at the bottom of any page on [docs.continue.dev](https://docs.continue.dev). + - Learn about running a local copy of the docs in [CONTRIBUTE.md](https://github.com/continuedev/continue/blob/main/CONTRIBUTING.md#-updating--improving-documentation) + + - type: checkboxes + id: doc-issue-category + attributes: + label: What kind of problem are you reporting? + description: Please select a category. + options: + - label: Undocumentated feature or missing documentation + required: false + - label: Existing article contains incorrect or out-of-date documentation + required: false + - label: Existing article suggestion or improvement + required: false + - label: Broken link or dead link + required: false + - label: Documentation organization issue or improvement + required: false + - label: Other (please describe below) + required: false + + - type: input + id: page-url + attributes: + label: URL of the affected documentation page + description: Provide the URL to the specific documentation page where you encountered the issue. + placeholder: "https://docs.continue.dev/" + + - type: textarea + id: details + attributes: + label: Description of the issue + description: Please describe the issue in detail. If there is missing information or outdated content, provide specifics about what should be added or updated. + value: | + Example: + * Missing section on ... + * Incorrect information stating ... + * Outdated example code ... + + - type: input + id: expected-content + attributes: + label: Expected content (optional) + description: If applicable, provide the content you believe should be added or updated. + placeholder: "Expected details to include in the documentation..." + + - type: input + id: additional-info + attributes: + label: Additional Information (optional) + description: Feel free to add any other relevant information that may help us understand and resolve your issue. + placeholder: "Additional details..." + + - type: input + id: related-issue + attributes: + label: Related Issue (optional) + description: Is this issue related to another existing GitHub issue? + placeholder: "e.g., #123" \ No newline at end of file From 1d1fb7cdf834c6aa97a150b1742801ce8252eff2 Mon Sep 17 00:00:00 2001 From: Sherman Boyd Date: Thu, 9 Jan 2025 17:59:49 -0700 Subject: [PATCH 110/114] Improved docs issue template --- .github/ISSUE_TEMPLATE/docs_issue_report.yml | 92 +++++++++++--------- 1 file changed, 50 insertions(+), 42 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/docs_issue_report.yml b/.github/ISSUE_TEMPLATE/docs_issue_report.yml index febdf7a02..20be7f044 100644 --- a/.github/ISSUE_TEMPLATE/docs_issue_report.yml +++ b/.github/ISSUE_TEMPLATE/docs_issue_report.yml @@ -1,6 +1,6 @@ --- name: 📖 Documentation Issue Report -description: Use this form to report issues related to the documentation +description: Report issues related to the documentation labels: [area:docs] body: @@ -8,68 +8,76 @@ body: attributes: value: | ## Thank you for helping us improve our documentation! + We appreciate your feedback. Before submitting, please check if a similar issue already exists. - We appreciate your feedback. + ### Quick Contribution Tips: + - Click "Edit this page" at the bottom of any page on [docs.continue.dev](https://docs.continue.dev) to contribute directly. + - For local development, see [CONTRIBUTING.md](https://github.com/continuedev/continue/blob/main/CONTRIBUTING.md#-updating--improving-documentation). - ## Contributing - - - Contribute directly by clicking "Edit this page" at the bottom of any page on [docs.continue.dev](https://docs.continue.dev). - - Learn about running a local copy of the docs in [CONTRIBUTE.md](https://github.com/continuedev/continue/blob/main/CONTRIBUTING.md#-updating--improving-documentation) - - - type: checkboxes + - type: dropdown id: doc-issue-category attributes: - label: What kind of problem are you reporting? - description: Please select a category. + label: Issue Category + description: Select the category that best describes your issue. options: - - label: Undocumentated feature or missing documentation - required: false - - label: Existing article contains incorrect or out-of-date documentation - required: false - - label: Existing article suggestion or improvement - required: false - - label: Broken link or dead link - required: false - - label: Documentation organization issue or improvement - required: false - - label: Other (please describe below) - required: false + - Undocumented feature or missing documentation + - Incorrect or outdated information + - Suggestion for existing article + - Broken or dead link + - Documentation organization issue + - Other (please describe in the details section) + validations: + required: true - type: input id: page-url attributes: - label: URL of the affected documentation page - description: Provide the URL to the specific documentation page where you encountered the issue. - placeholder: "https://docs.continue.dev/" + label: Affected Documentation Page URL + description: Provide the URL of the specific page where you encountered the issue. + placeholder: "https://docs.continue.dev/path/to/page" + validations: + required: true - type: textarea id: details attributes: - label: Description of the issue - description: Please describe the issue in detail. If there is missing information or outdated content, provide specifics about what should be added or updated. - value: | - Example: - * Missing section on ... - * Incorrect information stating ... - * Outdated example code ... + label: Issue Description + description: Please describe the issue in detail. Include specifics about missing information, outdated content, or improvements needed. + placeholder: | + Examples: + - Missing section on [topic] + - Incorrect information about [subject] + - Outdated example code for [feature] + - Suggestion to improve [section] by [details] + validations: + required: true - - type: input + - type: textarea id: expected-content attributes: - label: Expected content (optional) + label: Expected Content description: If applicable, provide the content you believe should be added or updated. - placeholder: "Expected details to include in the documentation..." + placeholder: "Suggested details or changes for the documentation..." - - type: input + - type: textarea id: additional-info attributes: - label: Additional Information (optional) - description: Feel free to add any other relevant information that may help us understand and resolve your issue. - placeholder: "Additional details..." + label: Additional Information + description: Add any other relevant information that may help us understand and resolve your issue. + placeholder: "Additional context, screenshots, or related links..." - type: input id: related-issue attributes: - label: Related Issue (optional) - description: Is this issue related to another existing GitHub issue? - placeholder: "e.g., #123" \ No newline at end of file + label: Related Issue + description: If this issue is related to an existing GitHub issue, provide the issue number. + placeholder: "#123" + + - type: checkboxes + id: terms + attributes: + label: Code of Conduct + description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/continuedev/continue/blob/main/CODE_OF_CONDUCT.md) + options: + - label: I agree to follow this project's Code of Conduct + required: true \ No newline at end of file From 9b153d4acf155d99efa65c9dcd0fdc3ed5b22b1b Mon Sep 17 00:00:00 2001 From: Sherman Boyd Date: Thu, 9 Jan 2025 18:10:27 -0700 Subject: [PATCH 111/114] Set page-url as optional --- .github/ISSUE_TEMPLATE/docs_issue_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/docs_issue_report.yml b/.github/ISSUE_TEMPLATE/docs_issue_report.yml index 20be7f044..d04f976f4 100644 --- a/.github/ISSUE_TEMPLATE/docs_issue_report.yml +++ b/.github/ISSUE_TEMPLATE/docs_issue_report.yml @@ -36,7 +36,7 @@ body: description: Provide the URL of the specific page where you encountered the issue. placeholder: "https://docs.continue.dev/path/to/page" validations: - required: true + required: false - type: textarea id: details From cb41d6e7022226f3fd57645683285b152d7e5cca Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Thu, 9 Jan 2025 19:41:00 -0800 Subject: [PATCH 112/114] Update Onboarding.kt --- .../continuedev/continueintellijextension/e2e/Onboarding.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Onboarding.kt b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Onboarding.kt index 2f8cdbbb1..3f667559d 100644 --- a/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Onboarding.kt +++ b/extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/e2e/Onboarding.kt @@ -35,7 +35,7 @@ class Onboarding { fun closeProject(remoteRobot: RemoteRobot) = CommonSteps(remoteRobot).closeProject() - @Test + // @Test @Video fun onboarding(remoteRobot: RemoteRobot): Unit = with(remoteRobot) { welcomeFrame { @@ -82,4 +82,4 @@ class Onboarding { } } } -} \ No newline at end of file +} From c382d3e6e23140c3182d329672586c7a8063efdf Mon Sep 17 00:00:00 2001 From: simon chauvin Date: Fri, 10 Jan 2025 09:36:00 +0100 Subject: [PATCH 113/114] fix - resolve error for http-slash-command --- core/commands/slash/http.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/core/commands/slash/http.ts b/core/commands/slash/http.ts index 2f5e2a7af..7a662561c 100644 --- a/core/commands/slash/http.ts +++ b/core/commands/slash/http.ts @@ -1,5 +1,6 @@ import { SlashCommand } from "../../index.js"; import { removeQuotesAndEscapes } from "../../util/index.js"; +import { streamResponse } from "../../llm/stream.js"; const HttpSlashCommand: SlashCommand = { name: "http", @@ -23,14 +24,8 @@ const HttpSlashCommand: SlashCommand = { if (response.body === null) { throw new Error("Response body is null"); } - const reader = response.body.getReader(); - while (true) { - const { done, value } = await reader.read(); - if (done) { - break; - } - const decoded = new TextDecoder("utf-8").decode(value); - yield decoded; + for await (const chunk of streamResponse(response)) { + yield chunk; } }, }; From a41a4bd2df5807bd216a4b23eabe8656ca098cdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E5=90=95=E6=A5=B8?= Date: Fri, 10 Jan 2025 17:26:49 +0800 Subject: [PATCH 114/114] fix: listDir --- .../continueintellijextension/continue/IntelliJIde.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt index 84ff3fc10..4093a09af 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt @@ -513,7 +513,7 @@ class IntelliJIDE( override suspend fun listDir(dir: String): List> { val files = File(URI(dir)).listFiles()?.map { - listOf(it.name, if (it.isDirectory) FileType.DIRECTORY else FileType.FILE) + listOf(it.name, if (it.isDirectory) FileType.DIRECTORY.value else FileType.FILE.value) } ?: emptyList() return files