From 879991ee96d363fa5f484df4aa49420bb6304c78 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Fri, 1 Dec 2023 09:50:34 -0800 Subject: [PATCH 1/7] =?UTF-8?q?=F0=9F=9A=B8=20use=20LLM=20instead=20of=20M?= =?UTF-8?q?odelDescription=20in=20config.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/modelSelection/ModelSelect.tsx | 2 +- gui/src/redux/selectors/configSelectors.ts | 1 + server/continuedev/core/config.py | 74 +++++++++++++------ server/continuedev/core/models.py | 12 +-- server/continuedev/libs/llm/base.py | 16 +++- server/continuedev/libs/util/paths.py | 8 +- .../context_providers/highlighted_code.py | 2 +- 7 files changed, 82 insertions(+), 33 deletions(-) diff --git a/gui/src/components/modelSelection/ModelSelect.tsx b/gui/src/components/modelSelection/ModelSelect.tsx index 7e6517718..e32750cf5 100644 --- a/gui/src/components/modelSelection/ModelSelect.tsx +++ b/gui/src/components/modelSelection/ModelSelect.tsx @@ -233,7 +233,7 @@ function ModelSelect(props: {}) { value={"GPT-4"} onChange={(val: string) => { if (val === defaultModel?.title) return; - client?.setModelForRoleFromTitle("*", val); + client?.setModelForRoleFromTitle("default", val); }} defaultValue={"GPT-4"} > diff --git a/gui/src/redux/selectors/configSelectors.ts b/gui/src/redux/selectors/configSelectors.ts index 3abcfd232..8d1cbf1db 100644 --- a/gui/src/redux/selectors/configSelectors.ts +++ b/gui/src/redux/selectors/configSelectors.ts @@ -14,6 +14,7 @@ export const contextLengthSelector = (state: RootStore) => { export const defaultModelSelector = (state: RootStore) => { const title = state.serverState.config.model_roles?.default; + if (!Array.isArray(state.serverState.config.models)) return; return state.serverState.config.models?.find( (model) => model.title === title ); diff --git a/server/continuedev/core/config.py b/server/continuedev/core/config.py index 905da4b1b..32436a680 100644 --- a/server/continuedev/core/config.py +++ b/server/continuedev/core/config.py @@ -8,18 +8,21 @@ 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.paths import getConfigFilePath, getGlobalFolderPath, sync_migrate 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, TemplateType, autodetect_prompt_templates, autodetect_template_function, + autodetect_template_type, ) from .context import ContextProvider from .main import ContextProviderDescription, Policy, SlashCommandDescription, Step @@ -273,6 +276,12 @@ class SerializedContinueConfig(BaseModel): else: config.model_roles.__setattr__(role, title) + def migrate_func(): + if role == "default" and config.model_roles.chat is not None: + config.model_roles.chat = None + + sync_migrate("select_default_model_001", migrate_func) + @staticmethod def add_model(model: ModelDescription): with SerializedContinueConfig.edit_config() as config: @@ -314,11 +323,10 @@ 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: List[ModelDescription] = Field( + models: List[LLM] = Field( default=[ - ModelDescription( + OpenAIFreeTrial( title="GPT-4 (trial)", - provider="openai-free-trial", model="gpt-4", api_key="", ) @@ -393,7 +401,10 @@ class ContinueConfig(BaseModel): allow_anonymous_telemetry=config.allow_anonymous_telemetry if config.allow_anonymous_telemetry is not None else True, - models=config.models, + models=[ + ContinueConfig.create_llm(config.completion_options, model) + for model in config.models + ], model_roles=config.model_roles, system_message=config.system_message, completion_options=config.completion_options, @@ -583,7 +594,9 @@ class ContinueConfig(BaseModel): return SerializedContinueConfig( disallowed_steps=self.disallowed_steps, allow_anonymous_telemetry=self.allow_anonymous_telemetry, - models=self.models, + models=[ + ContinueConfig.model_description_from(model) for model in self.models + ], model_roles=self.model_roles, system_message=self.system_message, completion_options=self.completion_options, @@ -604,28 +617,46 @@ class ContinueConfig(BaseModel): retrieval_settings=self.retrieval_settings, ) - def create_llm(self, model: ModelDescription) -> LLM: + @staticmethod + def create_llm( + completion_options: BaseCompletionOptions, 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( + options = completion_options.dict(exclude_none=True, exclude_defaults=True) + 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) + if "max_tokens" not in options: + 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["completion_options"] = options kwargs["template_messages"] = autodetect_template_function(model.model) kwargs["prompt_templates"] = autodetect_prompt_templates(model.model) return model_class(**kwargs) + @staticmethod + def model_description_from(llm: LLM) -> ModelDescription: + return ModelDescription( + title=llm.title or "LLM", + provider=MODEL_CLASS_TO_MODEL_PROVIDER.get( + llm.__class__.__name__, "custom" # type: ignore + ), + model=llm.model, + api_key=llm.api_key, + api_base=llm.api_base, + context_length=llm.context_length, + template=autodetect_template_type(llm.model), + completion_options=llm.completion_options, + system_message=llm.system_message, + request_options=llm.request_options, + ) + def construct_models(self) -> Models: - def model_with_title(title: Optional[str], fallback: ModelDescription): + def model_with_title(title: Optional[str], fallback: LLM): return next(filter(lambda x: x.title == title, self.models), fallback) default = model_with_title(self.model_roles.default, self.models[0]) @@ -640,11 +671,10 @@ class ContinueConfig(BaseModel): 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( + default=default, + chat=chat, + edit=edit, + summarize=summarize, + saved=saved, ) - return models diff --git a/server/continuedev/core/models.py b/server/continuedev/core/models.py index 36587a047..cb1da7d80 100644 --- a/server/continuedev/core/models.py +++ b/server/continuedev/core/models.py @@ -1,5 +1,5 @@ import uuid -from typing import Any, Callable, Dict, List, Optional, Type +from typing import Any, Callable, Dict, List, Optional, Type, Union from pydantic import BaseModel, validator @@ -72,12 +72,12 @@ MODEL_MODULE_NAMES = { class Models(BaseModel): """Main class that holds the current model configuration""" - default: LLM - summarize: LLM - edit: LLM - chat: LLM + default: Union[Any, LLM] + summarize: Union[Any, LLM] + edit: Union[Any, LLM] + chat: Union[Any, LLM] - saved: List[LLM] = [] + saved: List[Union[Any, LLM]] = [] temperature: Optional[float] = None system_message: Optional[str] = None diff --git a/server/continuedev/libs/llm/base.py b/server/continuedev/libs/llm/base.py index da3bf3a1e..b3674dab5 100644 --- a/server/continuedev/libs/llm/base.py +++ b/server/continuedev/libs/llm/base.py @@ -5,8 +5,12 @@ from typing import Any, AsyncGenerator, Callable, Coroutine, Dict, List, Optiona import aiohttp import certifi -from pydantic import Field +from pydantic import Field, validator +from ...core.config_utils.shared import ( + autodetect_prompt_templates, + autodetect_template_function, +) from ...core.main import ChatMessage from ...models.llm import BaseCompletionOptions, CompletionOptions, RequestOptions from ...models.main import ContinueBaseModel @@ -58,7 +62,7 @@ class LLM(ContinueBaseModel): ) prompt_templates: dict = Field( - default={}, + default=None, 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.', ) @@ -103,6 +107,14 @@ class LLM(ContinueBaseModel): }, } + @validator("template_messages", pre=True, always=True) + def set_template_messages(cls, template_messages, values): + return template_messages or autodetect_template_function(values["model"]) + + @validator("prompt_templates", pre=True, always=True) + def set_prompt_templates(cls, prompt_templates, values): + return prompt_templates or autodetect_prompt_templates(values["model"]) + def dict(self, **kwargs): original_dict = super().dict(**kwargs) original_dict.pop("write_log") diff --git a/server/continuedev/libs/util/paths.py b/server/continuedev/libs/util/paths.py index 6fd38a675..8114f8061 100644 --- a/server/continuedev/libs/util/paths.py +++ b/server/continuedev/libs/util/paths.py @@ -1,6 +1,6 @@ import os import re -from typing import Awaitable, Callable, Optional +from typing import Any, Awaitable, Callable, Optional from ..constants.default_config import default_config from ..constants.main import ( @@ -44,6 +44,12 @@ async def migrate(migration_id: str, migrate_func: Callable[[], Awaitable]): markMigrated(migration_id) +def sync_migrate(migration_id: str, migrate_func: Callable[[], Any]): + if not hasMigrated(migration_id): + migrate_func() + markMigrated(migration_id) + + def getSessionsFolderPath(): path = os.path.join(getGlobalFolderPath(), CONTINUE_SESSIONS_FOLDER) os.makedirs(path, exist_ok=True) diff --git a/server/continuedev/plugins/context_providers/highlighted_code.py b/server/continuedev/plugins/context_providers/highlighted_code.py index 8f0bac9be..82d3b5f92 100644 --- a/server/continuedev/plugins/context_providers/highlighted_code.py +++ b/server/continuedev/plugins/context_providers/highlighted_code.py @@ -99,7 +99,7 @@ class HighlightedCodeContextProvider(ContextProvider): ) return ChatMessage( role="user", - content=f"Code in this file is highlighted ({item.description.name}):\n```\n{rif.contents}\n```", + content=f"```{item.description.name}\n{rif.contents}\n```", summary=f"Code in this file is highlighted: {item.description.name}", ) From caf2a94f7420150b81cd4a6fcb6c5dc5260111f2 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Fri, 1 Dec 2023 09:51:44 -0800 Subject: [PATCH 2/7] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20update=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/vscode/schema/ContinueConfig.d.ts | 70 +++++------ extensions/vscode/schema/Models.d.ts | 10 +- gui/src/schema/ContinueConfig.d.ts | 70 +++++------ gui/src/schema/Models.d.ts | 10 +- schema/json/ContinueConfig.json | 121 ++++++++++--------- schema/json/LLM.json | 1 - schema/json/Models.json | 48 ++++++-- 7 files changed, 164 insertions(+), 166 deletions(-) diff --git a/extensions/vscode/schema/ContinueConfig.d.ts b/extensions/vscode/schema/ContinueConfig.d.ts index 48f7e28fc..c326e3752 100644 --- a/extensions/vscode/schema/ContinueConfig.d.ts +++ b/extensions/vscode/schema/ContinueConfig.d.ts @@ -32,47 +32,25 @@ export type DisallowedSteps = string[]; */ export type AllowAnonymousTelemetry = boolean; /** - * The title you wish to give your model. + * A title that will identify this model in the model selection dropdown */ export type Title = string; /** - * The provider of the model. This is used to determine the type of model, and how to interact with it. + * The unique ID of the user. */ -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" - | "llamafile"; +export type UniqueId = string; /** - * The name of the model. Used to autodetect prompt template. + * The name of the model to be used (e.g. gpt-4, codellama) */ export type Model = string; /** - * OpenAI, Anthropic, Together, or other API key + * A system message that will always be followed by the LLM */ -export type ApiKey = string; -/** - * The base URL of the LLM API. - */ -export type ApiBase = string; +export type SystemMessage1 = 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. */ @@ -105,10 +83,6 @@ 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. */ @@ -129,7 +103,15 @@ 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. + */ +export type ApiKey = string; +/** + * The base URL of the LLM API. + */ +export type ApiBase = string; +export type Models = LLM[]; /** * Roles for models. Each entry should be the title of a model in the models array. */ @@ -334,17 +316,17 @@ export interface FunctionCall { arguments: Arguments; [k: string]: unknown; } -export interface ModelDescription { - title: Title; - provider: Provider; +export interface LLM { + title?: Title; + unique_id?: UniqueId; 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 { @@ -371,6 +353,12 @@ 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 { + [k: string]: unknown; +} export interface ModelRoles1 { default: Default; chat?: Chat; diff --git a/extensions/vscode/schema/Models.d.ts b/extensions/vscode/schema/Models.d.ts index e24d6d587..a1592ae0a 100644 --- a/extensions/vscode/schema/Models.d.ts +++ b/extensions/vscode/schema/Models.d.ts @@ -86,7 +86,7 @@ export type ApiKey = string; * The base URL of the LLM API. */ export type ApiBase = string; -export type Saved = LLM[]; +export type Saved = (unknown | LLM)[]; export type Temperature1 = number; export type SystemMessage1 = string; @@ -94,10 +94,10 @@ export type SystemMessage1 = string; * Main class that holds the current model configuration */ export interface Models1 { - default: LLM; - summarize: LLM; - edit: LLM; - chat: LLM; + default?: unknown; + summarize?: unknown; + edit?: unknown; + chat?: unknown; saved?: Saved; temperature?: Temperature1; system_message?: SystemMessage1; diff --git a/gui/src/schema/ContinueConfig.d.ts b/gui/src/schema/ContinueConfig.d.ts index 48f7e28fc..c326e3752 100644 --- a/gui/src/schema/ContinueConfig.d.ts +++ b/gui/src/schema/ContinueConfig.d.ts @@ -32,47 +32,25 @@ export type DisallowedSteps = string[]; */ export type AllowAnonymousTelemetry = boolean; /** - * The title you wish to give your model. + * A title that will identify this model in the model selection dropdown */ export type Title = string; /** - * The provider of the model. This is used to determine the type of model, and how to interact with it. + * The unique ID of the user. */ -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" - | "llamafile"; +export type UniqueId = string; /** - * The name of the model. Used to autodetect prompt template. + * The name of the model to be used (e.g. gpt-4, codellama) */ export type Model = string; /** - * OpenAI, Anthropic, Together, or other API key + * A system message that will always be followed by the LLM */ -export type ApiKey = string; -/** - * The base URL of the LLM API. - */ -export type ApiBase = string; +export type SystemMessage1 = 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. */ @@ -105,10 +83,6 @@ 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. */ @@ -129,7 +103,15 @@ 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. + */ +export type ApiKey = string; +/** + * The base URL of the LLM API. + */ +export type ApiBase = string; +export type Models = LLM[]; /** * Roles for models. Each entry should be the title of a model in the models array. */ @@ -334,17 +316,17 @@ export interface FunctionCall { arguments: Arguments; [k: string]: unknown; } -export interface ModelDescription { - title: Title; - provider: Provider; +export interface LLM { + title?: Title; + unique_id?: UniqueId; 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 { @@ -371,6 +353,12 @@ 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 { + [k: string]: unknown; +} export interface ModelRoles1 { default: Default; chat?: Chat; diff --git a/gui/src/schema/Models.d.ts b/gui/src/schema/Models.d.ts index e24d6d587..a1592ae0a 100644 --- a/gui/src/schema/Models.d.ts +++ b/gui/src/schema/Models.d.ts @@ -86,7 +86,7 @@ export type ApiKey = string; * The base URL of the LLM API. */ export type ApiBase = string; -export type Saved = LLM[]; +export type Saved = (unknown | LLM)[]; export type Temperature1 = number; export type SystemMessage1 = string; @@ -94,10 +94,10 @@ export type SystemMessage1 = string; * Main class that holds the current model configuration */ export interface Models1 { - default: LLM; - summarize: LLM; - edit: LLM; - chat: LLM; + default?: unknown; + summarize?: unknown; + edit?: unknown; + chat?: unknown; saved?: Saved; temperature?: Temperature1; system_message?: SystemMessage1; diff --git a/schema/json/ContinueConfig.json b/schema/json/ContinueConfig.json index a2c4f0f18..8ef88047a 100644 --- a/schema/json/ContinueConfig.json +++ b/schema/json/ContinueConfig.json @@ -177,49 +177,28 @@ } } }, - "ModelDescription": { - "title": "ModelDescription", + "LLM": { + "title": "LLM", "type": "object", "properties": { "title": { "title": "Title", - "description": "The title you wish to give your model.", + "description": "A title that will identify this model in the model selection dropdown", "type": "string" }, - "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", - "llamafile" - ], + "unique_id": { + "title": "Unique Id", + "description": "The unique ID of the user.", "type": "string" }, "model": { "title": "Model", - "description": "The name of the model. Used to autodetect prompt template.", + "description": "The name of the model to be used (e.g. gpt-4, codellama)", "type": "string" }, - "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.", + "system_message": { + "title": "System Message", + "description": "A system message that will always be followed by the LLM", "type": "string" }, "context_length": { @@ -228,20 +207,6 @@ "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.", @@ -260,11 +225,6 @@ } ] }, - "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.", @@ -280,11 +240,24 @@ "$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.", + "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" ] }, @@ -611,12 +584,9 @@ "default": [ { "title": "GPT-4 (trial)", - "provider": "openai-free-trial", "model": "gpt-4", - "api_key": "", - "api_base": null, - "context_length": 2048, - "template": null, + "system_message": null, + "context_length": 8192, "completion_options": { "temperature": null, "top_p": null, @@ -626,19 +596,50 @@ "stop": null, "max_tokens": 1023 }, - "system_message": null, "request_options": { "timeout": 300, "verify_ssl": null, "ca_bundle_path": null, "proxy": null, "headers": null - } + }, + "prompt_templates": {}, + "template_messages": null, + "api_key": "", + "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" } ], "type": "array", "items": { - "$ref": "#/definitions/ModelDescription" + "$ref": "#/definitions/LLM" } }, "model_roles": { diff --git a/schema/json/LLM.json b/schema/json/LLM.json index 6dcf550f9..8003a66a1 100644 --- a/schema/json/LLM.json +++ b/schema/json/LLM.json @@ -149,7 +149,6 @@ "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": { diff --git a/schema/json/Models.json b/schema/json/Models.json index 68cc9d9e8..677a39a5c 100644 --- a/schema/json/Models.json +++ b/schema/json/Models.json @@ -149,7 +149,6 @@ "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": { @@ -173,23 +172,52 @@ "type": "object", "properties": { "default": { - "$ref": "#/definitions/LLM" + "title": "Default", + "anyOf": [ + {}, + { + "$ref": "#/definitions/LLM" + } + ] }, "summarize": { - "$ref": "#/definitions/LLM" + "title": "Summarize", + "anyOf": [ + {}, + { + "$ref": "#/definitions/LLM" + } + ] }, "edit": { - "$ref": "#/definitions/LLM" + "title": "Edit", + "anyOf": [ + {}, + { + "$ref": "#/definitions/LLM" + } + ] }, "chat": { - "$ref": "#/definitions/LLM" + "title": "Chat", + "anyOf": [ + {}, + { + "$ref": "#/definitions/LLM" + } + ] }, "saved": { "title": "Saved", "default": [], "type": "array", "items": { - "$ref": "#/definitions/LLM" + "anyOf": [ + {}, + { + "$ref": "#/definitions/LLM" + } + ] } }, "temperature": { @@ -200,13 +228,7 @@ "title": "System Message", "type": "string" } - }, - "required": [ - "default", - "summarize", - "edit", - "chat" - ] + } } } } \ No newline at end of file From 9f3c0d9d97046bed35952912a45e21c710a9052e Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Fri, 1 Dec 2023 18:18:43 +0000 Subject: [PATCH 3/7] =?UTF-8?q?=F0=9F=92=9A=20Update=20package.json=20vers?= =?UTF-8?q?ion=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 0b4f10a45..0ba25e7c1 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.7.21", + "version": "0.7.22", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "continue", - "version": "0.7.21", + "version": "0.7.22", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index facd4d0c4..7a664115e 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -1,7 +1,7 @@ { "name": "continue", "icon": "media/icon.png", - "version": "0.7.21", + "version": "0.7.22", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From f1acf9528192a42afbf5f3dca2634098b8c7447b Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Fri, 1 Dec 2023 11:11:05 -0800 Subject: [PATCH 4/7] =?UTF-8?q?=F0=9F=90=9B=20fixing=20a=20few=20misc=20bu?= =?UTF-8?q?gs=20with=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reference/Model Providers/llamacpp.md | 15 ++++++------ .../reference/Model Providers/llamafile.md | 13 +++++----- gui/src/pages/gui.tsx | 4 ++-- server/continuedev/core/config.py | 18 +++++++++++--- .../continuedev/core/config_utils/shared.py | 24 +++++++++++++++---- 5 files changed, 52 insertions(+), 22 deletions(-) diff --git a/docs/docs/reference/Model Providers/llamacpp.md b/docs/docs/reference/Model Providers/llamacpp.md index 6d5cdc0c3..71ebb5f05 100644 --- a/docs/docs/reference/Model Providers/llamacpp.md +++ b/docs/docs/reference/Model Providers/llamacpp.md @@ -12,12 +12,14 @@ After it's up and running, change `~/.continue/config.json` to look like this: ```json title="~/.continue/config.json" { - "models": [{ - "title": "Llama CPP", - "provider": "llama.cpp", - "model": "MODEL_NAME", - "api_base": "http://localhost:8080" - }] + "models": [ + { + "title": "Llama CPP", + "provider": "llama.cpp", + "model": "MODEL_NAME", + "api_base": "http://localhost:8080" + } + ] } ``` @@ -27,7 +29,6 @@ After it's up and running, change `~/.continue/config.json` to look like this: - ### Inherited Properties diff --git a/docs/docs/reference/Model Providers/llamafile.md b/docs/docs/reference/Model Providers/llamafile.md index 3991b8f48..021f1933f 100644 --- a/docs/docs/reference/Model Providers/llamafile.md +++ b/docs/docs/reference/Model Providers/llamafile.md @@ -6,11 +6,13 @@ A [llamafile](https://github.com/Mozilla-Ocho/llamafile#readme) is a self-contai ```json title="~/.continue/config.json" { - "models": [{ - "title": "Llamafile", - "provider": "llamafile", - "model": "mistral-7b", - }] + "models": [ + { + "title": "Llamafile", + "provider": "llamafile", + "model": "mistral-7b" + } + ] } ``` @@ -21,7 +23,6 @@ A [llamafile](https://github.com/Mozilla-Ocho/llamafile#readme) is a self-contai - ### Inherited Properties diff --git a/gui/src/pages/gui.tsx b/gui/src/pages/gui.tsx index accad00b1..8396ccb14 100644 --- a/gui/src/pages/gui.tsx +++ b/gui/src/pages/gui.tsx @@ -428,7 +428,7 @@ function GUI(props: GUIProps) { client?.stopSession(); persistSession(); dispatch(newSession()); - mainTextInputRef.current?.focus(); + mainTextInputRef.current?.focus?.(); } }; @@ -737,7 +737,7 @@ function GUI(props: GUIProps) { value={step.description as string} active={active && isLastUserInput(index)} onEnter={(e, value) => { - if (value) { + if (value && client) { client?.stopSession(); const newHistory = [ ...sessionState.history.slice(0, index), diff --git a/server/continuedev/core/config.py b/server/continuedev/core/config.py index 32436a680..c3f4e33fe 100644 --- a/server/continuedev/core/config.py +++ b/server/continuedev/core/config.py @@ -17,6 +17,7 @@ from .config_utils.context import CONTEXT_PROVIDER_NAME_TO_CLASS, ContextProvide from .config_utils.shared import ( MODEL_CLASS_TO_MODEL_PROVIDER, MODEL_PROVIDER_TO_MODEL_CLASS, + STEP_NAMES, ModelProvider, StepName, TemplateType, @@ -50,7 +51,11 @@ class SlashCommand(BaseModel): def step_is_string(cls, v): if isinstance(v, str): return v - elif isinstance(v, object) and v.__class__.__name__ == "ModelMetaclass": + elif ( + isinstance(v, object) + and v.__class__.__name__ == "ModelMetaclass" + and v.__class__.__name__ in STEP_NAMES + ): return str(v).split(".")[-1].split("'")[0] else: return v @@ -458,6 +463,9 @@ class ContinueConfig(BaseModel): serialized_config = json.loads(contents) + except json.JSONDecodeError as e: + raise e + except ValueError as e: logger.warning(f"Found empty config.json at {filepath}: {e}") with open(filepath, "w") as f: @@ -633,8 +641,12 @@ class ContinueConfig(BaseModel): # Allow extra fields to be passed through kwargs = {**model.dict(exclude_none=True)} kwargs["completion_options"] = options - kwargs["template_messages"] = autodetect_template_function(model.model) - kwargs["prompt_templates"] = autodetect_prompt_templates(model.model) + kwargs["template_messages"] = autodetect_template_function( + model.model, model.template + ) + kwargs["prompt_templates"] = autodetect_prompt_templates( + model.model, model.template + ) return model_class(**kwargs) diff --git a/server/continuedev/core/config_utils/shared.py b/server/continuedev/core/config_utils/shared.py index c65a35435..8e4417ca7 100644 --- a/server/continuedev/core/config_utils/shared.py +++ b/server/continuedev/core/config_utils/shared.py @@ -18,6 +18,18 @@ from ...libs.llm.prompts.edit import ( zephyr_edit_prompt, ) +STEP_NAMES = [ + "AnswerQuestionChroma", + "GenerateShellCommandStep", + "EditHighlightedCodeStep", + "ShareSessionStep", + "CommentCodeStep", + "ClearHistoryStep", + "StackOverflowStep", + "OpenConfigStep", + "GenerateShellCommandStep", +] + StepName = Literal[ "AnswerQuestionChroma", "GenerateShellCommandStep", @@ -64,8 +76,10 @@ def autodetect_template_type(model: str) -> Optional[TemplateType]: return "chatml" -def autodetect_template_function(model: str): - if template_type := autodetect_template_type(model): +def autodetect_template_function( + model: str, explicit_template: Optional[TemplateType] = None +): + if template_type := explicit_template or autodetect_template_type(model): mapping: Dict[TemplateType, Any] = { "llama2": llama2_template_messages, "alpaca": template_alpaca_messages, @@ -79,8 +93,10 @@ def autodetect_template_function(model: str): return None -def autodetect_prompt_templates(model: str): - template_type = autodetect_template_type(model) +def autodetect_prompt_templates( + model: str, explicit_template: Optional[TemplateType] = None +): + template_type = explicit_template or autodetect_template_type(model) templates = {} From 412376370ab4c8cb0e8444e5cf2661a170942071 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Fri, 1 Dec 2023 11:36:03 -0800 Subject: [PATCH 5/7] =?UTF-8?q?=F0=9F=90=9B=20fix=20broken=20link=20in=20d?= =?UTF-8?q?ocs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reference/Model Providers/anthropicllm.md | 4 +- docs/docs/reference/Model Providers/ggml.md | 8 +++- .../Model Providers/googlepalmapi.md | 4 +- .../huggingfaceinferenceapi.md | 4 +- .../Model Providers/huggingfacetgi.md | 4 +- .../reference/Model Providers/llamacpp.md | 21 ++++---- .../reference/Model Providers/llamafile.md | 19 ++++---- docs/docs/reference/Model Providers/ollama.md | 4 +- docs/docs/reference/Model Providers/openai.md | 48 ++++++++++++++----- .../Model Providers/openaifreetrial.md | 6 +-- .../reference/Model Providers/queuedllm.md | 4 +- .../reference/Model Providers/replicatellm.md | 4 +- .../reference/Model Providers/textgenwebui.md | 4 +- .../reference/Model Providers/togetherllm.md | 4 +- docs/docs/reference/config.md | 4 +- server/continuedev/libs/llm/llamacpp.py | 2 +- server/continuedev/libs/llm/openai.py | 14 +++--- 17 files changed, 93 insertions(+), 65 deletions(-) diff --git a/docs/docs/reference/Model Providers/anthropicllm.md b/docs/docs/reference/Model Providers/anthropicllm.md index 61e419b0b..97af029d4 100644 --- a/docs/docs/reference/Model Providers/anthropicllm.md +++ b/docs/docs/reference/Model Providers/anthropicllm.md @@ -30,8 +30,8 @@ Claude 2 is not yet publicly released. You can request early access [here](https - + - + diff --git a/docs/docs/reference/Model Providers/ggml.md b/docs/docs/reference/Model Providers/ggml.md index 7bfddcf9c..9aae2ed8f 100644 --- a/docs/docs/reference/Model Providers/ggml.md +++ b/docs/docs/reference/Model Providers/ggml.md @@ -4,6 +4,8 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; See our [5 minute quickstart](https://github.com/continuedev/ggml-server-example) to run any model locally with ggml. While these models don't yet perform as well, they are free, entirely private, and run offline. +You can also use this class for [LM Studio](https://lmstudio.ai). + Once the model is running on localhost:8000, change `~/.continue/config.json` to look like this: ```json title="~/.continue/config.json" @@ -24,6 +26,8 @@ Once the model is running on localhost:8000, change `~/.continue/config.json` to + + ### Inherited Properties @@ -33,8 +37,8 @@ Once the model is running on localhost:8000, change `~/.continue/config.json` to - + - + diff --git a/docs/docs/reference/Model Providers/googlepalmapi.md b/docs/docs/reference/Model Providers/googlepalmapi.md index eacb40958..e10091ebe 100644 --- a/docs/docs/reference/Model Providers/googlepalmapi.md +++ b/docs/docs/reference/Model Providers/googlepalmapi.md @@ -29,7 +29,7 @@ The Google PaLM API is currently in public preview, so production applications a - + - + diff --git a/docs/docs/reference/Model Providers/huggingfaceinferenceapi.md b/docs/docs/reference/Model Providers/huggingfaceinferenceapi.md index 2b2d65ee6..8d7ea897f 100644 --- a/docs/docs/reference/Model Providers/huggingfaceinferenceapi.md +++ b/docs/docs/reference/Model Providers/huggingfaceinferenceapi.md @@ -30,7 +30,7 @@ Hugging Face Inference API is a great option for newly released language models. - + - + diff --git a/docs/docs/reference/Model Providers/huggingfacetgi.md b/docs/docs/reference/Model Providers/huggingfacetgi.md index feb20ec79..919199fd2 100644 --- a/docs/docs/reference/Model Providers/huggingfacetgi.md +++ b/docs/docs/reference/Model Providers/huggingfacetgi.md @@ -17,8 +17,8 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; - + - + diff --git a/docs/docs/reference/Model Providers/llamacpp.md b/docs/docs/reference/Model Providers/llamacpp.md index 71ebb5f05..d1b494409 100644 --- a/docs/docs/reference/Model Providers/llamacpp.md +++ b/docs/docs/reference/Model Providers/llamacpp.md @@ -12,14 +12,12 @@ After it's up and running, change `~/.continue/config.json` to look like this: ```json title="~/.continue/config.json" { - "models": [ - { - "title": "Llama CPP", - "provider": "llama.cpp", - "model": "MODEL_NAME", - "api_base": "http://localhost:8080" - } - ] + "models": [{ + "title": "Llama CPP", + "provider": "llama.cpp", + "model": "MODEL_NAME", + "api_base": "http://localhost:8080" + }] } ``` @@ -27,7 +25,8 @@ After it's up and running, change `~/.continue/config.json` to look like this: ## Properties - + + ### Inherited Properties @@ -36,8 +35,8 @@ After it's up and running, change `~/.continue/config.json` to look like this: - + - + diff --git a/docs/docs/reference/Model Providers/llamafile.md b/docs/docs/reference/Model Providers/llamafile.md index 021f1933f..855e32770 100644 --- a/docs/docs/reference/Model Providers/llamafile.md +++ b/docs/docs/reference/Model Providers/llamafile.md @@ -6,23 +6,24 @@ A [llamafile](https://github.com/Mozilla-Ocho/llamafile#readme) is a self-contai ```json title="~/.continue/config.json" { - "models": [ - { - "title": "Llamafile", - "provider": "llamafile", - "model": "mistral-7b" - } - ] + "models": [{ + "title": "Llamafile", + "provider": "llamafile", + "model": "mistral-7b", + }] } ``` +Optionally, you can set the `llamafile_command` property, which will be run to start the llamafile if it isn't already running on port 8080. Be sure to use an absolute path to the llamafile binary. For example: `/Users/yourusername/mistral-7b-instruct-v0.1-Q4_K_M-server.llamafile`. + [View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/llamafile.py) ## Properties - + + ### Inherited Properties @@ -32,6 +33,6 @@ A [llamafile](https://github.com/Mozilla-Ocho/llamafile#readme) is a self-contai - + diff --git a/docs/docs/reference/Model Providers/ollama.md b/docs/docs/reference/Model Providers/ollama.md index 63d96057b..ead7be799 100644 --- a/docs/docs/reference/Model Providers/ollama.md +++ b/docs/docs/reference/Model Providers/ollama.md @@ -27,8 +27,8 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; - + - + diff --git a/docs/docs/reference/Model Providers/openai.md b/docs/docs/reference/Model Providers/openai.md index 046817fd4..5d8c3af71 100644 --- a/docs/docs/reference/Model Providers/openai.md +++ b/docs/docs/reference/Model Providers/openai.md @@ -2,14 +2,45 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; # OpenAI -The OpenAI class can be used to access OpenAI models like gpt-4 and gpt-3.5-turbo. +The OpenAI class can be used to access OpenAI models like GPT-4, GPT-4 Turbo, and GPT-3.5 Turbo. -If you are locally serving a model that uses an OpenAI-compatible server, you can simply change the `api_base` like this: +### Azure OpenAI Service + +If you'd like to use OpenAI models but are concerned about privacy, you can use the Azure OpenAI service, which is GDPR and HIPAA compliant. After applying for access [here](https://azure.microsoft.com/en-us/products/ai-services/openai-service), you will typically hear back within only a few days. Once you have access, set up a model in `config.json` like so: + +```json +"models": [{ + "title": "Azure OpenAI", + "provider": "openai", + "model": "gpt-4", + "api_base": "https://my-azure-openai-instance.openai.azure.com/", + "engine": "my-azure-openai-deployment", + "api_version": "2023-07-01-preview", + "api_type": "azure", + "api_key": "" +}] +``` + +The easiest way to find this information is from the chat playground in the Azure OpenAI portal. Under the "Chat Session" section, click "View Code" to see each of these parameters. + +### OpenAI compatible servers / APIs + +OpenAI compatible servers +- [text-gen-webui](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/openai#setup--installation) +- [FastChat](https://github.com/lm-sys/FastChat/blob/main/docs/openai_api.md) +- [LocalAI](https://localai.io/basics/getting_started/) +- [llama-cpp-python](https://github.com/abetlen/llama-cpp-python#web-server) + +OpenAI compatible APIs +- [Anyscale Endpoints](https://github.com/continuedev/deploy-os-code-llm#others) +- [Anyscale Private Endpoints](https://github.com/continuedev/deploy-os-code-llm#anyscale-private-endpoints) + +If you are [using an OpenAI compatible server / API](../../model-setup/select-provider#local), you can change the `api_base` like this: ```json title="~/.continue/config.json" { "models": [{ - "title": "OpenAI-compatible server", + "title": "OpenAI-compatible server / API", "provider": "openai", "model": "MODEL_NAME", "api_key": "EMPTY", @@ -18,13 +49,6 @@ If you are locally serving a model that uses an OpenAI-compatible server, you ca } ``` -Options for serving models locally with an OpenAI-compatible server include: - -- [text-gen-webui](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/openai#setup--installation) -- [FastChat](https://github.com/lm-sys/FastChat/blob/main/docs/openai_api.md) -- [LocalAI](https://localai.io/basics/getting_started/) -- [llama-cpp-python](https://github.com/abetlen/llama-cpp-python#web-server) - [View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/openai.py) ## Properties @@ -43,7 +67,7 @@ Options for serving models locally with an OpenAI-compatible server include: - + - + diff --git a/docs/docs/reference/Model Providers/openaifreetrial.md b/docs/docs/reference/Model Providers/openaifreetrial.md index 307a86ab1..d5538d42c 100644 --- a/docs/docs/reference/Model Providers/openaifreetrial.md +++ b/docs/docs/reference/Model Providers/openaifreetrial.md @@ -37,7 +37,7 @@ Once you are using Continue regularly though, you will need to add an OpenAI API ## Properties - + ### Inherited Properties @@ -47,8 +47,8 @@ Once you are using Continue regularly though, you will need to add an OpenAI API - + - + diff --git a/docs/docs/reference/Model Providers/queuedllm.md b/docs/docs/reference/Model Providers/queuedllm.md index a835ab3d7..59a0bcea5 100644 --- a/docs/docs/reference/Model Providers/queuedllm.md +++ b/docs/docs/reference/Model Providers/queuedllm.md @@ -31,8 +31,8 @@ config = ContinueConfig( - + - + diff --git a/docs/docs/reference/Model Providers/replicatellm.md b/docs/docs/reference/Model Providers/replicatellm.md index 27ea1d8c3..fb718bf4c 100644 --- a/docs/docs/reference/Model Providers/replicatellm.md +++ b/docs/docs/reference/Model Providers/replicatellm.md @@ -31,7 +31,7 @@ If you don't specify the `model` parameter, it will default to `replicate/llama- - + - + diff --git a/docs/docs/reference/Model Providers/textgenwebui.md b/docs/docs/reference/Model Providers/textgenwebui.md index 2141bf5f5..10636ff41 100644 --- a/docs/docs/reference/Model Providers/textgenwebui.md +++ b/docs/docs/reference/Model Providers/textgenwebui.md @@ -28,8 +28,8 @@ TextGenWebUI is a comprehensive, open-source language model UI and local server. - + - + diff --git a/docs/docs/reference/Model Providers/togetherllm.md b/docs/docs/reference/Model Providers/togetherllm.md index b66f3fe82..0e9a9da88 100644 --- a/docs/docs/reference/Model Providers/togetherllm.md +++ b/docs/docs/reference/Model Providers/togetherllm.md @@ -29,7 +29,7 @@ The Together API is a cloud platform for running large AI models. You can sign u - + - + diff --git a/docs/docs/reference/config.md b/docs/docs/reference/config.md index 814724737..b746de46a 100644 --- a/docs/docs/reference/config.md +++ b/docs/docs/reference/config.md @@ -10,10 +10,10 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; - + - + diff --git a/server/continuedev/libs/llm/llamacpp.py b/server/continuedev/libs/llm/llamacpp.py index 4d3b6dcf2..366d1c88b 100644 --- a/server/continuedev/libs/llm/llamacpp.py +++ b/server/continuedev/libs/llm/llamacpp.py @@ -39,7 +39,7 @@ class LlamaCpp(LLM): llama_cpp_args: Dict[str, Any] = Field( {"stop": ["[INST]"]}, - description="A list of additional arguments to pass to llama.cpp. See [here](https://github.com/ggerganov/llama.cpp/tree/master/examples/server#api-endpoints) for the complete catalog of options.", + description="A list of additional arguments to pass to llama.cpp. See https://github.com/ggerganov/llama.cpp/tree/master/examples/server#api-endpoints for the complete catalog of options.", ) class Config: diff --git a/server/continuedev/libs/llm/openai.py b/server/continuedev/libs/llm/openai.py index d645e152d..faa69fc1e 100644 --- a/server/continuedev/libs/llm/openai.py +++ b/server/continuedev/libs/llm/openai.py @@ -42,9 +42,9 @@ class OpenAI(LLM): The OpenAI class can be used to access OpenAI models like GPT-4, GPT-4 Turbo, and GPT-3.5 Turbo. ### Azure OpenAI Service - + If you'd like to use OpenAI models but are concerned about privacy, you can use the Azure OpenAI service, which is GDPR and HIPAA compliant. After applying for access [here](https://azure.microsoft.com/en-us/products/ai-services/openai-service), you will typically hear back within only a few days. Once you have access, set up a model in `config.json` like so: - + ```json "models": [{ "title": "Azure OpenAI", @@ -59,20 +59,20 @@ class OpenAI(LLM): ``` The easiest way to find this information is from the chat playground in the Azure OpenAI portal. Under the "Chat Session" section, click "View Code" to see each of these parameters. - + ### OpenAI compatible servers / APIs - + OpenAI compatible servers - [text-gen-webui](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/openai#setup--installation) - [FastChat](https://github.com/lm-sys/FastChat/blob/main/docs/openai_api.md) - [LocalAI](https://localai.io/basics/getting_started/) - [llama-cpp-python](https://github.com/abetlen/llama-cpp-python#web-server) - + OpenAI compatible APIs - [Anyscale Endpoints](https://github.com/continuedev/deploy-os-code-llm#others) - [Anyscale Private Endpoints](https://github.com/continuedev/deploy-os-code-llm#anyscale-private-endpoints) - - If you are [using an OpenAI compatible server / API](../model-setup/select-provider#local), you can change the `api_base` like this: + + If you are [using an OpenAI compatible server / API](../../model-setup/select-provider#local), you can change the `api_base` like this: ```json title="~/.continue/config.json" { From 76cb010b6f9d0fb45a2d6ce60f3b31f5abd499f6 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Fri, 1 Dec 2023 11:48:07 -0800 Subject: [PATCH 6/7] =?UTF-8?q?=F0=9F=90=9B=20fix=20serialization=20of=20S?= =?UTF-8?q?lashCommand?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/continuedev/core/config.py | 8 +++ server/continuedev/plugins/steps/codebase.py | 59 +++++++++----------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/server/continuedev/core/config.py b/server/continuedev/core/config.py index c3f4e33fe..685abe3f9 100644 --- a/server/continuedev/core/config.py +++ b/server/continuedev/core/config.py @@ -60,6 +60,14 @@ class SlashCommand(BaseModel): else: return v + def dict(self, *args, **kwargs): + d = super().dict(*args, **kwargs) + if isinstance(d["step"], str): + d["step"] = d["step"].split(".")[-1] + else: + d["step"] = d["step"].__name__ + return d + def slash_command_description(self) -> SlashCommandDescription: return SlashCommandDescription( name=self.name, diff --git a/server/continuedev/plugins/steps/codebase.py b/server/continuedev/plugins/steps/codebase.py index e5dab20f8..4e5642429 100644 --- a/server/continuedev/plugins/steps/codebase.py +++ b/server/continuedev/plugins/steps/codebase.py @@ -24,42 +24,35 @@ PROMPT = """Use the above code to answer the following question. You should not async def get_faster_model(sdk: ContinueSDK) -> Optional[LLM]: - 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 + # First, check for GPT-3/3.5 + models: List[LLM] = 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" - 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" - 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 - - if desc := get_model_description(): - llm = sdk.config.create_llm(desc) - llm.start(sdk.ide.window_info.unique_id) - else: - return None + # Return None, so re-ranking probably shouldn't happen + return None class AnswerQuestionChroma(Step): From 046421d12e8f95438b04a5a134d61420a2de5dde Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Fri, 1 Dec 2023 20:05:32 +0000 Subject: [PATCH 7/7] =?UTF-8?q?=F0=9F=92=9A=20Update=20package.json=20vers?= =?UTF-8?q?ion=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 0ba25e7c1..29e40746a 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.7.22", + "version": "0.7.23", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "continue", - "version": "0.7.22", + "version": "0.7.23", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 7a664115e..7c3a03e0d 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -1,7 +1,7 @@ { "name": "continue", "icon": "media/icon.png", - "version": "0.7.22", + "version": "0.7.23", "repository": { "type": "git", "url": "https://github.com/continuedev/continue"