From e5cc0c9bf23afe94a05f3153de8f566fde8e2ead Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sat, 18 Nov 2023 22:22:24 -0800 Subject: [PATCH 01/20] =?UTF-8?q?=F0=9F=9A=B8=20keep=20context=20items=20i?= =?UTF-8?q?n=20the=20history?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gui/src/components/ComboBox.tsx | 3 +- gui/src/pages/gui.tsx | 29 +++++--- gui/src/redux/slices/sessionStateReducer.ts | 81 ++++++++++++++------- server/continuedev/core/autopilot.py | 11 ++- server/continuedev/core/main.py | 2 +- server/continuedev/core/sdk.py | 33 +++++---- server/continuedev/core/steps.py | 24 +++++- server/continuedev/plugins/steps/main.py | 3 +- 8 files changed, 119 insertions(+), 67 deletions(-) diff --git a/gui/src/components/ComboBox.tsx b/gui/src/components/ComboBox.tsx index fbeab27ca..0dbcdde42 100644 --- a/gui/src/components/ComboBox.tsx +++ b/gui/src/components/ComboBox.tsx @@ -372,7 +372,8 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { ); const selectedContextItems = useSelector((state: RootStore) => { if (typeof props.index !== "undefined") { - return state.sessionState.contextItemsAtIndex[props.index] || []; + return (state.sessionState.history[props.index].params["context_items"] || + []) as ContextItem[]; } else { return state.sessionState.context_items || []; } diff --git a/gui/src/pages/gui.tsx b/gui/src/pages/gui.tsx index 5c8549a6e..46663a562 100644 --- a/gui/src/pages/gui.tsx +++ b/gui/src/pages/gui.tsx @@ -49,6 +49,7 @@ import { useNavigate } from "react-router-dom"; import { setTakenActionTrue } from "../redux/slices/miscSlice"; import { addContextItemAtIndex, + clearContextItems, deleteAtIndex, newSession, setActive, @@ -305,7 +306,10 @@ function GUI(props: GUIProps) { observations: [], logs: [], step_type: "UserInputStep", - params: { user_input: input }, + params: { + user_input: input, + context_items: sessionState.context_items, + }, hide: false, depth: 0, }, @@ -314,14 +318,6 @@ function GUI(props: GUIProps) { history: newHistory, context_items: sessionState.context_items, }; - for (let contextItem of sessionState.context_items) { - dispatch( - addContextItemAtIndex({ - item: contextItem, - index: newHistory.length - 1, - }) - ); - } client.runFromState(state); newHistory.push({ name: "Generating Response...", @@ -335,6 +331,15 @@ function GUI(props: GUIProps) { }); dispatch(setHistory(newHistory)); dispatch(setActive(true)); + for (let contextItem of sessionState.context_items) { + dispatch( + addContextItemAtIndex({ + item: contextItem, + index: newHistory.length - 1, + }) + ); + } + dispatch(clearContextItems()); // Increment localstorage counter for popup const counter = localStorage.getItem("mainTextEntryCounter"); @@ -742,7 +747,10 @@ function GUI(props: GUIProps) { observations: [], logs: [], step_type: "UserInputStep", - params: { user_input: value }, + params: { + user_input: value, + context_items: sessionState.context_items, + }, hide: false, depth: 0, }, @@ -753,6 +761,7 @@ function GUI(props: GUIProps) { history: newHistory, context_items: sessionState.context_items, }; + dispatch(clearContextItems()); client.runFromState(state); } diff --git a/gui/src/redux/slices/sessionStateReducer.ts b/gui/src/redux/slices/sessionStateReducer.ts index 7cbf10de4..e2c8e4ceb 100644 --- a/gui/src/redux/slices/sessionStateReducer.ts +++ b/gui/src/redux/slices/sessionStateReducer.ts @@ -75,7 +75,6 @@ const TEST_CONTEXT_ITEMS: ContextItem[] = [ export interface SessionFullState { history: StepDescription[]; - contextItemsAtIndex: { [index: number]: ContextItem[] }; context_items: ContextItem[]; active: boolean; title: string; @@ -89,7 +88,6 @@ export const sessionStateSlice = createSlice({ context_items: [], active: false, title: "New Session", - contextItemsAtIndex: {}, session_id: v4(), }, reducers: { @@ -223,16 +221,22 @@ export const sessionStateSlice = createSlice({ state: SessionFullState, { payload }: { payload: { item: ContextItem; index: number } } ) => { - return { - ...state, - contextItemsAtIndex: { - ...state.contextItemsAtIndex, - [payload.index]: [ - ...(state.contextItemsAtIndex[payload.index] ?? []), + let history = [...state.history]; + history[payload.index] = { + ...history[payload.index], + params: { + ...history[payload.index].params, + context_items: [ + ...((history[payload.index].params?.context_items as any) || []), payload.item, ], }, }; + + return { + ...state, + history, + }; }, addHighlightedCode: ( state: SessionFullState, @@ -327,20 +331,32 @@ export const sessionStateSlice = createSlice({ } else { return { ...state, - contextItemsAtIndex: { - ...state.contextItemsAtIndex, - [payload.index]: ( - state.contextItemsAtIndex[payload.index] ?? [] - ).filter( - (item) => - !ids.includes( - `${item.description.id.provider_title}-${item.description.id.item_id}` - ) - ), - }, + history: state.history.map((step, i) => { + if (i === payload.index) { + return { + ...step, + params: { + ...step.params, + context_items: (step.params?.context_items as any).filter( + (item: ContextItem) => + !ids.includes( + `${item.description.id.provider_title}-${item.description.id.item_id}` + ) + ), + }, + }; + } + return step; + }), }; } }, + clearContextItems: (state: SessionFullState) => { + return { + ...state, + context_items: [], + }; + }, setEditingAtIds: ( state: SessionFullState, { @@ -362,17 +378,25 @@ export const sessionStateSlice = createSlice({ } else { return { ...state, - contextItemsAtIndex: { - ...state.contextItemsAtIndex, - [payload.index]: ( - state.contextItemsAtIndex[payload.index] ?? [] - ).map((item) => { + history: state.history.map((step, i) => { + if (i === payload.index) { return { - ...item, - editing: ids.includes(item.description.id.item_id), + ...step, + params: { + ...step.params, + context_items: (step.params?.context_items as any).map( + (item: ContextItem) => { + return { + ...item, + editing: ids.includes(item.description.id.item_id), + }; + } + ), + }, }; - }), - }, + } + return step; + }), }; } }, @@ -391,5 +415,6 @@ export const { deleteContextWithIds, setTitle, setEditingAtIds, + clearContextItems, } = sessionStateSlice.actions; export default sessionStateSlice.reducer; diff --git a/server/continuedev/core/autopilot.py b/server/continuedev/core/autopilot.py index 0242e7532..48dc9e561 100644 --- a/server/continuedev/core/autopilot.py +++ b/server/continuedev/core/autopilot.py @@ -216,9 +216,10 @@ class Autopilot: elif inspect.isasyncgenfunction(step.run): async for update in step.run(self.sdk): # type: ignore (stub type) if self.stopped: - for update in step.on_stop(self.sdk): # type: ignore (stub type) - if handled := handle_step_update(update): - yield handled + if stop_generator := step.on_stop(self.sdk): # type: ignore (stub type) + for update in stop_generator: # type: ignore + if handled := handle_step_update(update): # type: ignore + yield handled return if handled := handle_step_update(update): @@ -329,9 +330,7 @@ class Autopilot: if self.sdk.config.disable_summaries: return "New Session" else: - chat_history = list( - map(lambda x: x.dict(), await self.sdk.get_chat_context()) - ) + chat_history = await self.sdk.get_chat_context() chat_history_str = template_alpaca_messages(chat_history) if self.sdk.models.summarize is None: return "New Session" diff --git a/server/continuedev/core/main.py b/server/continuedev/core/main.py index 2c0030c8e..0bbcdc5f3 100644 --- a/server/continuedev/core/main.py +++ b/server/continuedev/core/main.py @@ -340,7 +340,7 @@ class Step(ContinueBaseModel): return "Running step: " + self.name def on_stop(self, sdk: ContinueSDK) -> Optional[StepGenerator]: - pass + return None def dict(self, *args, **kwargs): d = super().dict(*args, **kwargs) diff --git a/server/continuedev/core/sdk.py b/server/continuedev/core/sdk.py index 98487f749..c54299468 100644 --- a/server/continuedev/core/sdk.py +++ b/server/continuedev/core/sdk.py @@ -215,27 +215,28 @@ class ContinueSDK(AbstractContinueSDK): raise ContinueCustomException(message, title, with_step) async def get_chat_context(self) -> List[ChatMessage]: - history_context = list( - map( - lambda step: ChatMessage( - role="user" if step.step_type == "UserInputStep" else "assistant", + msgs = [] + + for step in filter(lambda x: x.hide is False, self.history): + role = "assistant" + if step.step_type == "UserInputStep": + role = "user" + msgs.extend( + await self.__autopilot.context_manager.get_chat_messages( + [ContextItem(**itm) for itm in step.params["context_items"]] + ) + ) + + msgs.append( + ChatMessage( + role=role, name=step.step_type, content=step.description or f"Ran function {step.name}", summary=f"Called function {step.name}", - ), - filter(lambda x: x.hide is False, self.history[:-1]), + ) ) - ) - context_messages: List[ - ChatMessage - ] = await self.__autopilot.context_manager.get_chat_messages(self.context_items) - - # Insert at the end, but don't insert after latest user message or function call - for msg in context_messages: - history_context.insert(-1, msg) - - return history_context + return msgs async def get_context_item_chat_messages( self, exclude: Optional[str] = None diff --git a/server/continuedev/core/steps.py b/server/continuedev/core/steps.py index fad66ec36..342acda46 100644 --- a/server/continuedev/core/steps.py +++ b/server/continuedev/core/steps.py @@ -3,7 +3,7 @@ import difflib import subprocess import time from textwrap import dedent -from typing import Any, Dict, List, Optional, Union +from typing import Any, AsyncGenerator, Dict, List, Optional, Union from pydantic import Field @@ -20,7 +20,15 @@ from ..libs.util.templating import render_prompt_template from ..models.filesystem import FileSystem, RangeInFile, RangeInFileWithContents from ..models.filesystem_edit import EditDiff, FileEditWithFullContents, FileSystemEdit from .abstract_sdk import AbstractContinueSDK -from .main import ChatMessage, ContinueCustomException, SessionUpdate, SetStep, Step +from .main import ( + ChatMessage, + ContextItem, + ContinueCustomException, + DeltaStep, + SessionUpdate, + SetStep, + Step, +) from .observation import TextObservation, UserInputObservation @@ -373,7 +381,9 @@ Please output the code to be inserted at the cursor in order to fulfill the user or "" in line ) - async def stream_rif(self, rif: RangeInFileWithContents, sdk: AbstractContinueSDK): + async def stream_rif( + self, rif: RangeInFileWithContents, sdk: AbstractContinueSDK + ) -> AsyncGenerator[SetStep, None]: await sdk.ide.saveFile(rif.filepath) full_file_contents = await sdk.ide.readFile(rif.filepath) @@ -640,6 +650,10 @@ Please output the code to be inserted at the cursor in order to fulfill the user try: last_task_time = time.time() async for chunk in generator: + yield SetStep( + hide=False + ) # Doing this so that there are breakpoints for cancellation + # Stop early if it is repeating the file_suffix or the step was deleted if repeating_file_suffix: break @@ -754,7 +768,8 @@ Please output the code to be inserted at the cursor in order to fulfill the user for rif in rif_with_contents: await sdk.ide.setSuggestionsLocked(rif.filepath, True) - await self.stream_rif(rif, sdk) + async for update in self.stream_rif(rif, sdk): + yield update await sdk.ide.setSuggestionsLocked(rif.filepath, False) changes = "\n".join( @@ -854,6 +869,7 @@ class ManualEditStep(ReversibleStep): class UserInputStep(Step): user_input: str + context_items: List[ContextItem] = [] name: str = "User Input" hide: bool = False diff --git a/server/continuedev/plugins/steps/main.py b/server/continuedev/plugins/steps/main.py index 29b23fe6b..81c48810f 100644 --- a/server/continuedev/plugins/steps/main.py +++ b/server/continuedev/plugins/steps/main.py @@ -4,7 +4,7 @@ from typing import List, Optional, Union from pydantic import BaseModel, Field -from ...core.main import ContinueCustomException, SetStep, Step +from ...core.main import ContextItem, ContinueCustomException, SetStep, Step from ...core.sdk import ContinueSDK, Models from ...core.steps import DefaultModelEditCodeStep from ...libs.llm.base import LLM @@ -371,6 +371,7 @@ class EditHighlightedCodeStep(Step): class UserInputStep(Step): user_input: str + context_items: List[ContextItem] = [] class SolveTracebackStep(Step): From f024943cf5fd684cc2de29d4b78a053248db5cf5 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Thu, 23 Nov 2023 00:44:31 +0000 Subject: [PATCH 02/20] =?UTF-8?q?=F0=9F=92=9A=20Update=20package.json=20ve?= =?UTF-8?q?rsion=20[skip=20ci]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/vscode/package-lock.json | 4 ++-- extensions/vscode/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index fafae218a..97ef70cfd 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.7.11", + "version": "0.7.12", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "continue", - "version": "0.7.11", + "version": "0.7.12", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 50e17af88..beba90767 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -1,7 +1,7 @@ { "name": "continue", "icon": "media/icon.png", - "version": "0.7.11", + "version": "0.7.12", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From 33e74b0bbcf07b517ef7ab0877983e1ee7f0351c Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Thu, 23 Nov 2023 11:54:47 -0700 Subject: [PATCH 03/20] =?UTF-8?q?=F0=9F=90=9B=20fix=20deepseek-coder=20pro?= =?UTF-8?q?mpt=20to=20use=20sys=5Fmsg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/continuedev/libs/llm/prompts/chat.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/server/continuedev/libs/llm/prompts/chat.py b/server/continuedev/libs/llm/prompts/chat.py index cc8ba0535..e91fbcdc4 100644 --- a/server/continuedev/libs/llm/prompts/chat.py +++ b/server/continuedev/libs/llm/prompts/chat.py @@ -76,13 +76,18 @@ def template_alpaca_messages(msgs: List[ChatMessage]) -> str: def deepseek_template_messages(msgs: List[ChatMessage]) -> str: prompt = "" + system = None + prompt += "You are an AI programming assistant, utilizing the DeepSeek Coder model, developed by DeepSeek Company, and you only answer questions related to computer science. For politically sensitive questions, security and privacy issues, and other non-computer science questions, you will refuse to answer.\n" if msgs[0].role == "system": - prompt += f"{msgs.pop(0).content}\n" - else: - prompt += "You are an AI programming assistant, utilizing the DeepSeek Coder model, developed by DeepSeek Company, and you only answer questions related to computer science. For politically sensitive questions, security and privacy issues, and other non-computer science questions, you will refuse to answer.\n" + system = msgs.pop(0).content - for msg in msgs: + for i in range(len(msgs)): + msg = msgs[i] prompt += "### Instruction:\n" if msg.role == "user" else "### Response:\n" + + if system and msg.role == "user" and i == len(msgs) - 1: + prompt += system + "\n" + prompt += f"{msg.content}" prompt += "\n" if msg.role == "user" else "<|EOT|>\n" From 59de38af0881bd1325c4e22b68edbf3ec723b179 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Thu, 23 Nov 2023 19:07:17 +0000 Subject: [PATCH 04/20] =?UTF-8?q?=F0=9F=92=9A=20Update=20package.json=20ve?= =?UTF-8?q?rsion=20[skip=20ci]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/vscode/package-lock.json | 4 ++-- extensions/vscode/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 97ef70cfd..936d53221 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.7.12", + "version": "0.7.13", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "continue", - "version": "0.7.12", + "version": "0.7.13", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index beba90767..363586a77 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -1,7 +1,7 @@ { "name": "continue", "icon": "media/icon.png", - "version": "0.7.12", + "version": "0.7.13", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From ff481ae2291af04540774972070399d640558907 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Thu, 23 Nov 2023 13:39:50 -0700 Subject: [PATCH 05/20] =?UTF-8?q?=F0=9F=90=9B=20temp=20fix=20for=20highlig?= =?UTF-8?q?hting=20in=20.ipynb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/context_providers/highlighted_code.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/continuedev/plugins/context_providers/highlighted_code.py b/server/continuedev/plugins/context_providers/highlighted_code.py index 583c7fd90..8f0bac9be 100644 --- a/server/continuedev/plugins/context_providers/highlighted_code.py +++ b/server/continuedev/plugins/context_providers/highlighted_code.py @@ -84,7 +84,13 @@ class HighlightedCodeContextProvider(ContextProvider): filepath=item.description.description, range=Range.from_shorthand(int(lines[0]) - 1, 0, int(lines[1]), 0), ) - contents = await ide.readRangeInFile(rif) + # Temporary fix because reading the range in the file returns the raw JSON of the notebook + # , but we have the actual contents from when it was originally highlighted + if item.description.description.endswith(".ipynb"): + contents = item.content + else: + contents = await ide.readRangeInFile(rif) + return rif.with_contents(contents) async def get_chat_message(self, item: ContextItem) -> ChatMessage: From 6f43116fafbb53bb841ab858ef3b9f79b2b766b7 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Thu, 23 Nov 2023 20:51:41 +0000 Subject: [PATCH 06/20] =?UTF-8?q?=F0=9F=92=9A=20Update=20package.json=20ve?= =?UTF-8?q?rsion=20[skip=20ci]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/vscode/package-lock.json | 4 ++-- extensions/vscode/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 936d53221..9ee12ca65 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.7.13", + "version": "0.7.14", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "continue", - "version": "0.7.13", + "version": "0.7.14", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 363586a77..b9e062fa7 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -1,7 +1,7 @@ { "name": "continue", "icon": "media/icon.png", - "version": "0.7.13", + "version": "0.7.14", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From 69fd15788e47d03386d5a926687071904252640c Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Fri, 24 Nov 2023 08:53:00 -0700 Subject: [PATCH 07/20] =?UTF-8?q?=E2=9C=A8=20add=20option=20to=20change=20?= =?UTF-8?q?completions=20endpoint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/continuedev/libs/llm/ggml.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/server/continuedev/libs/llm/ggml.py b/server/continuedev/libs/llm/ggml.py index bfedebf9e..226749603 100644 --- a/server/continuedev/libs/llm/ggml.py +++ b/server/continuedev/libs/llm/ggml.py @@ -53,6 +53,14 @@ class GGML(LLM): default=None, description="OpenAI engine. For use with Azure OpenAI Service." ) + chat_endpoint: str = Field( + default="chat/completions", description="The endpoint to call for chat completions" + ) + + completions_endpoint: str = Field( + default="completions", description="The endpoint to call for chat completions" + ) + class Config: arbitrary_types_allowed = True @@ -86,7 +94,7 @@ class GGML(LLM): async with self.create_client_session() as client_session: async with client_session.post( - self.get_full_server_url(endpoint="completions"), + self.get_full_server_url(endpoint=self.completions_endpoint), json={ "prompt": prompt, "stream": True, @@ -131,7 +139,7 @@ class GGML(LLM): async def generator() -> AsyncGenerator[Any, None]: async with self.create_client_session() as client_session: async with client_session.post( - self.get_full_server_url(endpoint="chat/completions"), + self.get_full_server_url(endpoint=self.chat_endpoint), json={ "messages": [msg.to_dict() for msg in messages], "stream": True, @@ -196,7 +204,7 @@ class GGML(LLM): async with self.create_client_session() as client_session: async with client_session.post( - self.get_full_server_url(endpoint="completions"), + self.get_full_server_url(endpoint=self.completions_endpoint), json={ "prompt": prompt, **args, From 03a1ed5c37f59c7dd497a82650ceb272a7e14b80 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Fri, 24 Nov 2023 16:39:41 +0000 Subject: [PATCH 08/20] =?UTF-8?q?=F0=9F=92=9A=20Update=20package.json=20ve?= =?UTF-8?q?rsion=20[skip=20ci]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/vscode/package-lock.json | 4 ++-- extensions/vscode/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 9ee12ca65..b92405206 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.7.14", + "version": "0.7.15", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "continue", - "version": "0.7.14", + "version": "0.7.15", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index b9e062fa7..9265cc4ea 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -1,7 +1,7 @@ { "name": "continue", "icon": "media/icon.png", - "version": "0.7.14", + "version": "0.7.15", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From fc38b37458329ad88aacb6867115e5093aefcd57 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sat, 25 Nov 2023 09:04:27 -0700 Subject: [PATCH 09/20] =?UTF-8?q?=F0=9F=90=9B=20remove=20extra=20msg=20bei?= =?UTF-8?q?ng=20inserted=20in=20chat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/continuedev/plugins/steps/chat.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/continuedev/plugins/steps/chat.py b/server/continuedev/plugins/steps/chat.py index e84c75988..f7d9f59d8 100644 --- a/server/continuedev/plugins/steps/chat.py +++ b/server/continuedev/plugins/steps/chat.py @@ -24,6 +24,8 @@ class SimpleChatStep(Step): messages: Optional[List[ChatMessage]] = None prompt: Optional[str] = None + hide: bool = True + completion_options: Optional[CompletionOptions] = None async def run(self, sdk: ContinueSDK): @@ -50,7 +52,7 @@ class SimpleChatStep(Step): kwargs = self.completion_options.dict() if self.completion_options else {} generator = sdk.models.chat.stream_chat(messages, **kwargs) - yield SetStep(description="") + yield SetStep(description="", hide=False) async for chunk in generator: if chunk.content != "": yield chunk.content From 38a58ace8ef02d9db5adaeee7d74eaada576a9b7 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sat, 25 Nov 2023 17:04:32 +0000 Subject: [PATCH 10/20] =?UTF-8?q?=F0=9F=92=9A=20Update=20package.json=20ve?= =?UTF-8?q?rsion=20[skip=20ci]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/vscode/package-lock.json | 4 ++-- extensions/vscode/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index b92405206..f50a5c802 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.7.15", + "version": "0.7.16", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "continue", - "version": "0.7.15", + "version": "0.7.16", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 9265cc4ea..aa63f34b9 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -1,7 +1,7 @@ { "name": "continue", "icon": "media/icon.png", - "version": "0.7.15", + "version": "0.7.16", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From 5a5fbbfbfa0b810352c6653b2df966adff543272 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sat, 25 Nov 2023 11:56:52 -0700 Subject: [PATCH 11/20] =?UTF-8?q?=F0=9F=90=9B=20use=20retrieval=5Fsettings?= =?UTF-8?q?.ignore=5Ffiles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/continuedev/libs/index/build_index.py | 5 ++++- .../continuedev/libs/index/chunkers/chunk_directory.py | 9 +++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/server/continuedev/libs/index/build_index.py b/server/continuedev/libs/index/build_index.py index cf40b309a..36aff5f54 100644 --- a/server/continuedev/libs/index/build_index.py +++ b/server/continuedev/libs/index/build_index.py @@ -61,7 +61,10 @@ async def build_index( chroma_task = asyncio.create_task(chroma_task()) meilisearch_task = asyncio.create_task(meilisearch_task()) - async for chunk, progress in stream_chunk_directory(ide, MAX_CHUNK_SIZE): + ignore_files = settings.ignore_files if settings else [] + async for chunk, progress in stream_chunk_directory( + ide, MAX_CHUNK_SIZE, ignore_files=ignore_files + ): if chunk is not None: buffers[0].append(chunk) buffers[1].append(chunk) diff --git a/server/continuedev/libs/index/chunkers/chunk_directory.py b/server/continuedev/libs/index/chunkers/chunk_directory.py index 07e7f3f1d..3023b1458 100644 --- a/server/continuedev/libs/index/chunkers/chunk_directory.py +++ b/server/continuedev/libs/index/chunkers/chunk_directory.py @@ -4,9 +4,8 @@ from typing import AsyncGenerator, Callable, List, Optional, Tuple from ....server.protocols.ide_protocol import AbstractIdeProtocolServer from ...util.filter_files import DEFAULT_IGNORE_PATTERNS, should_filter_path -from .chunk import Chunk from . import chunk_document - +from .chunk import Chunk FILE_IGNORE_PATTERNS = [ # File Names @@ -150,9 +149,11 @@ async def stream_file_contents( async def stream_chunk_directory( - ide: AbstractIdeProtocolServer, max_chunk_size: int + ide: AbstractIdeProtocolServer, max_chunk_size: int, ignore_files: List[str] = [] ) -> AsyncGenerator[Tuple[Optional[Chunk], float], None]: - async for file, contents, progress in stream_file_contents(ide): + async for file, contents, progress in stream_file_contents( + ide, ignore_files=ignore_files + ): if contents is None: yield (None, progress) continue From 0dafdcffa678c86763547109c3eb06ae6a784de9 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sat, 25 Nov 2023 19:09:27 +0000 Subject: [PATCH 12/20] =?UTF-8?q?=F0=9F=92=9A=20Update=20package.json=20ve?= =?UTF-8?q?rsion=20[skip=20ci]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/vscode/package-lock.json | 4 ++-- extensions/vscode/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index f50a5c802..c5ec4eab3 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.7.16", + "version": "0.7.17", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "continue", - "version": "0.7.16", + "version": "0.7.17", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index aa63f34b9..fa9005d08 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -1,7 +1,7 @@ { "name": "continue", "icon": "media/icon.png", - "version": "0.7.16", + "version": "0.7.17", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From 7c46ea7a86b7200ef9915416cf2a3cfcc3651250 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sat, 25 Nov 2023 20:05:58 -0700 Subject: [PATCH 13/20] =?UTF-8?q?=F0=9F=90=9B=20fix=20max=5Ftokens=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/continuedev/core/steps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/continuedev/core/steps.py b/server/continuedev/core/steps.py index 8439d45db..6948f4755 100644 --- a/server/continuedev/core/steps.py +++ b/server/continuedev/core/steps.py @@ -625,7 +625,7 @@ Please output the code to be inserted at the cursor in order to fulfill the user params.update(template.dict(exclude={"prompt"})) # type: ignore params.update( - {"max_tokens": min(max_tokens, model_to_use.context_length // 2)} + {"max_tokens": min(max_tokens, model_to_use.context_length // 2, 4096)} ) generator = model_to_use.stream_complete(**params) From 4f651ea7c33810f6b40c877f2f7ab2ae79afc378 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 26 Nov 2023 03:19:30 +0000 Subject: [PATCH 14/20] =?UTF-8?q?=F0=9F=92=9A=20Update=20package.json=20ve?= =?UTF-8?q?rsion=20[skip=20ci]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/vscode/package-lock.json | 4 ++-- extensions/vscode/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index c5ec4eab3..37e0eb3b7 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.7.17", + "version": "0.7.18", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "continue", - "version": "0.7.17", + "version": "0.7.18", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index fa9005d08..5cdc0ed83 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -1,7 +1,7 @@ { "name": "continue", "icon": "media/icon.png", - "version": "0.7.17", + "version": "0.7.18", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From 56232545cff30591077b2bffa5015905bf314073 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Tue, 28 Nov 2023 23:21:06 -0800 Subject: [PATCH 15/20] =?UTF-8?q?=F0=9F=93=9D=20update=20CONTRIBUTING.md,?= =?UTF-8?q?=20add=20button=20to=20open=20config.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CONTRIBUTING.md | 4 ++++ extensions/vscode/src/util/vscode.ts | 7 +++++++ gui/src/pages/settings.tsx | 28 +++++++++++++++++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 82ddb9ed1..2ba685932 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -81,6 +81,10 @@ VSCode is assumed for development as Continue is primarily a VSCode tool at the 2. Search for a method `sendHighlightedCode` and set a breakpoint in it, it is invoked on every selection change on the extension side 2. _In Host VSCode_: Select part of the `example.ts` file, your breakpoint should be hit. If you hit play at this point (or F5) you should see the original breakpoint hit again - congratulations, you debugged an end to end interaction from the extension to the server! +### Formatting + +Continue uses the [Black Formatter](https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter) for Python and [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) for JavaScript/TypeScript. Please install these extensions in VSCode and enable "Format on Save" in your settings. + ### Writing Steps A Step can be used as a custom slash command, or called otherwise in a `Policy`. See the [steps README](./server/continuedev/plugins/steps/README.md) to learn how to write a Step. diff --git a/extensions/vscode/src/util/vscode.ts b/extensions/vscode/src/util/vscode.ts index 92bbc1102..ae05ba12f 100644 --- a/extensions/vscode/src/util/vscode.ts +++ b/extensions/vscode/src/util/vscode.ts @@ -1,5 +1,6 @@ import * as vscode from "vscode"; import { machineIdSync } from "node-machine-id"; +import * as path from "path"; export function translate(range: vscode.Range, lines: number): vscode.Range { return new vscode.Range( @@ -74,6 +75,12 @@ export function openEditorAndRevealRange( viewColumn?: vscode.ViewColumn ): Promise { return new Promise((resolve, _) => { + if (editorFilename.startsWith("~")) { + editorFilename = path.join( + process.env.HOME || process.env.USERPROFILE || "", + editorFilename.slice(1) + ); + } vscode.workspace.openTextDocument(editorFilename).then(async (doc) => { try { // An error is thrown mysteriously if you open two documents in parallel, hence this diff --git a/gui/src/pages/settings.tsx b/gui/src/pages/settings.tsx index f9286ec29..bf4a4ee19 100644 --- a/gui/src/pages/settings.tsx +++ b/gui/src/pages/settings.tsx @@ -17,7 +17,8 @@ import { ArrowLeftIcon } from "@heroicons/react/24/outline"; import Loader from "../components/loaders/Loader"; import InfoHover from "../components/InfoHover"; import { FormProvider, useForm } from "react-hook-form"; -import { getFontSize } from "../util"; +import { getFontSize, getPlatform } from "../util"; +import { postToIde } from "../util/ide"; const Hr = styled.hr` border: 0.5px solid ${lightGray}; @@ -78,6 +79,19 @@ const Slider = styled.input.attrs({ type: "range" })` border: none; } `; + +const ConfigJsonButton = styled(Button)` + padding: 2px 4px; + margin-left: auto; + margin-right: 4px; + background-color: transparent; + color: white; + border: 1px solid ${lightGray}; + &:hover { + background-color: ${lightGray}; + } +`; + const ALL_MODEL_ROLES = ["default", "summarize", "edit", "chat"]; function Settings() { @@ -139,6 +153,18 @@ function Settings() { className="inline-block ml-4 cursor-pointer" />

Settings

+ { + postToIde("showFile", { + filepath: + getPlatform() == "windows" + ? "~\\.continue\\config.json" + : "~/.continue/config.json", + }); + }} + > + Open config.json +
{config ? ( From 462f0ade8142e08547b157c3b798e9734b95392b Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 29 Nov 2023 16:46:36 -0800 Subject: [PATCH 16/20] =?UTF-8?q?=F0=9F=9A=B8=20make=20model=20config=20mo?= =?UTF-8?q?re=20intuitive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/vscode/schema/ContinueConfig.d.ts | 108 +++-- extensions/vscode/schema/Models.d.ts | 6 +- gui/src/client/ContinueGUIClientProtocol.ts | 4 +- gui/src/components/mainInput/ComboBox.tsx | 6 +- .../components/modelSelection/ModelSelect.tsx | 62 +-- gui/src/redux/selectors/configSelectors.ts | 18 + gui/src/schema/ContinueConfig.d.ts | 108 +++-- gui/src/schema/Models.d.ts | 6 +- schema/json/ContinueConfig.json | 378 +++++------------- schema/json/Models.json | 5 +- server/continuedev/core/autopilot.py | 4 +- server/continuedev/core/config.py | 187 +++------ server/continuedev/core/models.py | 16 +- server/continuedev/core/sdk.py | 7 +- server/continuedev/headless/__init__.py | 6 +- server/continuedev/libs/llm/anthropic.py | 4 +- server/continuedev/libs/llm/base.py | 2 +- server/continuedev/libs/llm/ollama.py | 22 +- server/continuedev/libs/llm/openai.py | 4 +- .../continuedev/libs/llm/openai_free_trial.py | 6 +- server/continuedev/libs/llm/proxy_server.py | 4 +- server/continuedev/libs/llm/queued.py | 6 +- server/continuedev/plugins/steps/codebase.py | 63 +-- server/continuedev/server/protocols/gui.py | 17 +- server/continuedev/server/protocols/ide.py | 9 +- .../server/protocols/ide_protocol.py | 11 +- server/continuedev/server/window_manager.py | 13 - server/tests/config/config_json_test.py | 10 +- server/tests/llm_test.py | 2 +- server/tests/util/config.py | 16 +- 30 files changed, 458 insertions(+), 652 deletions(-) create mode 100644 gui/src/redux/selectors/configSelectors.ts diff --git a/extensions/vscode/schema/ContinueConfig.d.ts b/extensions/vscode/schema/ContinueConfig.d.ts index cd3524ca2..694458fbd 100644 --- a/extensions/vscode/schema/ContinueConfig.d.ts +++ b/extensions/vscode/schema/ContinueConfig.d.ts @@ -32,29 +32,46 @@ export type DisallowedSteps = string[]; */ export type AllowAnonymousTelemetry = boolean; /** - * Configuration for the models used by Continue. Read more about how to configure models in the documentation. - */ -export type Models = Models1; -/** - * A title that will identify this model in the model selection dropdown + * The title you wish to give your model. */ export type Title = string; /** - * The unique ID of the user. + * The provider of the model. This is used to determine the type of model, and how to interact with it. */ -export type UniqueId = string; +export type Provider = + | "openai" + | "openai-free-trial" + | "openai-aiohttp" + | "anthropic" + | "together" + | "ollama" + | "huggingface-tgi" + | "huggingface-inference-api" + | "llama.cpp" + | "replicate" + | "text-gen-webui" + | "google-palm" + | "lmstudio"; /** - * The name of the model to be used (e.g. gpt-4, codellama) + * The name of the model. Used to autodetect prompt template. */ export type Model = string; /** - * A system message that will always be followed by the LLM + * OpenAI, Anthropic, Together, or other API key */ -export type SystemMessage1 = string; +export type ApiKey = string; +/** + * The base URL of the LLM API. + */ +export type ApiBase = string; /** * The maximum context length of the LLM in tokens, as counted by count_tokens. */ export type ContextLength = number; +/** + * The chat template used to format messages. This is auto-detected for most models, but can be overridden here. + */ +export type Template = "llama2" | "alpaca" | "zephyr" | "phind" | "anthropic" | "chatml" | "deepseek"; /** * Options for the completion endpoint. Read more about the completion options in the documentation. */ @@ -87,6 +104,10 @@ export type Stop = string[]; * The maximum number of tokens to generate. */ export type MaxTokens = number; +/** + * A system message that will always be followed by the LLM + */ +export type SystemMessage1 = string; /** * Options for the HTTP request to the LLM. */ @@ -107,21 +128,31 @@ export type CaBundlePath = string; * Proxy URL to use when making the HTTP request */ export type Proxy = string; +export type Models = ModelDescription[]; /** - * The API key for the LLM provider. + * Roles for models. Each entry should be the title of a model in the models array. */ -export type ApiKey = string; +export type ModelRoles = ModelRoles1; /** - * The base URL of the LLM API. + * The default model. If other model roles are not set, they will fall back to default. */ -export type ApiBase = string; -export type Saved = LLM[]; -export type Temperature1 = number; -export type SystemMessage2 = string; +export type Default = string; +/** + * The model to use for chat. If not set, will fall back to default. + */ +export type Chat = string; +/** + * The model to use for editing. If not set, will fall back to default. + */ +export type Edit = string; +/** + * The model to use for summarization. If not set, will fall back to default. + */ +export type Summarize = string; /** * A system message that will always be followed by the LLM */ -export type SystemMessage3 = string; +export type SystemMessage2 = string; /** * Options for the completion endpoint. Read more about the completion options in the documentation. */ @@ -264,7 +295,8 @@ export interface ContinueConfig1 { disallowed_steps?: DisallowedSteps; allow_anonymous_telemetry?: AllowAnonymousTelemetry; models?: Models; - system_message?: SystemMessage3; + model_roles?: ModelRoles; + system_message?: SystemMessage2; completion_options?: CompletionOptions1; custom_commands?: CustomCommands; slash_commands?: SlashCommands; @@ -301,30 +333,17 @@ export interface FunctionCall { arguments: Arguments; [k: string]: unknown; } -/** - * Main class that holds the current model configuration - */ -export interface Models1 { - default: LLM; - summarize?: LLM; - edit?: LLM; - chat?: LLM; - saved?: Saved; - temperature?: Temperature1; - system_message?: SystemMessage2; - [k: string]: unknown; -} -export interface LLM { - title?: Title; - unique_id?: UniqueId; +export interface ModelDescription { + title: Title; + provider: Provider; model: Model; - system_message?: SystemMessage1; - context_length?: ContextLength; - completion_options?: CompletionOptions; - request_options?: RequestOptions; - prompt_templates?: PromptTemplates; api_key?: ApiKey; api_base?: ApiBase; + context_length?: ContextLength; + template?: Template; + completion_options?: CompletionOptions; + system_message?: SystemMessage1; + request_options?: RequestOptions; [k: string]: unknown; } export interface BaseCompletionOptions { @@ -351,10 +370,11 @@ export interface RequestOptions1 { export interface Headers { [k: string]: string; } -/** - * A dictionary of prompt templates that can be used to customize the behavior of the LLM in certain situations. For example, set the "edit" key in order to change the prompt that is used for the /edit slash command. Each value in the dictionary is a string templated in mustache syntax, and filled in at runtime with the variables specific to the situation. See the documentation for more information. - */ -export interface PromptTemplates { +export interface ModelRoles1 { + default: Default; + chat?: Chat; + edit?: Edit; + summarize?: Summarize; [k: string]: unknown; } export interface CustomCommand { diff --git a/extensions/vscode/schema/Models.d.ts b/extensions/vscode/schema/Models.d.ts index 683995905..e24d6d587 100644 --- a/extensions/vscode/schema/Models.d.ts +++ b/extensions/vscode/schema/Models.d.ts @@ -95,9 +95,9 @@ export type SystemMessage1 = string; */ export interface Models1 { default: LLM; - summarize?: LLM; - edit?: LLM; - chat?: LLM; + summarize: LLM; + edit: LLM; + chat: LLM; saved?: Saved; temperature?: Temperature1; system_message?: SystemMessage1; diff --git a/gui/src/client/ContinueGUIClientProtocol.ts b/gui/src/client/ContinueGUIClientProtocol.ts index 321e55227..a67a212ba 100644 --- a/gui/src/client/ContinueGUIClientProtocol.ts +++ b/gui/src/client/ContinueGUIClientProtocol.ts @@ -221,8 +221,8 @@ class ContinueGUIClientProtocol extends AbstractContinueGUIClientProtocol { this.messenger?.send("add_model_for_role", { role, model }); } - setModelForRoleFromIndex(role: string, index: number): void { - this.messenger?.send("set_model_for_role_from_index", { role, index }); + setModelForRoleFromTitle(role: string, title: string): void { + this.messenger?.send("set_model_for_role_from_title", { role, title }); } saveContextGroup(title: string, contextItems: ContextItem[]): void { diff --git a/gui/src/components/mainInput/ComboBox.tsx b/gui/src/components/mainInput/ComboBox.tsx index 4af7c9661..fed059f28 100644 --- a/gui/src/components/mainInput/ComboBox.tsx +++ b/gui/src/components/mainInput/ComboBox.tsx @@ -71,6 +71,7 @@ import { } from "../../redux/slices/sessionStateReducer"; import RingLoader from "../loaders/RingLoader"; import CodeSnippetPreview from "../markdown/CodeSnippetPreview"; +import { contextLengthSelector } from "../../redux/selectors/configSelectors"; const SEARCH_INDEX_NAME = "continue_context_items"; @@ -803,10 +804,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { const [contextLengthFillPercentage, setContextLengthFillPercentage] = useState(0); - const contextLength = useSelector( - (store: RootStore) => - store.serverState.config.models?.default?.context_length || 4096 - ); + const contextLength = useSelector(contextLengthSelector); useEffect(() => { let tokenEstimate = selectedContextItems.reduce((acc, item) => { diff --git a/gui/src/components/modelSelection/ModelSelect.tsx b/gui/src/components/modelSelection/ModelSelect.tsx index e5911ef58..1a334991b 100644 --- a/gui/src/components/modelSelection/ModelSelect.tsx +++ b/gui/src/components/modelSelection/ModelSelect.tsx @@ -20,6 +20,7 @@ import { useNavigate } from "react-router-dom"; import { Listbox, Transition } from "@headlessui/react"; import ReactDOM from "react-dom"; import HeaderButtonWithText from "../HeaderButtonWithText"; +import { defaultModelSelector } from "../../redux/selectors/configSelectors"; const GridDiv = styled.div` display: grid; @@ -157,7 +158,7 @@ function ListBoxOption({ option, idx }: { option: Option; idx: number }) { >
{option.title} - {idx > 0 && hovered && ( + {hovered && ( { @@ -195,51 +196,33 @@ interface Option { function ModelSelect(props: {}) { const client = useContext(GUIClientContext); - const defaultModel = useSelector( - (state: RootStore) => (state.serverState.config as any)?.models?.default - ); - const savedModels = useSelector( - (state: RootStore) => (state.serverState.config as any)?.models?.saved + const defaultModel = useSelector(defaultModelSelector); + const allModels = useSelector( + (state: RootStore) => state.serverState.config.models ); const navigate = useNavigate(); const DEFAULT_OPTION = { - value: JSON.stringify({ - t: "default", - idx: -1, - }), + value: "GPT-4", title: "GPT-4", }; const [options, setOptions] = useState([DEFAULT_OPTION]); useEffect(() => { - if (!defaultModel && !savedModels) { + if (!allModels) { setOptions([DEFAULT_OPTION]); return; } - const newOptions: Option[] = []; - if (defaultModel) { - newOptions.push({ - value: JSON.stringify({ - t: "default", - idx: -1, - }), - title: modelSelectTitle(defaultModel), - }); - } - - savedModels?.forEach((model: any, idx: number) => { - newOptions.push({ - value: JSON.stringify({ - t: "saved", - idx, - }), - title: modelSelectTitle(model), - }); - }); - setOptions(newOptions); - }, [defaultModel, savedModels]); + setOptions( + allModels.map((model) => { + return { + value: model.title, + title: modelSelectTitle(model), + }; + }) + ); + }, [allModels]); const topDiv = document.getElementById("model-select-top-div"); @@ -247,17 +230,12 @@ function ModelSelect(props: {}) { <> { - const value = JSON.parse(val); - if (value.t === "saved") { - client?.setModelForRoleFromIndex("*", value.idx); - } + if (val === defaultModel.title) return; + client?.setModelForRoleFromTitle("*", val); }} - defaultValue={"0"} + defaultValue={"GPT-4"} >
diff --git a/gui/src/redux/selectors/configSelectors.ts b/gui/src/redux/selectors/configSelectors.ts new file mode 100644 index 000000000..e3c6226fe --- /dev/null +++ b/gui/src/redux/selectors/configSelectors.ts @@ -0,0 +1,18 @@ +import { RootStore } from "../store"; + +export const contextLengthSelector = (state: RootStore) => { + return ( + { + "gpt-4": 8096, + "gpt-3.5-turbo": 4096, + "gpt-3.5-turbo-16k": 16384, + "gpt-4-32k": 32768, + "claude-2": 16384, + }[state.serverState.config.model_roles?.default] || 4096 + ); +}; + +export const defaultModelSelector = (state: RootStore) => { + const title = state.serverState.config.model_roles?.default; + return state.serverState.config.models.find((model) => model.title === title); +}; diff --git a/gui/src/schema/ContinueConfig.d.ts b/gui/src/schema/ContinueConfig.d.ts index cd3524ca2..694458fbd 100644 --- a/gui/src/schema/ContinueConfig.d.ts +++ b/gui/src/schema/ContinueConfig.d.ts @@ -32,29 +32,46 @@ export type DisallowedSteps = string[]; */ export type AllowAnonymousTelemetry = boolean; /** - * Configuration for the models used by Continue. Read more about how to configure models in the documentation. - */ -export type Models = Models1; -/** - * A title that will identify this model in the model selection dropdown + * The title you wish to give your model. */ export type Title = string; /** - * The unique ID of the user. + * The provider of the model. This is used to determine the type of model, and how to interact with it. */ -export type UniqueId = string; +export type Provider = + | "openai" + | "openai-free-trial" + | "openai-aiohttp" + | "anthropic" + | "together" + | "ollama" + | "huggingface-tgi" + | "huggingface-inference-api" + | "llama.cpp" + | "replicate" + | "text-gen-webui" + | "google-palm" + | "lmstudio"; /** - * The name of the model to be used (e.g. gpt-4, codellama) + * The name of the model. Used to autodetect prompt template. */ export type Model = string; /** - * A system message that will always be followed by the LLM + * OpenAI, Anthropic, Together, or other API key */ -export type SystemMessage1 = string; +export type ApiKey = string; +/** + * The base URL of the LLM API. + */ +export type ApiBase = string; /** * The maximum context length of the LLM in tokens, as counted by count_tokens. */ export type ContextLength = number; +/** + * The chat template used to format messages. This is auto-detected for most models, but can be overridden here. + */ +export type Template = "llama2" | "alpaca" | "zephyr" | "phind" | "anthropic" | "chatml" | "deepseek"; /** * Options for the completion endpoint. Read more about the completion options in the documentation. */ @@ -87,6 +104,10 @@ export type Stop = string[]; * The maximum number of tokens to generate. */ export type MaxTokens = number; +/** + * A system message that will always be followed by the LLM + */ +export type SystemMessage1 = string; /** * Options for the HTTP request to the LLM. */ @@ -107,21 +128,31 @@ export type CaBundlePath = string; * Proxy URL to use when making the HTTP request */ export type Proxy = string; +export type Models = ModelDescription[]; /** - * The API key for the LLM provider. + * Roles for models. Each entry should be the title of a model in the models array. */ -export type ApiKey = string; +export type ModelRoles = ModelRoles1; /** - * The base URL of the LLM API. + * The default model. If other model roles are not set, they will fall back to default. */ -export type ApiBase = string; -export type Saved = LLM[]; -export type Temperature1 = number; -export type SystemMessage2 = string; +export type Default = string; +/** + * The model to use for chat. If not set, will fall back to default. + */ +export type Chat = string; +/** + * The model to use for editing. If not set, will fall back to default. + */ +export type Edit = string; +/** + * The model to use for summarization. If not set, will fall back to default. + */ +export type Summarize = string; /** * A system message that will always be followed by the LLM */ -export type SystemMessage3 = string; +export type SystemMessage2 = string; /** * Options for the completion endpoint. Read more about the completion options in the documentation. */ @@ -264,7 +295,8 @@ export interface ContinueConfig1 { disallowed_steps?: DisallowedSteps; allow_anonymous_telemetry?: AllowAnonymousTelemetry; models?: Models; - system_message?: SystemMessage3; + model_roles?: ModelRoles; + system_message?: SystemMessage2; completion_options?: CompletionOptions1; custom_commands?: CustomCommands; slash_commands?: SlashCommands; @@ -301,30 +333,17 @@ export interface FunctionCall { arguments: Arguments; [k: string]: unknown; } -/** - * Main class that holds the current model configuration - */ -export interface Models1 { - default: LLM; - summarize?: LLM; - edit?: LLM; - chat?: LLM; - saved?: Saved; - temperature?: Temperature1; - system_message?: SystemMessage2; - [k: string]: unknown; -} -export interface LLM { - title?: Title; - unique_id?: UniqueId; +export interface ModelDescription { + title: Title; + provider: Provider; model: Model; - system_message?: SystemMessage1; - context_length?: ContextLength; - completion_options?: CompletionOptions; - request_options?: RequestOptions; - prompt_templates?: PromptTemplates; api_key?: ApiKey; api_base?: ApiBase; + context_length?: ContextLength; + template?: Template; + completion_options?: CompletionOptions; + system_message?: SystemMessage1; + request_options?: RequestOptions; [k: string]: unknown; } export interface BaseCompletionOptions { @@ -351,10 +370,11 @@ export interface RequestOptions1 { export interface Headers { [k: string]: string; } -/** - * A dictionary of prompt templates that can be used to customize the behavior of the LLM in certain situations. For example, set the "edit" key in order to change the prompt that is used for the /edit slash command. Each value in the dictionary is a string templated in mustache syntax, and filled in at runtime with the variables specific to the situation. See the documentation for more information. - */ -export interface PromptTemplates { +export interface ModelRoles1 { + default: Default; + chat?: Chat; + edit?: Edit; + summarize?: Summarize; [k: string]: unknown; } export interface CustomCommand { diff --git a/gui/src/schema/Models.d.ts b/gui/src/schema/Models.d.ts index 683995905..e24d6d587 100644 --- a/gui/src/schema/Models.d.ts +++ b/gui/src/schema/Models.d.ts @@ -95,9 +95,9 @@ export type SystemMessage1 = string; */ export interface Models1 { default: LLM; - summarize?: LLM; - edit?: LLM; - chat?: LLM; + summarize: LLM; + edit: LLM; + chat: LLM; saved?: Saved; temperature?: Temperature1; system_message?: SystemMessage1; diff --git a/schema/json/ContinueConfig.json b/schema/json/ContinueConfig.json index f1480a714..b10be7a36 100644 --- a/schema/json/ContinueConfig.json +++ b/schema/json/ContinueConfig.json @@ -177,28 +177,48 @@ } } }, - "LLM": { - "title": "LLM", + "ModelDescription": { + "title": "ModelDescription", "type": "object", "properties": { "title": { "title": "Title", - "description": "A title that will identify this model in the model selection dropdown", + "description": "The title you wish to give your model.", "type": "string" }, - "unique_id": { - "title": "Unique Id", - "description": "The unique ID of the user.", + "provider": { + "title": "Provider", + "description": "The provider of the model. This is used to determine the type of model, and how to interact with it.", + "enum": [ + "openai", + "openai-free-trial", + "openai-aiohttp", + "anthropic", + "together", + "ollama", + "huggingface-tgi", + "huggingface-inference-api", + "llama.cpp", + "replicate", + "text-gen-webui", + "google-palm", + "lmstudio" + ], "type": "string" }, "model": { "title": "Model", - "description": "The name of the model to be used (e.g. gpt-4, codellama)", + "description": "The name of the model. Used to autodetect prompt template.", "type": "string" }, - "system_message": { - "title": "System Message", - "description": "A system message that will always be followed by the LLM", + "api_key": { + "title": "Api Key", + "description": "OpenAI, Anthropic, Together, or other API key", + "type": "string" + }, + "api_base": { + "title": "Api Base", + "description": "The base URL of the LLM API.", "type": "string" }, "context_length": { @@ -207,6 +227,20 @@ "default": 2048, "type": "integer" }, + "template": { + "title": "Template", + "description": "The chat template used to format messages. This is auto-detected for most models, but can be overridden here.", + "enum": [ + "llama2", + "alpaca", + "zephyr", + "phind", + "anthropic", + "chatml", + "deepseek" + ], + "type": "string" + }, "completion_options": { "title": "Completion Options", "description": "Options for the completion endpoint. Read more about the completion options in the documentation.", @@ -225,6 +259,11 @@ } ] }, + "system_message": { + "title": "System Message", + "description": "A system message that will always be followed by the LLM", + "type": "string" + }, "request_options": { "title": "Request Options", "description": "Options for the HTTP request to the LLM.", @@ -240,59 +279,36 @@ "$ref": "#/definitions/RequestOptions" } ] - }, - "prompt_templates": { - "title": "Prompt Templates", - "description": "A dictionary of prompt templates that can be used to customize the behavior of the LLM in certain situations. For example, set the \"edit\" key in order to change the prompt that is used for the /edit slash command. Each value in the dictionary is a string templated in mustache syntax, and filled in at runtime with the variables specific to the situation. See the documentation for more information.", - "default": {}, - "type": "object" - }, - "api_key": { - "title": "Api Key", - "description": "The API key for the LLM provider.", - "type": "string" - }, - "api_base": { - "title": "Api Base", - "description": "The base URL of the LLM API.", - "type": "string" } }, "required": [ + "title", + "provider", "model" ] }, - "Models": { - "title": "Models", - "description": "Main class that holds the current model configuration", + "ModelRoles": { + "title": "ModelRoles", "type": "object", "properties": { "default": { - "$ref": "#/definitions/LLM" - }, - "summarize": { - "$ref": "#/definitions/LLM" - }, - "edit": { - "$ref": "#/definitions/LLM" + "title": "Default", + "description": "The default model. If other model roles are not set, they will fall back to default.", + "type": "string" }, "chat": { - "$ref": "#/definitions/LLM" + "title": "Chat", + "description": "The model to use for chat. If not set, will fall back to default.", + "type": "string" }, - "saved": { - "title": "Saved", - "default": [], - "type": "array", - "items": { - "$ref": "#/definitions/LLM" - } + "edit": { + "title": "Edit", + "description": "The model to use for editing. If not set, will fall back to default.", + "type": "string" }, - "temperature": { - "title": "Temperature", - "type": "number" - }, - "system_message": { - "title": "System Message", + "summarize": { + "title": "Summarize", + "description": "The model to use for summarization. If not set, will fall back to default.", "type": "string" } }, @@ -591,231 +607,51 @@ }, "models": { "title": "Models", - "description": "Configuration for the models used by Continue. Read more about how to configure models in the documentation.", + "default": [ + { + "title": "GPT-4 (trial)", + "provider": "openai-free-trial", + "model": "gpt-4", + "api_key": "", + "api_base": null, + "context_length": 2048, + "template": null, + "completion_options": { + "temperature": null, + "top_p": null, + "top_k": null, + "presence_penalty": null, + "frequency_penalty": null, + "stop": null, + "max_tokens": 1023 + }, + "system_message": null, + "request_options": { + "timeout": 300, + "verify_ssl": null, + "ca_bundle_path": null, + "proxy": null, + "headers": null + } + } + ], + "type": "array", + "items": { + "$ref": "#/definitions/ModelDescription" + } + }, + "model_roles": { + "title": "Model Roles", + "description": "Roles for models. Each entry should be the title of a model in the models array.", "default": { - "default": { - "title": null, - "model": "gpt-4", - "system_message": null, - "context_length": 8192, - "completion_options": { - "temperature": null, - "top_p": null, - "top_k": null, - "presence_penalty": null, - "frequency_penalty": null, - "stop": null, - "max_tokens": 1023 - }, - "request_options": { - "timeout": 300, - "verify_ssl": null, - "ca_bundle_path": null, - "proxy": null, - "headers": null - }, - "prompt_templates": {}, - "template_messages": null, - "api_key": null, - "api_base": null, - "llm": { - "title": null, - "model": "gpt-4", - "system_message": null, - "context_length": 2048, - "completion_options": { - "temperature": null, - "top_p": null, - "top_k": null, - "presence_penalty": null, - "frequency_penalty": null, - "stop": null, - "max_tokens": 1023 - }, - "request_options": { - "timeout": 300, - "verify_ssl": null, - "ca_bundle_path": null, - "proxy": null, - "headers": null - }, - "prompt_templates": {}, - "template_messages": null, - "api_key": null, - "api_base": null, - "class_name": "ProxyServer" - }, - "class_name": "OpenAIFreeTrial" - }, - "summarize": { - "title": null, - "model": "gpt-3.5-turbo", - "system_message": null, - "context_length": 4096, - "completion_options": { - "temperature": null, - "top_p": null, - "top_k": null, - "presence_penalty": null, - "frequency_penalty": null, - "stop": null, - "max_tokens": 1023 - }, - "request_options": { - "timeout": 300, - "verify_ssl": null, - "ca_bundle_path": null, - "proxy": null, - "headers": null - }, - "prompt_templates": {}, - "template_messages": null, - "api_key": null, - "api_base": null, - "llm": { - "title": null, - "model": "gpt-3.5-turbo", - "system_message": null, - "context_length": 2048, - "completion_options": { - "temperature": null, - "top_p": null, - "top_k": null, - "presence_penalty": null, - "frequency_penalty": null, - "stop": null, - "max_tokens": 1023 - }, - "request_options": { - "timeout": 300, - "verify_ssl": null, - "ca_bundle_path": null, - "proxy": null, - "headers": null - }, - "prompt_templates": {}, - "template_messages": null, - "api_key": null, - "api_base": null, - "class_name": "ProxyServer" - }, - "class_name": "OpenAIFreeTrial" - }, - "edit": { - "title": null, - "model": "gpt-4", - "system_message": null, - "context_length": 8192, - "completion_options": { - "temperature": null, - "top_p": null, - "top_k": null, - "presence_penalty": null, - "frequency_penalty": null, - "stop": null, - "max_tokens": 1023 - }, - "request_options": { - "timeout": 300, - "verify_ssl": null, - "ca_bundle_path": null, - "proxy": null, - "headers": null - }, - "prompt_templates": {}, - "template_messages": null, - "api_key": null, - "api_base": null, - "llm": { - "title": null, - "model": "gpt-4", - "system_message": null, - "context_length": 2048, - "completion_options": { - "temperature": null, - "top_p": null, - "top_k": null, - "presence_penalty": null, - "frequency_penalty": null, - "stop": null, - "max_tokens": 1023 - }, - "request_options": { - "timeout": 300, - "verify_ssl": null, - "ca_bundle_path": null, - "proxy": null, - "headers": null - }, - "prompt_templates": {}, - "template_messages": null, - "api_key": null, - "api_base": null, - "class_name": "ProxyServer" - }, - "class_name": "OpenAIFreeTrial" - }, - "chat": { - "title": null, - "model": "gpt-4", - "system_message": null, - "context_length": 8192, - "completion_options": { - "temperature": null, - "top_p": null, - "top_k": null, - "presence_penalty": null, - "frequency_penalty": null, - "stop": null, - "max_tokens": 1023 - }, - "request_options": { - "timeout": 300, - "verify_ssl": null, - "ca_bundle_path": null, - "proxy": null, - "headers": null - }, - "prompt_templates": {}, - "template_messages": null, - "api_key": null, - "api_base": null, - "llm": { - "title": null, - "model": "gpt-4", - "system_message": null, - "context_length": 2048, - "completion_options": { - "temperature": null, - "top_p": null, - "top_k": null, - "presence_penalty": null, - "frequency_penalty": null, - "stop": null, - "max_tokens": 1023 - }, - "request_options": { - "timeout": 300, - "verify_ssl": null, - "ca_bundle_path": null, - "proxy": null, - "headers": null - }, - "prompt_templates": {}, - "template_messages": null, - "api_key": null, - "api_base": null, - "class_name": "ProxyServer" - }, - "class_name": "OpenAIFreeTrial" - }, - "saved": [], - "temperature": null, - "system_message": null + "default": "GPT-4 (trial)", + "chat": null, + "edit": null, + "summarize": null }, "allOf": [ { - "$ref": "#/definitions/Models" + "$ref": "#/definitions/ModelRoles" } ] }, diff --git a/schema/json/Models.json b/schema/json/Models.json index 3a2687e38..68cc9d9e8 100644 --- a/schema/json/Models.json +++ b/schema/json/Models.json @@ -202,7 +202,10 @@ } }, "required": [ - "default" + "default", + "summarize", + "edit", + "chat" ] } } diff --git a/server/continuedev/core/autopilot.py b/server/continuedev/core/autopilot.py index c81f42705..ae59e29e7 100644 --- a/server/continuedev/core/autopilot.py +++ b/server/continuedev/core/autopilot.py @@ -317,14 +317,14 @@ class Autopilot: ) ) - logger_id = self.config.models.add_logger(add_log) + logger_id = self.sdk.models.add_logger(add_log) if step is not None: await self.run_step(step) while next_step := self.policy.next(self.sdk.config, self.session_state): # type: ignore (stub type) await self.run_step(next_step) - self.config.models.remove_logger(logger_id) + self.sdk.models.remove_logger(logger_id) async def get_session_title(self) -> str: if self.sdk.config.disable_summaries: diff --git a/server/continuedev/core/config.py b/server/continuedev/core/config.py index 1352f543b..905da4b1b 100644 --- a/server/continuedev/core/config.py +++ b/server/continuedev/core/config.py @@ -8,14 +8,12 @@ from pydantic import BaseModel, Field, validator from ..libs.constants.default_config import default_config_json from ..libs.llm.base import LLM -from ..libs.llm.openai_free_trial import OpenAIFreeTrial from ..libs.util.logging import logger from ..libs.util.paths import getConfigFilePath, getGlobalFolderPath from ..libs.util.telemetry import posthog_logger from ..models.llm import BaseCompletionOptions, RequestOptions from .config_utils.context import CONTEXT_PROVIDER_NAME_TO_CLASS, ContextProviderName from .config_utils.shared import ( - MODEL_CLASS_TO_MODEL_PROVIDER, MODEL_PROVIDER_TO_MODEL_CLASS, ModelProvider, StepName, @@ -298,50 +296,6 @@ class SerializedContinueConfig(BaseModel): if config.model_roles.summarize == title: config.model_roles.summarize = None - def construct_models(self) -> Models: - def model_with_title(title: Optional[str], fallback: ModelDescription): - return next(filter(lambda x: x.title == title, self.models), fallback) - - default = model_with_title(self.model_roles.default, self.models[0]) - chat = model_with_title(self.model_roles.chat, default) - edit = model_with_title(self.model_roles.edit, default) - summarize = model_with_title(self.model_roles.summarize, default) - - saved = [ - model_with_title(model.title, default) - for model in self.models - if model.title - not in [default.title, chat.title, edit.title, summarize.title] - ] - - def create_llm(model: ModelDescription) -> LLM: - model_class = MODEL_CLASSES[MODEL_PROVIDER_TO_MODEL_CLASS[model.provider]] - completion_options = self.completion_options.dict( - exclude_none=True, exclude_defaults=True - ) - completion_options.update( - model.completion_options.dict(exclude_none=True, exclude_defaults=True) - ) - - if "max_tokens" not in completion_options: - completion_options["max_tokens"] = min(2048, model.context_length // 2) - - # Allow extra fields to be passed through - kwargs = {**model.dict(exclude_none=True)} - kwargs["completion_options"] = completion_options - kwargs["template_messages"] = autodetect_template_function(model.model) - kwargs["prompt_templates"] = autodetect_prompt_templates(model.model) - - return model_class(**kwargs) - - return Models( - default=create_llm(default), - chat=create_llm(chat), - edit=create_llm(edit), - summarize=create_llm(summarize), - saved=[create_llm(model) for model in saved], - ) - class ContinueConfig(BaseModel): """ @@ -360,12 +314,19 @@ class ContinueConfig(BaseModel): default=True, description="If this field is set to True, we will collect anonymous telemetry as described in the documentation page on telemetry. If set to False, we will not collect any data.", ) - models: Models = Field( - default=Models( - default=OpenAIFreeTrial(model="gpt-4"), - summarize=OpenAIFreeTrial(model="gpt-3.5-turbo"), - ), - description="Configuration for the models used by Continue. Read more about how to configure models in the documentation.", + models: List[ModelDescription] = Field( + default=[ + ModelDescription( + title="GPT-4 (trial)", + provider="openai-free-trial", + model="gpt-4", + api_key="", + ) + ] + ) + model_roles: ModelRoles = Field( + default=ModelRoles(default="GPT-4 (trial)"), + description="Roles for models. Each entry should be the title of a model in the models array.", ) system_message: Optional[str] = Field( default=None, @@ -432,7 +393,8 @@ class ContinueConfig(BaseModel): allow_anonymous_telemetry=config.allow_anonymous_telemetry if config.allow_anonymous_telemetry is not None else True, - models=config.construct_models(), + models=config.models, + model_roles=config.model_roles, system_message=config.system_message, completion_options=config.completion_options, custom_commands=config.custom_commands, @@ -611,76 +573,6 @@ class ContinueConfig(BaseModel): def to_serialized_continue_config(self) -> SerializedContinueConfig: # For migration purposes - pre_models = self.models.saved + [ - self.models.default, - self.models.chat, - self.models.edit, - self.models.summarize, - ] - seen = set() - models: List[LLM] = [] - for model in pre_models: - if model is None or (model.title, model.model) in seen: - # Remove duplicate models - continue # : ) - - seen.add((model.title, model.model)) - models.append(model) - - completion_options_keys = [ - "temperature", - "top_p", - "top_k", - "max_tokens", - "presence_penalty", - "frequency_penalty", - ] - request_options_keys = [ - "timeout", - "verify_ssl", - "ca_bundle_path", - "proxy", - "headers", - ] - for model in models: - for key in completion_options_keys: - if hasattr(model, key): - setattr(model.completion_options, key, getattr(model, key)) - delattr(model, key) - - for key in request_options_keys: - if hasattr(model, key): - setattr(model.request_options, key, getattr(model, key)) - delattr(model, key) - - for key in completion_options_keys: - if hasattr(self, key): - setattr(self.completion_options, key, getattr(self, key)) - delattr(self, key) - - BACKUP_TITLE = "LLM" - - serialized_models = [ - ModelDescription( - title=model.title or BACKUP_TITLE, - provider=MODEL_CLASS_TO_MODEL_PROVIDER[model.__class__.__name__], - api_base=model.api_base, - model=model.model, - completion_options=model.completion_options, - api_key=model.api_key, - context_length=model.context_length, - system_message=model.system_message, - ) - for model in models - if model is not None - ] - - model_roles = ModelRoles( - default=self.models.default.title or BACKUP_TITLE, - chat=(self.models.chat or self.models.default).title, - edit=(self.models.edit or self.models.default).title, - summarize=(self.models.summarize or self.models.default).title, - ) slash_commands = [] for slash_command in self.slash_commands or []: @@ -691,8 +583,8 @@ class ContinueConfig(BaseModel): return SerializedContinueConfig( disallowed_steps=self.disallowed_steps, allow_anonymous_telemetry=self.allow_anonymous_telemetry, - models=serialized_models, - model_roles=model_roles, + models=self.models, + model_roles=self.model_roles, system_message=self.system_message, completion_options=self.completion_options, custom_commands=self.custom_commands, @@ -711,3 +603,48 @@ class ContinueConfig(BaseModel): disable_indexing=self.disable_indexing, retrieval_settings=self.retrieval_settings, ) + + def create_llm(self, model: ModelDescription) -> LLM: + model_class = MODEL_CLASSES[MODEL_PROVIDER_TO_MODEL_CLASS[model.provider]] + completion_options = self.completion_options.dict( + exclude_none=True, exclude_defaults=True + ) + completion_options.update( + model.completion_options.dict(exclude_none=True, exclude_defaults=True) + ) + + if "max_tokens" not in completion_options: + completion_options["max_tokens"] = min(2048, model.context_length // 2) + + # Allow extra fields to be passed through + kwargs = {**model.dict(exclude_none=True)} + kwargs["completion_options"] = completion_options + kwargs["template_messages"] = autodetect_template_function(model.model) + kwargs["prompt_templates"] = autodetect_prompt_templates(model.model) + + return model_class(**kwargs) + + def construct_models(self) -> Models: + def model_with_title(title: Optional[str], fallback: ModelDescription): + return next(filter(lambda x: x.title == title, self.models), fallback) + + default = model_with_title(self.model_roles.default, self.models[0]) + chat = model_with_title(self.model_roles.chat, default) + edit = model_with_title(self.model_roles.edit, default) + summarize = model_with_title(self.model_roles.summarize, default) + + saved = [ + model_with_title(model.title, default) + for model in self.models + if model.title + not in [default.title, chat.title, edit.title, summarize.title] + ] + + models = Models( + default=self.create_llm(default), + chat=self.create_llm(chat), + edit=self.create_llm(edit), + summarize=self.create_llm(summarize), + saved=[self.create_llm(model) for model in saved], + ) + return models diff --git a/server/continuedev/core/models.py b/server/continuedev/core/models.py index f8411b3ca..74f5a838b 100644 --- a/server/continuedev/core/models.py +++ b/server/continuedev/core/models.py @@ -70,9 +70,9 @@ class Models(BaseModel): """Main class that holds the current model configuration""" default: LLM - summarize: LLM = Field(default=None) - edit: LLM = Field(default=None) - chat: LLM = Field(default=None) + summarize: LLM + edit: LLM + chat: LLM saved: List[LLM] = [] @@ -108,7 +108,7 @@ class Models(BaseModel): for model in self.all_models: model.set_main_config_params(system_msg, temperature) - async def start( + def start( self, unique_id: str, system_message: Optional[str], @@ -117,11 +117,9 @@ class Models(BaseModel): """Start each of the LLMs, or fall back to default""" for role in ALL_MODEL_ROLES: model: LLM = getattr(self, role) - if model is None: - setattr(self, role, self.default) - else: - await model.start(unique_id) - model.write_log = self.write_log + + model.start(unique_id) + model.write_log = self.write_log self.set_main_config_params(system_message, temperature) diff --git a/server/continuedev/core/sdk.py b/server/continuedev/core/sdk.py index c54299468..115303c81 100644 --- a/server/continuedev/core/sdk.py +++ b/server/continuedev/core/sdk.py @@ -74,7 +74,12 @@ class ContinueSDK(AbstractContinueSDK): self.ide = ide self.gui = gui self.config = config - self.models = config.models + self.models = config.construct_models() + self.models.start( + self.ide.window_info.unique_id, + self.config.system_message, + self.config.completion_options.temperature, + ) self.__autopilot = autopilot @property diff --git a/server/continuedev/headless/__init__.py b/server/continuedev/headless/__init__.py index 8eeb2e9ab..6c860a7b7 100644 --- a/server/continuedev/headless/__init__.py +++ b/server/continuedev/headless/__init__.py @@ -25,9 +25,9 @@ async def get_headless_autopilot( ide = LocalIdeProtocol(workspace_directory=directory) context_manager = ContextManager() # await context_manager.start(context_providers=context_providers, ide=ide) - await _config.models.start( - "HEADLESS", _config.system_message, _config.completion_options.temperature - ) + # await _config.models.start( + # "HEADLESS", _config.system_message, _config.completion_options.temperature + # ) return Autopilot( session_state=state or SessionState.from_empty(), diff --git a/server/continuedev/libs/llm/anthropic.py b/server/continuedev/libs/llm/anthropic.py index b193f03f5..f948b3f46 100644 --- a/server/continuedev/libs/llm/anthropic.py +++ b/server/continuedev/libs/llm/anthropic.py @@ -35,8 +35,8 @@ class AnthropicLLM(LLM): class Config: arbitrary_types_allowed = True - async def start(self, *args, **kwargs): - await super().start(*args, **kwargs) + def start(self, *args, **kwargs): + super().start(*args, **kwargs) if self.model == "claude-2": self.context_length = 100_000 diff --git a/server/continuedev/libs/llm/base.py b/server/continuedev/libs/llm/base.py index 9fc64caaf..da3bf3a1e 100644 --- a/server/continuedev/libs/llm/base.py +++ b/server/continuedev/libs/llm/base.py @@ -112,7 +112,7 @@ class LLM(ContinueBaseModel): original_dict["class_name"] = self.__class__.__name__ return original_dict - async def start(self, unique_id: Optional[str] = None): + def start(self, unique_id: Optional[str] = None): """Start the connection to the LLM.""" self.unique_id = unique_id diff --git a/server/continuedev/libs/llm/ollama.py b/server/continuedev/libs/llm/ollama.py index fa3a77e8b..32cd1101c 100644 --- a/server/continuedev/libs/llm/ollama.py +++ b/server/continuedev/libs/llm/ollama.py @@ -1,6 +1,7 @@ import json from typing import Any, Dict, Optional +import requests from pydantic import Field, validator from ...core.main import ContinueCustomException @@ -61,19 +62,16 @@ class Ollama(LLM): "codeup-13b": "codeup:13b", }.get(self.model, self.model) - async def start(self, *args, **kwargs): - await super().start(*args, **kwargs) + def start(self, *args, **kwargs): + super().start(*args, **kwargs) try: - async with self.create_client_session() as session: - async with session.post( - f"{self.api_base}/api/generate", - proxy=self.request_options.proxy, - json={ - "prompt": "", - "model": self.get_model_name(), - }, - ) as _: - pass + requests.post( + f"{self.api_base}/api/generate", + json={ + "prompt": "", + "model": self.get_model_name(), + }, + ) except Exception as e: logger.warning(f"Error pre-loading Ollama model: {e}") diff --git a/server/continuedev/libs/llm/openai.py b/server/continuedev/libs/llm/openai.py index 237abdd90..bcd7f3c7e 100644 --- a/server/continuedev/libs/llm/openai.py +++ b/server/continuedev/libs/llm/openai.py @@ -92,8 +92,8 @@ class OpenAI(LLM): def context_length_for_model(cls, v, values): return CONTEXT_LENGTH_FOR_MODEL.get(values["model"], 4096) - async def start(self, unique_id: Optional[str] = None): - await super().start(unique_id=unique_id) + def start(self, unique_id: Optional[str] = None): + super().start(unique_id=unique_id) if self.context_length is None: self.context_length = CONTEXT_LENGTH_FOR_MODEL.get(self.model, 4096) diff --git a/server/continuedev/libs/llm/openai_free_trial.py b/server/continuedev/libs/llm/openai_free_trial.py index 8f39c8a8b..28f56eb95 100644 --- a/server/continuedev/libs/llm/openai_free_trial.py +++ b/server/continuedev/libs/llm/openai_free_trial.py @@ -74,9 +74,9 @@ class OpenAIFreeTrial(LLM): def update_llm_properties(self): self.llm.system_message = self.system_message - async def start(self, unique_id: Optional[str] = None): - await super().start(unique_id=unique_id) - await self.llm.start(unique_id=unique_id) + def start(self, unique_id: Optional[str] = None): + super().start(unique_id=unique_id) + self.llm.start(unique_id=unique_id) async def stop(self): await self.llm.stop() diff --git a/server/continuedev/libs/llm/proxy_server.py b/server/continuedev/libs/llm/proxy_server.py index a5431e663..014aff9a4 100644 --- a/server/continuedev/libs/llm/proxy_server.py +++ b/server/continuedev/libs/llm/proxy_server.py @@ -18,11 +18,11 @@ class ProxyServer(LLM): class Config: arbitrary_types_allowed = True - async def start( + def start( self, **kwargs, ): - await super().start(**kwargs) + super().start(**kwargs) self.context_length = CONTEXT_LENGTH_FOR_MODEL[self.model] def get_headers(self): diff --git a/server/continuedev/libs/llm/queued.py b/server/continuedev/libs/llm/queued.py index 2db749eba..ff7d08814 100644 --- a/server/continuedev/libs/llm/queued.py +++ b/server/continuedev/libs/llm/queued.py @@ -33,9 +33,9 @@ class QueuedLLM(LLM): def dict(self, **kwargs): return self.llm.dict(**kwargs) - async def start(self, *args, **kwargs): - await super().start(*args, **kwargs) - await self.llm.start(*args, **kwargs) + def start(self, *args, **kwargs): + super().start(*args, **kwargs) + self.llm.start(*args, **kwargs) self._lock = asyncio.Lock() self.model = self.llm.model self.template_messages = self.llm.template_messages diff --git a/server/continuedev/plugins/steps/codebase.py b/server/continuedev/plugins/steps/codebase.py index 3aba70558..e5dab20f8 100644 --- a/server/continuedev/plugins/steps/codebase.py +++ b/server/continuedev/plugins/steps/codebase.py @@ -2,7 +2,7 @@ import asyncio import os from typing import List, Optional, Union -from ...core.config import RetrievalSettings +from ...core.config import ModelDescription, RetrievalSettings from ...core.main import ( ContextItem, ContextItemDescription, @@ -24,37 +24,42 @@ PROMPT = """Use the above code to answer the following question. You should not async def get_faster_model(sdk: ContinueSDK) -> Optional[LLM]: - # First, check for GPT-3/3.5 - models = sdk.config.models.all_models - if gpt3_model := next(filter(lambda m: "gpt-3" in m.model, models), None): - return gpt3_model + def get_model_description() -> Optional[ModelDescription]: + # First, check for GPT-3/3.5 + models = sdk.config.models + if gpt3_model := next(filter(lambda m: "gpt-3" in m.model, models), None): + return gpt3_model - # Then, check for OpenAIFreeTrial - if openai_free_trial_model := next( - filter(lambda m: m.__class__.__name__ == "OpenAIFreeTrial", models), None - ): - new_model = openai_free_trial_model.copy() - new_model.model = "gpt-3.5-turbo" - await new_model.start(sdk.ide.window_info.unique_id) - return new_model + # Then, check for OpenAIFreeTrial + if openai_free_trial_model := next( + filter(lambda m: m.__class__.__name__ == "OpenAIFreeTrial", models), None + ): + new_model = openai_free_trial_model.copy() + new_model.model = "gpt-3.5-turbo" + return new_model - # Then, check for an API Key - if openai_model := next( - filter( - lambda m: hasattr(m, "api_key") - and m.api_key is not None - and m.api_key.startswith("sk-"), - models, - ), - None, - ): - new_model = openai_model.copy() - new_model.model = "gpt-3.5-turbo" - await new_model.start(sdk.ide.window_info.unique_id) - return new_model + # Then, check for an API Key + if openai_model := next( + filter( + lambda m: hasattr(m, "api_key") + and m.api_key is not None + and m.api_key.startswith("sk-"), + models, + ), + None, + ): + new_model = openai_model.copy() + new_model.model = "gpt-3.5-turbo" + return new_model - # Return None, so re-ranking probably shouldn't happen - return None + # Return None, so re-ranking probably shouldn't happen + return None + + if desc := get_model_description(): + llm = sdk.config.create_llm(desc) + llm.start(sdk.ide.window_info.unique_id) + else: + return None class AnswerQuestionChroma(Step): diff --git a/server/continuedev/server/protocols/gui.py b/server/continuedev/server/protocols/gui.py index a1d9a94d6..d5cbbd95a 100644 --- a/server/continuedev/server/protocols/gui.py +++ b/server/continuedev/server/protocols/gui.py @@ -89,23 +89,20 @@ class GUIProtocolServer(AbstractGUIProtocolServer): data["role"], ModelDescription(**data["model"]) ) await self.open_config() - elif msg.message_type == "set_model_for_role_from_index": - await self.set_model_for_role_from_index(data["role"], data["index"]) + elif msg.message_type == "set_model_for_role_from_title": + await self.set_model_for_role_from_title(data["role"], data["title"]) elif msg.message_type == "delete_model_at_index": await self.delete_model_at_index(data["index"]) - async def set_model_for_role_from_index(self, role: str, index: int): - if config := self.get_config(): - models = config.models - if title := models.saved[index].title: - SerializedContinueConfig.set_model_for_role(title, role) - await self.reload_config() - await self.send_config_update() + async def set_model_for_role_from_title(self, role: str, title: str): + SerializedContinueConfig.set_model_for_role(title, role) + await self.reload_config() + await self.send_config_update() async def delete_model_at_index(self, index: int): if config := self.get_config(): models = config.models - if title := models.saved[index].title: + if title := models[index].title: SerializedContinueConfig.delete_model(title) await self.reload_config() await self.send_config_update() diff --git a/server/continuedev/server/protocols/ide.py b/server/continuedev/server/protocols/ide.py index 923d9b042..87ab885d3 100644 --- a/server/continuedev/server/protocols/ide.py +++ b/server/continuedev/server/protocols/ide.py @@ -33,7 +33,7 @@ from ...models.filesystem_edit import ( from ...models.main import Position, Range from ...models.websockets import WebsocketsMessage from ..websockets_messenger import SocketIOMessenger -from .ide_protocol import AbstractIdeProtocolServer +from .ide_protocol import AbstractIdeProtocolServer, WindowInfo # region: Types @@ -118,13 +118,6 @@ class FoldingRangeResponse(BaseModel): # endregion -class WindowInfo(BaseModel): - window_id: str - workspace_directory: str - unique_id: str - ide_info: Dict[str, Any] - - class cached_property_no_none: def __init__(self, func): self.func = func diff --git a/server/continuedev/server/protocols/ide_protocol.py b/server/continuedev/server/protocols/ide_protocol.py index 358d618f6..003db462f 100644 --- a/server/continuedev/server/protocols/ide_protocol.py +++ b/server/continuedev/server/protocols/ide_protocol.py @@ -1,7 +1,8 @@ from abc import ABC, abstractmethod -from typing import Callable, Dict, List, Optional, Union +from typing import Any, Callable, Dict, List, Optional, Union from fastapi import WebSocket +from pydantic import BaseModel from ...models.filesystem import RangeInFile, RangeInFileWithContents from ...models.filesystem_edit import EditDiff, FileEdit, FileSystemEdit @@ -9,10 +10,18 @@ from ...models.main import Position from ...models.websockets import WebsocketsMessage +class WindowInfo(BaseModel): + window_id: str + workspace_directory: str + unique_id: str + ide_info: Dict[str, Any] + + class AbstractIdeProtocolServer(ABC): websocket: WebSocket session_id: Union[str, None] ide_info: Optional[Dict[str, str]] = None + window_info: WindowInfo @abstractmethod async def handle_json(self, msg: WebsocketsMessage): diff --git a/server/continuedev/server/window_manager.py b/server/continuedev/server/window_manager.py index 9e614cb4e..282060fc9 100644 --- a/server/continuedev/server/window_manager.py +++ b/server/continuedev/server/window_manager.py @@ -70,12 +70,6 @@ class Window: async def reload_config(self): self.config = self.load_config() - if self.ide is not None: - await self.config.models.start( - self.ide.window_info.unique_id, - self.config.system_message, - self.config.completion_options.temperature, - ) async def display_config_error(self): if self._error_loading_config is not None: @@ -136,13 +130,6 @@ class Window: create_async_task(index(), on_error=self.on_error) - # Start models - await self.config.models.start( - self.ide.window_info.unique_id, - self.config.system_message, - self.config.completion_options.temperature, - ) - # When the config is loaded, setup posthog logger posthog_logger.setup( self.ide.window_info.unique_id, diff --git a/server/tests/config/config_json_test.py b/server/tests/config/config_json_test.py index 557544972..571b6e4bf 100644 --- a/server/tests/config/config_json_test.py +++ b/server/tests/config/config_json_test.py @@ -67,7 +67,15 @@ def test_load_old_config(config_filename): validate_continue_config(config) if config_filename == "config_2.py": - model = config.models.default + model = next( + ( + model + for model in config.models + if model.title == config.model_roles.default + ), + None, + ) + assert model is not None assert model.completion_options.temperature == 0.1 assert model.completion_options.top_p == 0.75 assert model.completion_options.top_k == 40 diff --git a/server/tests/llm_test.py b/server/tests/llm_test.py index 583e6fa00..1ff330687 100644 --- a/server/tests/llm_test.py +++ b/server/tests/llm_test.py @@ -21,7 +21,7 @@ SPEND_MONEY = False def start_model(model: LLM): - asyncio.run(model.start(unique_id="test_unique_id")) + model.start(unique_id="test_unique_id") def async_test(func): diff --git a/server/tests/util/config.py b/server/tests/util/config.py index 370933a00..c8e15262f 100644 --- a/server/tests/util/config.py +++ b/server/tests/util/config.py @@ -1,18 +1,14 @@ -from continuedev.core.config import ContinueConfig -from continuedev.core.models import Models -from continuedev.libs.llm.openai_free_trial import OpenAIFreeTrial +from continuedev.core.config import ContinueConfig, ModelDescription config = ContinueConfig( allow_anonymous_telemetry=False, - models=Models( - default=OpenAIFreeTrial(api_key="", model="gpt-4"), - summarize=OpenAIFreeTrial( - api_key="", - model="gpt-3.5-turbo", + models=[ + ModelDescription(model="gpt-4", title="GPT-4", provider="openai-free-trial"), + ModelDescription( + model="gpt-3.5-turbo", title="GPT-3.5 Turbo", provider="openai-free-trial" ), - ), + ], system_message=None, - temperature=0.5, custom_commands=[], slash_commands=[], context_providers=[], From 1dea8200d3efd051e0a3d123864d997fd5742358 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 29 Nov 2023 16:51:20 -0800 Subject: [PATCH 17/20] =?UTF-8?q?=E2=9C=85=20update=20config=20loading=20t?= =?UTF-8?q?est?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/tests/config/config_json_test.py | 18 +--- server/tests/config/examples/config_2.py | 113 ----------------------- 2 files changed, 1 insertion(+), 130 deletions(-) delete mode 100644 server/tests/config/examples/config_2.py diff --git a/server/tests/config/config_json_test.py b/server/tests/config/config_json_test.py index 571b6e4bf..c737969b3 100644 --- a/server/tests/config/config_json_test.py +++ b/server/tests/config/config_json_test.py @@ -51,7 +51,7 @@ def temp_clear_config(): "config_filename", [ # "config_1.py", - "config_2.py", + # "config_2.py", ], ) def test_load_old_config(config_filename): @@ -66,22 +66,6 @@ def test_load_old_config(config_filename): config = ContinueConfig.load_default() validate_continue_config(config) - if config_filename == "config_2.py": - model = next( - ( - model - for model in config.models - if model.title == config.model_roles.default - ), - None, - ) - assert model is not None - assert model.completion_options.temperature == 0.1 - assert model.completion_options.top_p == 0.75 - assert model.completion_options.top_k == 40 - assert model.context_length == 16384 - assert model.request_options.timeout == 8000 - def validate_continue_config(config: ContinueConfig): ctx_provs = config.get_context_provider_descriptions() diff --git a/server/tests/config/examples/config_2.py b/server/tests/config/examples/config_2.py deleted file mode 100644 index 087c8fcd4..000000000 --- a/server/tests/config/examples/config_2.py +++ /dev/null @@ -1,113 +0,0 @@ -""" -This is the Continue configuration file. - -See https://continue.dev/docs/customization to for documentation of the available options. -""" -from continuedev.core.config import ContinueConfig, CustomCommand, SlashCommand -from continuedev.core.models import Models -from continuedev.libs.llm.llamacpp import LlamaCpp -from continuedev.libs.llm.openai_free_trial import OpenAIFreeTrial -from continuedev.libs.llm.prompts.chat import ( - llama2_template_messages, - phind_template_messages, -) -from continuedev.plugins.context_providers.diff import DiffContextProvider -from continuedev.plugins.context_providers.github import GitHubIssuesContextProvider -from continuedev.plugins.context_providers.terminal import TerminalContextProvider -from continuedev.plugins.context_providers.url import URLContextProvider -from continuedev.plugins.steps.clear_history import ClearHistoryStep -from continuedev.plugins.steps.cmd import GenerateShellCommandStep -from continuedev.plugins.steps.comment_code import CommentCodeStep -from continuedev.plugins.steps.main import EditHighlightedCodeStep -from continuedev.plugins.steps.open_config import OpenConfigStep -from continuedev.plugins.steps.share_session import ShareSessionStep - -config = ContinueConfig( - allow_anonymous_telemetry=False, - models=Models( - saved=[ - LlamaCpp( - model="serverone", - system_message="", - timeout=3600, - server_url="http://serverone.local:8080", - ), - LlamaCpp( - model="servertwo", - system_message="", - timeout=3600, - api_base="http://servertwo.local:8080", - ), - LlamaCpp( - model="desktopone", - system_message="", - server_url="http://desktopone.local:8080", - ), - ], - default=LlamaCpp( - model="serverone Phind", - system_message="", - timeout=8000, - template_messages=phind_template_messages, - temperature=0.1, - top_p=0.75, - top_k=40, - context_length=16384, - server_url="http://serverone.local:8080", - ), - ), - system_message="", - temperature=0.1, - custom_commands=[ - CustomCommand( - name="test", - description="Write unit tests for highlighted code", - prompt="Write a comprehensive set of unit tests for the selected code. It should setup, run tests that check for correctness including important edge cases, and teardown. Ensure that the tests are complete and sophisticated. Give the tests just as chat output, don't edit any file.", - ) - ], - slash_commands=[ - SlashCommand( - name="edit", - description="Edit highlighted code", - step=EditHighlightedCodeStep, - ), - SlashCommand( - name="config", - description="Customize Continue", - step=OpenConfigStep, - ), - SlashCommand( - name="comment", - description="Write comments for the highlighted code", - step=CommentCodeStep, - ), - SlashCommand( - name="clear", - description="Clear step history", - step=ClearHistoryStep, - ), - SlashCommand( - name="share", - description="Download and share this session", - step=ShareSessionStep, - ), - SlashCommand( - name="cmd", - description="Generate a shell command", - step=GenerateShellCommandStep, - ), - ], - context_providers=[ - # GitHubIssuesContextProvider( - # repo_name="/", - # auth_token="" - # ), - DiffContextProvider(), - URLContextProvider( - preset_urls=[ - # Add any common urls you reference here so they appear in autocomplete - ] - ), - TerminalContextProvider(), - ], -) From 524075674cf94a61a3b4ab23e8fd5f7b7fc16a85 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 29 Nov 2023 17:03:07 -0800 Subject: [PATCH 18/20] =?UTF-8?q?=F0=9F=93=84=20add=20license=20annotation?= =?UTF-8?q?=20to=20PyPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/server/pyproject.toml b/server/pyproject.toml index d971e0b7d..616c56768 100644 --- a/server/pyproject.toml +++ b/server/pyproject.toml @@ -4,6 +4,7 @@ version = "0.1.99" description = "" authors = ["Nate Sesti "] readme = "README.md" +license = "Apache-2.0" [tool.poetry.dependencies] python = "^3.8.1" From b0d2a9f625aeb3ac516045534f9e7f47fe18d5f2 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Thu, 30 Nov 2023 01:09:13 +0000 Subject: [PATCH 19/20] =?UTF-8?q?=F0=9F=92=9A=20Update=20package.json=20ve?= =?UTF-8?q?rsion=20[skip=20ci]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/vscode/package-lock.json | 4 ++-- extensions/vscode/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 37e0eb3b7..5c8ec0cc2 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.7.18", + "version": "0.7.19", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "continue", - "version": "0.7.18", + "version": "0.7.19", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 5cdc0ed83..a3a20309c 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -1,7 +1,7 @@ { "name": "continue", "icon": "media/icon.png", - "version": "0.7.18", + "version": "0.7.19", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From 7318bf7c56923420ae149397465c889d9e82ca7b Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 29 Nov 2023 18:40:34 -0800 Subject: [PATCH 20/20] =?UTF-8?q?=F0=9F=94=8A=20display=20entire=20ollama?= =?UTF-8?q?=20error=20at=20top=20level?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/continuedev/libs/llm/ollama.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/continuedev/libs/llm/ollama.py b/server/continuedev/libs/llm/ollama.py index 32cd1101c..61aba2873 100644 --- a/server/continuedev/libs/llm/ollama.py +++ b/server/continuedev/libs/llm/ollama.py @@ -114,7 +114,7 @@ class Ollama(LLM): elif resp.status != 200: raise ContinueCustomException( f"Ollama returned an error: {await resp.text()}", - "Invalid request to Ollama", + f"Ollama returned an error: {await resp.text()}", ) async for line in resp.content.iter_any(): if line: