Merge branch 'main' into package-python
This commit is contained in:
commit
0f0cbf6d65
6 changed files with 22 additions and 22 deletions
|
|
@ -159,8 +159,9 @@ class ContextManager:
|
|||
if not meilisearch_running:
|
||||
logger.warning(
|
||||
"MeiliSearch not running, avoiding any dependent context providers")
|
||||
self.context_providers = list(
|
||||
filter(lambda cp: cp.title == "code", self.context_providers))
|
||||
self.context_providers = {
|
||||
title: provider for title, provider in self.context_providers.items() if title == "code"
|
||||
}
|
||||
|
||||
async def load_index(self, workspace_dir: str):
|
||||
for _, provider in self.context_providers.items():
|
||||
|
|
|
|||
|
|
@ -196,10 +196,8 @@ class ContinueSDK(AbstractContinueSDK):
|
|||
context_messages: List[ChatMessage] = await self.__autopilot.context_manager.get_chat_messages()
|
||||
|
||||
# Insert at the end, but don't insert after latest user message or function call
|
||||
i = -2 if (len(history_context) > 0 and (
|
||||
history_context[-1].role == "user" or history_context[-1].role == "function")) else -1
|
||||
for msg in context_messages:
|
||||
history_context.insert(i, msg)
|
||||
history_context.insert(-1, msg)
|
||||
|
||||
return history_context
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class LLM(ContinueBaseModel, ABC):
|
|||
requires_unique_id: bool = False
|
||||
requires_write_log: bool = False
|
||||
|
||||
system_message: Union[str, None] = None
|
||||
system_message: Optional[str] = None
|
||||
|
||||
@abstractproperty
|
||||
def name(self):
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
from functools import cached_property
|
||||
import json
|
||||
from typing import Any, Callable, Coroutine, Dict, Generator, List, Literal, Union, Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
from textwrap import dedent
|
||||
from typing import Union
|
||||
from typing import Type, Union
|
||||
|
||||
from ..steps.chat import SimpleChatStep
|
||||
from ..steps.welcome import WelcomeStep
|
||||
|
|
@ -46,7 +46,8 @@ def parse_custom_command(inp: str, config: ContinueConfig) -> Union[None, Step]:
|
|||
|
||||
class DefaultPolicy(Policy):
|
||||
|
||||
default_step: Step = SimpleChatStep()
|
||||
default_step: Type[Step] = SimpleChatStep
|
||||
default_params: dict = {}
|
||||
|
||||
def next(self, config: ContinueConfig, history: History) -> Step:
|
||||
# At the very start, run initial Steps spcecified in the config
|
||||
|
|
@ -75,6 +76,6 @@ class DefaultPolicy(Policy):
|
|||
if user_input.startswith("/edit"):
|
||||
return EditHighlightedCodeStep(user_input=user_input[5:])
|
||||
|
||||
return self.default_step.copy()
|
||||
return self.default_step(**self.default_params)
|
||||
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ class IdeProtocolClient {
|
|||
|
||||
// Setup listeners for any selection changes in open editors
|
||||
vscode.window.onDidChangeTextEditorSelection((event) => {
|
||||
if (this.editorIsTerminal(event.textEditor)) {
|
||||
if (!this.editorIsCode(event.textEditor)) {
|
||||
return;
|
||||
}
|
||||
if (this._highlightDebounce) {
|
||||
|
|
@ -442,17 +442,19 @@ class IdeProtocolClient {
|
|||
// ------------------------------------ //
|
||||
// Respond to request
|
||||
|
||||
private editorIsTerminal(editor: vscode.TextEditor) {
|
||||
return (
|
||||
!!path.basename(editor.document.uri.fsPath).match(/\d/) ||
|
||||
(editor.document.languageId === "plaintext" &&
|
||||
editor.document.getText() === "accessible-buffer-accessible-buffer-")
|
||||
// Checks to see if the editor is a code editor.
|
||||
// In some cases vscode.window.visibleTextEditors can return non-code editors
|
||||
// e.g. terminal editors in side-by-side mode
|
||||
private editorIsCode(editor: vscode.TextEditor) {
|
||||
return !(
|
||||
editor.document.languageId === "plaintext" &&
|
||||
editor.document.getText() === "accessible-buffer-accessible-buffer-"
|
||||
);
|
||||
}
|
||||
|
||||
getOpenFiles(): string[] {
|
||||
return vscode.window.visibleTextEditors
|
||||
.filter((editor) => !this.editorIsTerminal(editor))
|
||||
.filter((editor) => this.editorIsCode(editor))
|
||||
.map((editor) => {
|
||||
return editor.document.uri.fsPath;
|
||||
});
|
||||
|
|
@ -460,7 +462,7 @@ class IdeProtocolClient {
|
|||
|
||||
getVisibleFiles(): string[] {
|
||||
return vscode.window.visibleTextEditors
|
||||
.filter((editor) => !this.editorIsTerminal(editor))
|
||||
.filter((editor) => this.editorIsCode(editor))
|
||||
.map((editor) => {
|
||||
return editor.document.uri.fsPath;
|
||||
});
|
||||
|
|
@ -468,7 +470,7 @@ class IdeProtocolClient {
|
|||
|
||||
saveFile(filepath: string) {
|
||||
vscode.window.visibleTextEditors
|
||||
.filter((editor) => !this.editorIsTerminal(editor))
|
||||
.filter((editor) => this.editorIsCode(editor))
|
||||
.forEach((editor) => {
|
||||
if (editor.document.uri.fsPath === filepath) {
|
||||
editor.document.save();
|
||||
|
|
@ -479,7 +481,7 @@ class IdeProtocolClient {
|
|||
readFile(filepath: string): string {
|
||||
let contents: string | undefined;
|
||||
vscode.window.visibleTextEditors
|
||||
.filter((editor) => !this.editorIsTerminal(editor))
|
||||
.filter((editor) => this.editorIsCode(editor))
|
||||
.forEach((editor) => {
|
||||
if (editor.document.uri.fsPath === filepath) {
|
||||
contents = editor.document.getText();
|
||||
|
|
@ -525,7 +527,7 @@ class IdeProtocolClient {
|
|||
// TODO
|
||||
let rangeInFiles: RangeInFile[] = [];
|
||||
vscode.window.visibleTextEditors
|
||||
.filter((editor) => !this.editorIsTerminal(editor))
|
||||
.filter((editor) => this.editorIsCode(editor))
|
||||
.forEach((editor) => {
|
||||
editor.selections.forEach((selection) => {
|
||||
// if (!selection.isEmpty) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue