diff --git a/docs/docs/reference/Models/textgenui.md b/docs/docs/reference/Models/textgenui.md deleted file mode 100644 index 2f772611c..000000000 --- a/docs/docs/reference/Models/textgenui.md +++ /dev/null @@ -1,47 +0,0 @@ -import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; - -# TextGenUI - -TextGenUI is a comprehensive, open-source language model UI and local server. You can set it up with an OpenAI-compatible server plugin, but if for some reason that doesn't work, you can use this class like so: - -```python title="~/.continue/config.py" -from continuedev.libs.llm.text_gen_interface import TextGenUI - -config = ContinueConfig( - ... - models=Models( - default=TextGenUI( - model="", - ) - ) -) -``` - -[View the source](https://github.com/continuedev/continue/tree/main/server/continuedev/libs/llm/text_gen_interface.py) - -## Properties - - - - - -### Inherited Properties - - - - - - - - - - - - - - - - - - - diff --git a/extensions/vscode/SerializedContinueConfig.json b/extensions/vscode/SerializedContinueConfig.json new file mode 100644 index 000000000..059755036 --- /dev/null +++ b/extensions/vscode/SerializedContinueConfig.json @@ -0,0 +1,514 @@ +{ + "title": "SerializedContinueConfig", + "$ref": "#/definitions/continuedev__core__config__serialized_config__SerializedContinueConfig", + "definitions": { + "StepWithParams": { + "title": "StepWithParams", + "type": "object", + "properties": { + "step": { + "title": "Step", + "enum": [ + "AnswerQuestionChroma", + "GenerateShellCommandStep", + "EditHighlightedCodeStep", + "ShareSessionStep", + "CommentCodeStep", + "ClearHistoryStep", + "StackOverflowStep" + ], + "type": "string" + }, + "params": { + "title": "Params", + "type": "object" + } + }, + "required": [ + "step", + "params" + ] + }, + "BaseCompletionOptions": { + "title": "BaseCompletionOptions", + "type": "object", + "properties": { + "temperature": { + "title": "Temperature", + "description": "The temperature of the completion.", + "type": "number" + }, + "top_p": { + "title": "Top P", + "description": "The top_p of the completion.", + "type": "number" + }, + "top_k": { + "title": "Top K", + "description": "The top_k of the completion.", + "type": "integer" + }, + "presence_penalty": { + "title": "Presence Penalty", + "description": "The presence penalty Aof the completion.", + "type": "number" + }, + "frequency_penalty": { + "title": "Frequency Penalty", + "description": "The frequency penalty of the completion.", + "type": "number" + }, + "stop": { + "title": "Stop", + "description": "The stop tokens of the completion.", + "type": "array", + "items": { + "type": "string" + } + }, + "max_tokens": { + "title": "Max Tokens", + "description": "The maximum number of tokens to generate.", + "default": 600, + "type": "integer" + } + } + }, + "RequestOptions": { + "title": "RequestOptions", + "type": "object", + "properties": { + "timeout": { + "title": "Timeout", + "description": "Set the timeout for each request to the LLM. If you are running a local LLM that takes a while to respond, you might want to set this to avoid timeouts.", + "default": 300, + "type": "integer" + }, + "verify_ssl": { + "title": "Verify Ssl", + "description": "Whether to verify SSL certificates for requests.", + "type": "boolean" + }, + "ca_bundle_path": { + "title": "Ca Bundle Path", + "description": "Path to a custom CA bundle to use when making the HTTP request", + "type": "string" + }, + "proxy": { + "title": "Proxy", + "description": "Proxy URL to use when making the HTTP request", + "type": "string" + }, + "headers": { + "title": "Headers", + "description": "Headers to use when making the HTTP request", + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + }, + "ModelDescription": { + "title": "ModelDescription", + "type": "object", + "properties": { + "title": { + "title": "Title", + "description": "The title you wish to give your model.", + "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" + ], + "type": "string" + }, + "model": { + "title": "Model", + "description": "The name of the model. Used to autodetect prompt template.", + "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.", + "type": "string" + }, + "context_length": { + "title": "Context Length", + "description": "The maximum context length of the LLM in tokens, as counted by count_tokens.", + "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" + ], + "type": "string" + }, + "completion_options": { + "title": "Completion Options", + "description": "Options for the completion endpoint. Read more about the completion options in the documentation.", + "default": { + "temperature": null, + "top_p": null, + "top_k": null, + "presence_penalty": null, + "frequency_penalty": null, + "stop": null, + "max_tokens": 600 + }, + "allOf": [ + { + "$ref": "#/definitions/BaseCompletionOptions" + } + ] + }, + "request_options": { + "title": "Request Options", + "description": "Options for the HTTP request to the LLM.", + "default": { + "timeout": 300, + "verify_ssl": null, + "ca_bundle_path": null, + "proxy": null, + "headers": null + }, + "allOf": [ + { + "$ref": "#/definitions/RequestOptions" + } + ] + } + }, + "required": [ + "title", + "provider", + "model" + ] + }, + "ModelRoles": { + "title": "ModelRoles", + "type": "object", + "properties": { + "default": { + "title": "Default", + "description": "The default model. If other model roles are not set, they will fall back to default.", + "type": "string" + }, + "chat": { + "title": "Chat", + "description": "The model to use for chat. If not set, will fall back to default.", + "type": "string" + }, + "edit": { + "title": "Edit", + "description": "The model to use for editing. If not set, will fall back to default.", + "type": "string" + }, + "summarize": { + "title": "Summarize", + "description": "The model to use for summarization. If not set, will fall back to default.", + "type": "string" + } + }, + "required": [ + "default" + ] + }, + "SlashCommand": { + "title": "SlashCommand", + "type": "object", + "properties": { + "name": { + "title": "Name", + "type": "string" + }, + "description": { + "title": "Description", + "type": "string" + }, + "step": { + "title": "Step" + }, + "params": { + "title": "Params", + "default": {}, + "type": "object" + } + }, + "required": [ + "name", + "description", + "step" + ] + }, + "CustomCommand": { + "title": "CustomCommand", + "type": "object", + "properties": { + "name": { + "title": "Name", + "type": "string" + }, + "prompt": { + "title": "Prompt", + "type": "string" + }, + "description": { + "title": "Description", + "type": "string" + } + }, + "required": [ + "name", + "prompt", + "description" + ] + }, + "RetrievalSettings": { + "title": "RetrievalSettings", + "type": "object", + "properties": { + "n_retrieve": { + "title": "N Retrieve", + "description": "Number of results to initially retrieve from vector database", + "default": 50, + "type": "integer" + }, + "n_final": { + "title": "N Final", + "description": "Final number of results to use after re-ranking", + "default": 10, + "type": "integer" + }, + "use_reranking": { + "title": "Use Reranking", + "description": "Whether to use re-ranking, which will allow initial selection of n_retrieve results, then will use an LLM to select the top n_final results", + "default": true, + "type": "boolean" + }, + "rerank_group_size": { + "title": "Rerank Group Size", + "description": "Number of results to group together when re-ranking. Each group will be processed in parallel.", + "default": 5, + "type": "integer" + }, + "ignore_files": { + "title": "Ignore Files", + "description": "Files to ignore when indexing the codebase. You can use glob patterns, such as **/*.py. This is useful for directories that contain generated code, or other directories that are not relevant to the codebase.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "openai_api_key": { + "title": "Openai Api Key", + "description": "OpenAI API key", + "type": "string" + }, + "api_base": { + "title": "Api Base", + "description": "OpenAI API base URL", + "type": "string" + }, + "api_type": { + "title": "Api Type", + "description": "OpenAI API type", + "type": "string" + }, + "api_version": { + "title": "Api Version", + "description": "OpenAI API version", + "type": "string" + }, + "organization_id": { + "title": "Organization Id", + "description": "OpenAI organization ID", + "type": "string" + } + } + }, + "continuedev__core__config__serialized_config__SerializedContinueConfig": { + "title": "SerializedContinueConfig", + "type": "object", + "properties": { + "steps_on_startup": { + "title": "Steps On Startup", + "description": "Steps that will be automatically run at the beginning of a new session", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/StepWithParams" + } + }, + "disallowed_steps": { + "title": "Disallowed Steps", + "description": "Steps that are not allowed to be run, and will be skipped if attempted", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "allow_anonymous_telemetry": { + "title": "Allow Anonymous Telemetry", + "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.", + "default": true, + "type": "boolean" + }, + "models": { + "title": "Models", + "default": [ + { + "title": "GPT-4 (trial)", + "provider": "openai-free-trial", + "model": "gpt-4", + "api_key": "" + } + ], + "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": "GPT-4 (trial)", + "chat": null, + "edit": null, + "summarize": null + }, + "allOf": [ + { + "$ref": "#/definitions/ModelRoles" + } + ] + }, + "completion_options": { + "title": "Completion Options", + "description": "Default options for completion. These will be overriden by any options set for a specific model.", + "default": { + "temperature": null, + "top_p": null, + "top_k": null, + "presence_penalty": null, + "frequency_penalty": null, + "stop": null, + "max_tokens": 600 + }, + "allOf": [ + { + "$ref": "#/definitions/BaseCompletionOptions" + } + ] + }, + "slash_commands": { + "title": "Slash Commands", + "description": "An array of slash commands that let you map custom Steps to a shortcut.", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/SlashCommand" + } + }, + "custom_commands": { + "title": "Custom Commands", + "description": "An array of custom commands that allow you to reuse prompts. Each has name, description, and prompt properties. When you enter / in the text input, it will act as a shortcut to the prompt.", + "default": [ + { + "name": "test", + "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.", + "description": "This is an example custom command. Use /config to edit it and create more" + } + ], + "type": "array", + "items": { + "$ref": "#/definitions/CustomCommand" + } + }, + "context_providers": { + "title": "Context Providers", + "description": "A list of ContextProvider objects that can be used to provide context to the LLM by typing '@'. Read more about ContextProviders in the documentation.", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/StepWithParams" + } + }, + "user_token": { + "title": "User Token", + "description": "An optional token to identify the user.", + "type": "string" + }, + "data_server_url": { + "title": "Data Server Url", + "description": "The URL of the server where development data is sent. No data is sent unless a valid user token is provided.", + "default": "https://us-west1-autodebug.cloudfunctions.net", + "type": "string" + }, + "disable_summaries": { + "title": "Disable Summaries", + "description": "If set to `True`, Continue will not generate summaries for each Step. This can be useful if you want to save on compute.", + "default": false, + "type": "boolean" + }, + "disable_indexing": { + "title": "Disable Indexing", + "description": "If set to `True`, Continue will not index the codebase. This is mainly used for debugging purposes.", + "default": false, + "type": "boolean" + }, + "retrieval_settings": { + "title": "Retrieval Settings", + "description": "Settings for the retrieval system. Read more about the retrieval system in the documentation.", + "default": { + "n_retrieve": 50, + "n_final": 10, + "use_reranking": true, + "rerank_group_size": 5, + "ignore_files": [], + "openai_api_key": null, + "api_base": null, + "api_type": null, + "api_version": null, + "organization_id": null + }, + "allOf": [ + { + "$ref": "#/definitions/RetrievalSettings" + } + ] + } + } + } + } +} \ No newline at end of file diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 06d4a1a77..549fb2d9e 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -274,6 +274,12 @@ } ] } + ], + "jsonValidation": [ + { + "fileMatch": "config.json", + "url": "./SerializedContinueConfig.json" + } ] }, "scripts": { diff --git a/schema/json/ContinueConfig.json b/schema/json/ContinueConfig.json deleted file mode 100644 index 71a76c055..000000000 --- a/schema/json/ContinueConfig.json +++ /dev/null @@ -1,727 +0,0 @@ -{ - "title": "ContinueConfig", - "$ref": "#/definitions/continuedev__core__config__ContinueConfig", - "definitions": { - "FunctionCall": { - "title": "FunctionCall", - "type": "object", - "properties": { - "name": { - "title": "Name", - "type": "string" - }, - "arguments": { - "title": "Arguments", - "type": "string" - } - }, - "required": [ - "name", - "arguments" - ] - }, - "ChatMessage": { - "title": "ChatMessage", - "type": "object", - "properties": { - "role": { - "title": "Role", - "enum": [ - "assistant", - "user", - "system", - "function" - ], - "type": "string" - }, - "content": { - "title": "Content", - "type": "string" - }, - "name": { - "title": "Name", - "type": "string" - }, - "summary": { - "title": "Summary", - "type": "string" - }, - "function_call": { - "$ref": "#/definitions/FunctionCall" - } - }, - "required": [ - "role", - "summary" - ] - }, - "Step": { - "title": "Step", - "type": "object", - "properties": { - "name": { - "title": "Name", - "type": "string" - }, - "hide": { - "title": "Hide", - "default": false, - "type": "boolean" - }, - "description": { - "title": "Description", - "default": "", - "type": "string" - }, - "class_name": { - "title": "Class Name", - "default": "Step", - "type": "string" - }, - "system_message": { - "title": "System Message", - "type": "string" - }, - "chat_context": { - "title": "Chat Context", - "default": [], - "type": "array", - "items": { - "$ref": "#/definitions/ChatMessage" - } - }, - "manage_own_chat_context": { - "title": "Manage Own Chat Context", - "default": false, - "type": "boolean" - } - } - }, - "LLM": { - "title": "LLM", - "type": "object", - "properties": { - "title": { - "title": "Title", - "description": "A title that will identify this model in the model selection dropdown", - "type": "string" - }, - "unique_id": { - "title": "Unique Id", - "description": "The unique ID of the user.", - "type": "string" - }, - "model": { - "title": "Model", - "description": "The name of the model to be used (e.g. gpt-4, codellama)", - "type": "string" - }, - "system_message": { - "title": "System Message", - "description": "A system message that will always be followed by the LLM", - "type": "string" - }, - "context_length": { - "title": "Context Length", - "description": "The maximum context length of the LLM in tokens, as counted by count_tokens.", - "default": 2048, - "type": "integer" - }, - "stop_tokens": { - "title": "Stop Tokens", - "description": "Tokens that will stop the completion.", - "type": "array", - "items": { - "type": "string" - } - }, - "temperature": { - "title": "Temperature", - "description": "The temperature of the completion.", - "type": "number" - }, - "top_p": { - "title": "Top P", - "description": "The top_p of the completion.", - "type": "number" - }, - "top_k": { - "title": "Top K", - "description": "The top_k of the completion.", - "type": "integer" - }, - "presence_penalty": { - "title": "Presence Penalty", - "description": "The presence penalty Aof the completion.", - "type": "number" - }, - "frequency_penalty": { - "title": "Frequency Penalty", - "description": "The frequency penalty of the completion.", - "type": "number" - }, - "timeout": { - "title": "Timeout", - "description": "Set the timeout for each request to the LLM. If you are running a local LLM that takes a while to respond, you might want to set this to avoid timeouts.", - "default": 300, - "type": "integer" - }, - "verify_ssl": { - "title": "Verify Ssl", - "description": "Whether to verify SSL certificates for requests.", - "type": "boolean" - }, - "ca_bundle_path": { - "title": "Ca Bundle Path", - "description": "Path to a custom CA bundle to use when making the HTTP request", - "type": "string" - }, - "proxy": { - "title": "Proxy", - "description": "Proxy URL to use when making the HTTP request", - "type": "string" - }, - "headers": { - "title": "Headers", - "description": "Headers to use when making the HTTP request", - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "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" - } - }, - "required": [ - "model" - ] - }, - "Models": { - "title": "Models", - "description": "Main class that holds the current model configuration", - "type": "object", - "properties": { - "default": { - "$ref": "#/definitions/LLM" - }, - "summarize": { - "$ref": "#/definitions/LLM" - }, - "edit": { - "$ref": "#/definitions/LLM" - }, - "chat": { - "$ref": "#/definitions/LLM" - }, - "saved": { - "title": "Saved", - "default": [], - "type": "array", - "items": { - "$ref": "#/definitions/LLM" - } - }, - "temperature": { - "title": "Temperature", - "type": "number" - }, - "system_message": { - "title": "System Message", - "type": "string" - } - }, - "required": [ - "default" - ] - }, - "CustomCommand": { - "title": "CustomCommand", - "type": "object", - "properties": { - "name": { - "title": "Name", - "type": "string" - }, - "prompt": { - "title": "Prompt", - "type": "string" - }, - "description": { - "title": "Description", - "type": "string" - } - }, - "required": [ - "name", - "prompt", - "description" - ] - }, - "SlashCommand": { - "title": "SlashCommand", - "type": "object", - "properties": { - "name": { - "title": "Name", - "type": "string" - }, - "description": { - "title": "Description", - "type": "string" - }, - "step": { - "title": "Step" - }, - "params": { - "title": "Params", - "default": {}, - "type": "object" - } - }, - "required": [ - "name", - "description", - "step" - ] - }, - "Policy": { - "title": "Policy", - "description": "A rule that determines which step to take next", - "type": "object", - "properties": {} - }, - "ContextItemId": { - "title": "ContextItemId", - "description": "A ContextItemId is a unique identifier for a ContextItem.", - "type": "object", - "properties": { - "provider_title": { - "title": "Provider Title", - "type": "string" - }, - "item_id": { - "title": "Item Id", - "type": "string" - } - }, - "required": [ - "provider_title", - "item_id" - ] - }, - "ContextItemDescription": { - "title": "ContextItemDescription", - "description": "A ContextItemDescription is a description of a ContextItem that is displayed to the user when they type '@'.\n\nThe id can be used to retrieve the ContextItem from the ContextManager.", - "type": "object", - "properties": { - "name": { - "title": "Name", - "type": "string" - }, - "description": { - "title": "Description", - "type": "string" - }, - "id": { - "$ref": "#/definitions/ContextItemId" - } - }, - "required": [ - "name", - "description", - "id" - ] - }, - "ContextItem": { - "title": "ContextItem", - "description": "A ContextItem is a single item that is stored in the ContextManager.", - "type": "object", - "properties": { - "description": { - "$ref": "#/definitions/ContextItemDescription" - }, - "content": { - "title": "Content", - "type": "string" - }, - "editing": { - "title": "Editing", - "default": false, - "type": "boolean" - }, - "editable": { - "title": "Editable", - "default": false, - "type": "boolean" - } - }, - "required": [ - "description", - "content" - ] - }, - "ContextProvider": { - "title": "ContextProvider", - "description": "The ContextProvider class is a plugin that lets you provide new information to the LLM by typing '@'.\nWhen you type '@', the context provider will be asked to populate a list of options.\nThese options will be updated on each keystroke.\nWhen you hit enter on an option, the context provider will add that item to the autopilot's list of context (which is all stored in the ContextManager object).", - "type": "object", - "properties": { - "title": { - "title": "Title", - "description": "The title of the ContextProvider. This is what must be typed in the input to trigger the ContextProvider.", - "type": "string" - }, - "ide": { - "title": "Ide" - }, - "display_title": { - "title": "Display Title", - "description": "The display title of the ContextProvider shown in the dropdown menu", - "type": "string" - }, - "description": { - "title": "Description", - "description": "A description of the ContextProvider displayed in the dropdown menu", - "type": "string" - }, - "dynamic": { - "title": "Dynamic", - "description": "Indicates whether the ContextProvider is dynamic", - "type": "boolean" - }, - "requires_query": { - "title": "Requires Query", - "description": "Indicates whether the ContextProvider requires a query. For example, the SearchContextProvider requires you to type '@search '. This will change the behavior of the UI so that it can indicate the expectation for a query.", - "default": false, - "type": "boolean" - }, - "selected_items": { - "title": "Selected Items", - "description": "List of selected items in the ContextProvider", - "default": [], - "type": "array", - "items": { - "$ref": "#/definitions/ContextItem" - } - } - }, - "required": [ - "title", - "display_title", - "description", - "dynamic" - ] - }, - "RetrievalSettings": { - "title": "RetrievalSettings", - "type": "object", - "properties": { - "n_retrieve": { - "title": "N Retrieve", - "description": "Number of results to initially retrieve from vector database", - "default": 50, - "type": "integer" - }, - "n_final": { - "title": "N Final", - "description": "Final number of results to use after re-ranking", - "default": 10, - "type": "integer" - }, - "use_reranking": { - "title": "Use Reranking", - "description": "Whether to use re-ranking, which will allow initial selection of n_retrieve results, then will use an LLM to select the top n_final results", - "default": true, - "type": "boolean" - }, - "rerank_group_size": { - "title": "Rerank Group Size", - "description": "Number of results to group together when re-ranking. Each group will be processed in parallel.", - "default": 5, - "type": "integer" - }, - "ignore_files": { - "title": "Ignore Files", - "description": "Files to ignore when indexing the codebase. You can use glob patterns, such as **/*.py. This is useful for directories that contain generated code, or other directories that are not relevant to the codebase.", - "default": [], - "type": "array", - "items": { - "type": "string" - } - }, - "openai_api_key": { - "title": "Openai Api Key", - "description": "OpenAI API key", - "type": "string" - }, - "api_base": { - "title": "Api Base", - "description": "OpenAI API base URL", - "type": "string" - }, - "api_type": { - "title": "Api Type", - "description": "OpenAI API type", - "type": "string" - }, - "api_version": { - "title": "Api Version", - "description": "OpenAI API version", - "type": "string" - }, - "organization_id": { - "title": "Organization Id", - "description": "OpenAI organization ID", - "type": "string" - } - } - }, - "continuedev__core__config__ContinueConfig": { - "title": "ContinueConfig", - "description": "Continue can be deeply customized by editing the `ContinueConfig` object in `~/.continue/config.py` (`%userprofile%\\.continue\\config.py` for Windows) on your machine. This class is instantiated from the config file for every new session.", - "type": "object", - "properties": { - "steps_on_startup": { - "title": "Steps On Startup", - "description": "Steps that will be automatically run at the beginning of a new session", - "default": [], - "type": "array", - "items": { - "$ref": "#/definitions/Step" - } - }, - "disallowed_steps": { - "title": "Disallowed Steps", - "description": "Steps that are not allowed to be run, and will be skipped if attempted", - "default": [], - "type": "array", - "items": { - "type": "string" - } - }, - "allow_anonymous_telemetry": { - "title": "Allow Anonymous Telemetry", - "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.", - "default": true, - "type": "boolean" - }, - "models": { - "title": "Models", - "description": "Configuration for the models used by Continue. Read more about how to configure models in the documentation.", - "default": { - "default": { - "title": null, - "model": "gpt-4", - "system_message": null, - "context_length": 2048, - "stop_tokens": null, - "temperature": null, - "top_p": null, - "top_k": null, - "presence_penalty": null, - "frequency_penalty": null, - "timeout": 300, - "verify_ssl": null, - "ca_bundle_path": null, - "proxy": null, - "headers": null, - "prompt_templates": {}, - "template_messages": null, - "api_key": null, - "llm": null, - "class_name": "OpenAIFreeTrial" - }, - "summarize": { - "title": null, - "model": "gpt-3.5-turbo", - "system_message": null, - "context_length": 2048, - "stop_tokens": null, - "temperature": null, - "top_p": null, - "top_k": null, - "presence_penalty": null, - "frequency_penalty": null, - "timeout": 300, - "verify_ssl": null, - "ca_bundle_path": null, - "proxy": null, - "headers": null, - "prompt_templates": {}, - "template_messages": null, - "api_key": null, - "llm": null, - "class_name": "OpenAIFreeTrial" - }, - "edit": { - "title": null, - "model": "gpt-4", - "system_message": null, - "context_length": 2048, - "stop_tokens": null, - "temperature": null, - "top_p": null, - "top_k": null, - "presence_penalty": null, - "frequency_penalty": null, - "timeout": 300, - "verify_ssl": null, - "ca_bundle_path": null, - "proxy": null, - "headers": null, - "prompt_templates": {}, - "template_messages": null, - "api_key": null, - "llm": null, - "class_name": "OpenAIFreeTrial" - }, - "chat": { - "title": null, - "model": "gpt-4", - "system_message": null, - "context_length": 2048, - "stop_tokens": null, - "temperature": null, - "top_p": null, - "top_k": null, - "presence_penalty": null, - "frequency_penalty": null, - "timeout": 300, - "verify_ssl": null, - "ca_bundle_path": null, - "proxy": null, - "headers": null, - "prompt_templates": {}, - "template_messages": null, - "api_key": null, - "llm": null, - "class_name": "OpenAIFreeTrial" - }, - "saved": [], - "temperature": null, - "system_message": null - }, - "allOf": [ - { - "$ref": "#/definitions/Models" - } - ] - }, - "temperature": { - "title": "Temperature", - "description": "The temperature parameter for sampling from the LLM. Higher temperatures will result in more random output, while lower temperatures will result in more predictable output. This value ranges from 0 to 1.", - "default": 0.5, - "type": "number" - }, - "custom_commands": { - "title": "Custom Commands", - "description": "An array of custom commands that allow you to reuse prompts. Each has name, description, and prompt properties. When you enter / in the text input, it will act as a shortcut to the prompt.", - "default": [ - { - "name": "test", - "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.", - "description": "This is an example custom command. Use /config to edit it and create more" - } - ], - "type": "array", - "items": { - "$ref": "#/definitions/CustomCommand" - } - }, - "slash_commands": { - "title": "Slash Commands", - "description": "An array of slash commands that let you map custom Steps to a shortcut.", - "default": [], - "type": "array", - "items": { - "$ref": "#/definitions/SlashCommand" - } - }, - "on_traceback": { - "title": "On Traceback", - "description": "The step that will be run when a traceback is detected (when you use the shortcut cmd+shift+R)", - "allOf": [ - { - "$ref": "#/definitions/Step" - } - ] - }, - "system_message": { - "title": "System Message", - "description": "A system message that will always be followed by the LLM", - "type": "string" - }, - "policy_override": { - "title": "Policy Override", - "description": "A Policy object that can be used to override the default behavior of Continue, for example in order to build custom agents that take multiple steps at a time.", - "allOf": [ - { - "$ref": "#/definitions/Policy" - } - ] - }, - "context_providers": { - "title": "Context Providers", - "description": "A list of ContextProvider objects that can be used to provide context to the LLM by typing '@'. Read more about ContextProviders in the documentation.", - "default": [], - "type": "array", - "items": { - "$ref": "#/definitions/ContextProvider" - } - }, - "user_token": { - "title": "User Token", - "description": "An optional token to identify the user.", - "type": "string" - }, - "data_server_url": { - "title": "Data Server Url", - "description": "The URL of the server where development data is sent. No data is sent unless a valid user token is provided.", - "default": "https://us-west1-autodebug.cloudfunctions.net", - "type": "string" - }, - "disable_summaries": { - "title": "Disable Summaries", - "description": "If set to `True`, Continue will not generate summaries for each Step. This can be useful if you want to save on compute.", - "default": false, - "type": "boolean" - }, - "disable_indexing": { - "title": "Disable Indexing", - "description": "If set to `True`, Continue will not index the codebase. This is mainly used for debugging purposes.", - "default": false, - "type": "boolean" - }, - "retrieval_settings": { - "title": "Retrieval Settings", - "description": "Settings for the retrieval system. Read more about the retrieval system in the documentation.", - "default": { - "n_retrieve": 50, - "n_final": 10, - "use_reranking": true, - "rerank_group_size": 5, - "ignore_files": [], - "openai_api_key": null, - "api_base": null, - "api_type": null, - "api_version": null, - "organization_id": null - }, - "allOf": [ - { - "$ref": "#/definitions/RetrievalSettings" - } - ] - } - } - } - } -} \ No newline at end of file diff --git a/schema/json/LLM.json b/schema/json/LLM.json index cde480e86..be340014d 100644 --- a/schema/json/LLM.json +++ b/schema/json/LLM.json @@ -32,6 +32,12 @@ "default": 2048, "type": "integer" }, + "max_tokens": { + "title": "Max Tokens", + "description": "The maximum number of tokens to generate.", + "default": 600, + "type": "integer" + }, "stop_tokens": { "title": "Stop Tokens", "description": "Tokens that will stop the completion.", diff --git a/schema/json/Models.json b/schema/json/Models.json index 10f4f8546..26812b3df 100644 --- a/schema/json/Models.json +++ b/schema/json/Models.json @@ -32,6 +32,12 @@ "default": 2048, "type": "integer" }, + "max_tokens": { + "title": "Max Tokens", + "description": "The maximum number of tokens to generate.", + "default": 600, + "type": "integer" + }, "stop_tokens": { "title": "Stop Tokens", "description": "Tokens that will stop the completion.", diff --git a/schema/json/SerializedContinueConfig.json b/schema/json/SerializedContinueConfig.json new file mode 100644 index 000000000..059755036 --- /dev/null +++ b/schema/json/SerializedContinueConfig.json @@ -0,0 +1,514 @@ +{ + "title": "SerializedContinueConfig", + "$ref": "#/definitions/continuedev__core__config__serialized_config__SerializedContinueConfig", + "definitions": { + "StepWithParams": { + "title": "StepWithParams", + "type": "object", + "properties": { + "step": { + "title": "Step", + "enum": [ + "AnswerQuestionChroma", + "GenerateShellCommandStep", + "EditHighlightedCodeStep", + "ShareSessionStep", + "CommentCodeStep", + "ClearHistoryStep", + "StackOverflowStep" + ], + "type": "string" + }, + "params": { + "title": "Params", + "type": "object" + } + }, + "required": [ + "step", + "params" + ] + }, + "BaseCompletionOptions": { + "title": "BaseCompletionOptions", + "type": "object", + "properties": { + "temperature": { + "title": "Temperature", + "description": "The temperature of the completion.", + "type": "number" + }, + "top_p": { + "title": "Top P", + "description": "The top_p of the completion.", + "type": "number" + }, + "top_k": { + "title": "Top K", + "description": "The top_k of the completion.", + "type": "integer" + }, + "presence_penalty": { + "title": "Presence Penalty", + "description": "The presence penalty Aof the completion.", + "type": "number" + }, + "frequency_penalty": { + "title": "Frequency Penalty", + "description": "The frequency penalty of the completion.", + "type": "number" + }, + "stop": { + "title": "Stop", + "description": "The stop tokens of the completion.", + "type": "array", + "items": { + "type": "string" + } + }, + "max_tokens": { + "title": "Max Tokens", + "description": "The maximum number of tokens to generate.", + "default": 600, + "type": "integer" + } + } + }, + "RequestOptions": { + "title": "RequestOptions", + "type": "object", + "properties": { + "timeout": { + "title": "Timeout", + "description": "Set the timeout for each request to the LLM. If you are running a local LLM that takes a while to respond, you might want to set this to avoid timeouts.", + "default": 300, + "type": "integer" + }, + "verify_ssl": { + "title": "Verify Ssl", + "description": "Whether to verify SSL certificates for requests.", + "type": "boolean" + }, + "ca_bundle_path": { + "title": "Ca Bundle Path", + "description": "Path to a custom CA bundle to use when making the HTTP request", + "type": "string" + }, + "proxy": { + "title": "Proxy", + "description": "Proxy URL to use when making the HTTP request", + "type": "string" + }, + "headers": { + "title": "Headers", + "description": "Headers to use when making the HTTP request", + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + }, + "ModelDescription": { + "title": "ModelDescription", + "type": "object", + "properties": { + "title": { + "title": "Title", + "description": "The title you wish to give your model.", + "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" + ], + "type": "string" + }, + "model": { + "title": "Model", + "description": "The name of the model. Used to autodetect prompt template.", + "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.", + "type": "string" + }, + "context_length": { + "title": "Context Length", + "description": "The maximum context length of the LLM in tokens, as counted by count_tokens.", + "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" + ], + "type": "string" + }, + "completion_options": { + "title": "Completion Options", + "description": "Options for the completion endpoint. Read more about the completion options in the documentation.", + "default": { + "temperature": null, + "top_p": null, + "top_k": null, + "presence_penalty": null, + "frequency_penalty": null, + "stop": null, + "max_tokens": 600 + }, + "allOf": [ + { + "$ref": "#/definitions/BaseCompletionOptions" + } + ] + }, + "request_options": { + "title": "Request Options", + "description": "Options for the HTTP request to the LLM.", + "default": { + "timeout": 300, + "verify_ssl": null, + "ca_bundle_path": null, + "proxy": null, + "headers": null + }, + "allOf": [ + { + "$ref": "#/definitions/RequestOptions" + } + ] + } + }, + "required": [ + "title", + "provider", + "model" + ] + }, + "ModelRoles": { + "title": "ModelRoles", + "type": "object", + "properties": { + "default": { + "title": "Default", + "description": "The default model. If other model roles are not set, they will fall back to default.", + "type": "string" + }, + "chat": { + "title": "Chat", + "description": "The model to use for chat. If not set, will fall back to default.", + "type": "string" + }, + "edit": { + "title": "Edit", + "description": "The model to use for editing. If not set, will fall back to default.", + "type": "string" + }, + "summarize": { + "title": "Summarize", + "description": "The model to use for summarization. If not set, will fall back to default.", + "type": "string" + } + }, + "required": [ + "default" + ] + }, + "SlashCommand": { + "title": "SlashCommand", + "type": "object", + "properties": { + "name": { + "title": "Name", + "type": "string" + }, + "description": { + "title": "Description", + "type": "string" + }, + "step": { + "title": "Step" + }, + "params": { + "title": "Params", + "default": {}, + "type": "object" + } + }, + "required": [ + "name", + "description", + "step" + ] + }, + "CustomCommand": { + "title": "CustomCommand", + "type": "object", + "properties": { + "name": { + "title": "Name", + "type": "string" + }, + "prompt": { + "title": "Prompt", + "type": "string" + }, + "description": { + "title": "Description", + "type": "string" + } + }, + "required": [ + "name", + "prompt", + "description" + ] + }, + "RetrievalSettings": { + "title": "RetrievalSettings", + "type": "object", + "properties": { + "n_retrieve": { + "title": "N Retrieve", + "description": "Number of results to initially retrieve from vector database", + "default": 50, + "type": "integer" + }, + "n_final": { + "title": "N Final", + "description": "Final number of results to use after re-ranking", + "default": 10, + "type": "integer" + }, + "use_reranking": { + "title": "Use Reranking", + "description": "Whether to use re-ranking, which will allow initial selection of n_retrieve results, then will use an LLM to select the top n_final results", + "default": true, + "type": "boolean" + }, + "rerank_group_size": { + "title": "Rerank Group Size", + "description": "Number of results to group together when re-ranking. Each group will be processed in parallel.", + "default": 5, + "type": "integer" + }, + "ignore_files": { + "title": "Ignore Files", + "description": "Files to ignore when indexing the codebase. You can use glob patterns, such as **/*.py. This is useful for directories that contain generated code, or other directories that are not relevant to the codebase.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "openai_api_key": { + "title": "Openai Api Key", + "description": "OpenAI API key", + "type": "string" + }, + "api_base": { + "title": "Api Base", + "description": "OpenAI API base URL", + "type": "string" + }, + "api_type": { + "title": "Api Type", + "description": "OpenAI API type", + "type": "string" + }, + "api_version": { + "title": "Api Version", + "description": "OpenAI API version", + "type": "string" + }, + "organization_id": { + "title": "Organization Id", + "description": "OpenAI organization ID", + "type": "string" + } + } + }, + "continuedev__core__config__serialized_config__SerializedContinueConfig": { + "title": "SerializedContinueConfig", + "type": "object", + "properties": { + "steps_on_startup": { + "title": "Steps On Startup", + "description": "Steps that will be automatically run at the beginning of a new session", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/StepWithParams" + } + }, + "disallowed_steps": { + "title": "Disallowed Steps", + "description": "Steps that are not allowed to be run, and will be skipped if attempted", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "allow_anonymous_telemetry": { + "title": "Allow Anonymous Telemetry", + "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.", + "default": true, + "type": "boolean" + }, + "models": { + "title": "Models", + "default": [ + { + "title": "GPT-4 (trial)", + "provider": "openai-free-trial", + "model": "gpt-4", + "api_key": "" + } + ], + "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": "GPT-4 (trial)", + "chat": null, + "edit": null, + "summarize": null + }, + "allOf": [ + { + "$ref": "#/definitions/ModelRoles" + } + ] + }, + "completion_options": { + "title": "Completion Options", + "description": "Default options for completion. These will be overriden by any options set for a specific model.", + "default": { + "temperature": null, + "top_p": null, + "top_k": null, + "presence_penalty": null, + "frequency_penalty": null, + "stop": null, + "max_tokens": 600 + }, + "allOf": [ + { + "$ref": "#/definitions/BaseCompletionOptions" + } + ] + }, + "slash_commands": { + "title": "Slash Commands", + "description": "An array of slash commands that let you map custom Steps to a shortcut.", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/SlashCommand" + } + }, + "custom_commands": { + "title": "Custom Commands", + "description": "An array of custom commands that allow you to reuse prompts. Each has name, description, and prompt properties. When you enter / in the text input, it will act as a shortcut to the prompt.", + "default": [ + { + "name": "test", + "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.", + "description": "This is an example custom command. Use /config to edit it and create more" + } + ], + "type": "array", + "items": { + "$ref": "#/definitions/CustomCommand" + } + }, + "context_providers": { + "title": "Context Providers", + "description": "A list of ContextProvider objects that can be used to provide context to the LLM by typing '@'. Read more about ContextProviders in the documentation.", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/StepWithParams" + } + }, + "user_token": { + "title": "User Token", + "description": "An optional token to identify the user.", + "type": "string" + }, + "data_server_url": { + "title": "Data Server Url", + "description": "The URL of the server where development data is sent. No data is sent unless a valid user token is provided.", + "default": "https://us-west1-autodebug.cloudfunctions.net", + "type": "string" + }, + "disable_summaries": { + "title": "Disable Summaries", + "description": "If set to `True`, Continue will not generate summaries for each Step. This can be useful if you want to save on compute.", + "default": false, + "type": "boolean" + }, + "disable_indexing": { + "title": "Disable Indexing", + "description": "If set to `True`, Continue will not index the codebase. This is mainly used for debugging purposes.", + "default": false, + "type": "boolean" + }, + "retrieval_settings": { + "title": "Retrieval Settings", + "description": "Settings for the retrieval system. Read more about the retrieval system in the documentation.", + "default": { + "n_retrieve": 50, + "n_final": 10, + "use_reranking": true, + "rerank_group_size": 5, + "ignore_files": [], + "openai_api_key": null, + "api_base": null, + "api_type": null, + "api_version": null, + "organization_id": null + }, + "allOf": [ + { + "$ref": "#/definitions/RetrievalSettings" + } + ] + } + } + } + } +} \ No newline at end of file diff --git a/server/config.py b/server/config.py index 513fee2c7..b023a4d24 100644 --- a/server/config.py +++ b/server/config.py @@ -5,7 +5,11 @@ See https://continue.dev/docs/customization to for documentation of the availabl """ from continuedev.core.models import Models -from continuedev.core.config import CustomCommand, SlashCommand, ContinueConfig +from continuedev.core.config.serialized_config import ( + CustomCommand, + SlashCommand, + ContinueConfig, +) from continuedev.libs.llm import OpenAIFreeTrial from continuedev.plugins.context_providers import ( diff --git a/server/continuedev/__init__.py b/server/continuedev/__init__.py index 9a26baeea..2fa7e7f47 100644 --- a/server/continuedev/__init__.py +++ b/server/continuedev/__init__.py @@ -1,7 +1,7 @@ import asyncio from typing import Union -from .core.config import ContinueConfig +from .core.config.serialized_config import ContinueConfig from .core.main import Step # from .headless import start_headless_session diff --git a/server/continuedev/__main__.py b/server/continuedev/__main__.py index 4fcdbd494..7d5714de3 100644 --- a/server/continuedev/__main__.py +++ b/server/continuedev/__main__.py @@ -3,7 +3,7 @@ import os from typing import Optional from tqdm import tqdm -from .core.config import ContinueConfig +from .core.config.serialized_config import ContinueConfig from .headless.headless_ide import LocalIdeProtocol from .libs.index.build_index import build_index from .libs.util.ext_to_lang import ext_to_lang diff --git a/server/continuedev/core/autopilot.py b/server/continuedev/core/autopilot.py index ba9946bbf..8bc15fb57 100644 --- a/server/continuedev/core/autopilot.py +++ b/server/continuedev/core/autopilot.py @@ -25,7 +25,7 @@ from ..server.protocols.ide_protocol import AbstractIdeProtocolServer from ..plugins.policies.default import DefaultPolicy from ..plugins.steps.on_traceback import DefaultOnTracebackStep -from .config import ContinueConfig +from .config.serialized_config import ContinueConfig from .main import ( AutopilotGenerator, AutopilotGeneratorOutput, diff --git a/server/continuedev/core/config.py b/server/continuedev/core/config/config.py similarity index 70% rename from server/continuedev/core/config.py rename to server/continuedev/core/config/config.py index 2267b6a6d..a5def0ac1 100644 --- a/server/continuedev/core/config.py +++ b/server/continuedev/core/config/config.py @@ -1,79 +1,29 @@ from typing import Dict, List, Optional, Type -from ..libs.util.edit_config import ( +from ...libs.llm.base import BaseCompletionOptions + +from .serialized_config import ( + CustomCommand, + RetrievalSettings, + SerializedContinueConfig, + SlashCommand, +) + +from ...libs.util.edit_config import ( create_bool_node, create_obj_node, display_llm_class, edit_config_property, ) -from ..libs.util.paths import convertConfigImports, getConfigFilePath +from ...libs.util.paths import convertConfigImports, getConfigFilePath from pydantic import BaseModel, Field, validator -from ..libs.llm.openai_free_trial import OpenAIFreeTrial -from .context import ContextProvider -from .main import ContextProviderDescription, Policy, SlashCommandDescription, Step -from .models import Models -from ..libs.util.telemetry import posthog_logger - - -class SlashCommand(BaseModel): - name: str - description: str - step: Type[Step] - params: Optional[Dict] = {} - - def dict(self, *args, **kwargs): - return { - "name": self.name, - "description": self.description, - "params": self.params, - "step": self.step.__name__, - } - - def slash_command_description(self) -> SlashCommandDescription: - return SlashCommandDescription( - name=self.name, - description=self.description, - ) - - -class CustomCommand(BaseModel): - name: str - prompt: str - description: str - - def slash_command_description(self) -> SlashCommandDescription: - return SlashCommandDescription( - name=self.name, - description=self.description, - ) - - -class RetrievalSettings(BaseModel): - n_retrieve: Optional[int] = Field( - 50, description="Number of results to initially retrieve from vector database" - ) - n_final: Optional[int] = Field( - 10, description="Final number of results to use after re-ranking" - ) - use_reranking: bool = Field( - True, - description="Whether to use re-ranking, which will allow initial selection of n_retrieve results, then will use an LLM to select the top n_final results", - ) - rerank_group_size: int = Field( - 5, - description="Number of results to group together when re-ranking. Each group will be processed in parallel.", - ) - ignore_files: List[str] = Field( - [], - description="Files to ignore when indexing the codebase. You can use glob patterns, such as **/*.py. This is useful for directories that contain generated code, or other directories that are not relevant to the codebase.", - ) - openai_api_key: Optional[str] = Field(None, description="OpenAI API key") - api_base: Optional[str] = Field(None, description="OpenAI API base URL") - api_type: Optional[str] = Field(None, description="OpenAI API type") - api_version: Optional[str] = Field(None, description="OpenAI API version") - organization_id: Optional[str] = Field(None, description="OpenAI organization ID") +from ...libs.llm.openai_free_trial import OpenAIFreeTrial +from ..context import ContextProvider +from ..main import ContextProviderDescription, Policy, SlashCommandDescription, Step +from ..models import Models +from ...libs.util.telemetry import posthog_logger class ContinueConfig(BaseModel): @@ -100,9 +50,9 @@ class ContinueConfig(BaseModel): ), description="Configuration for the models used by Continue. Read more about how to configure models in the documentation.", ) - temperature: Optional[float] = Field( - 0.5, - description="The temperature parameter for sampling from the LLM. Higher temperatures will result in more random output, while lower temperatures will result in more predictable output. This value ranges from 0 to 1.", + completion_options: BaseCompletionOptions = Field( + BaseCompletionOptions(), + description="Options for the completion endpoint. Read more about the completion options in the documentation.", ) custom_commands: Optional[List[CustomCommand]] = Field( [ @@ -122,9 +72,6 @@ class ContinueConfig(BaseModel): None, description="The step that will be run when a traceback is detected (when you use the shortcut cmd+shift+R)", ) - system_message: Optional[str] = Field( - None, description="A system message that will always be followed by the LLM" - ) policy_override: Optional[Policy] = Field( None, description="A Policy object that can be used to override the default behavior of Continue, for example in order to build custom agents that take multiple steps at a time.", @@ -153,15 +100,27 @@ class ContinueConfig(BaseModel): description="Settings for the retrieval system. Read more about the retrieval system in the documentation.", ) - @classmethod - def schema(cls, *args, **kwargs): - # kwargs.setdefault("exclude", {"ide"}) - return super().schema(*args, **kwargs) - @validator("temperature", pre=True) def temperature_validator(cls, v): return max(0.0, min(1.0, v)) + @staticmethod + def from_serialized_config(config: SerializedContinueConfig) -> "ContinueConfig": + return ContinueConfig( + disallowed_steps=config.disallowed_steps, + allow_anonymous_telemetry=config.allow_anonymous_telemetry, + models=Models.from_serialized_config(config), + completion_options=config.completion_options, + custom_commands=config.custom_commands, + slash_commands=config.slash_commands, + context_providers=config.context_providers, + user_token=config.user_token, + data_server_url=config.data_server_url, + disable_summaries=config.disable_summaries, + disable_indexing=config.disable_indexing, + retrieval_settings=config.retrieval_settings, + ) + @staticmethod def from_filepath(filepath: str, retry: bool = True) -> "ContinueConfig": # Use importlib to load the config file config.py at the given path diff --git a/server/continuedev/core/config/serialized_config.py b/server/continuedev/core/config/serialized_config.py new file mode 100644 index 000000000..ee31d5e47 --- /dev/null +++ b/server/continuedev/core/config/serialized_config.py @@ -0,0 +1,197 @@ +from typing import Any, Dict, List, Literal, Optional, Type +from .shared import ModelProvider, RequestOptions, StepName, TemplateType +from pydantic import BaseModel, Field + +from ...libs.llm.base import BaseCompletionOptions +from ..main import SlashCommandDescription, Step + + +class StepWithParams(BaseModel): + step: StepName + params: Dict[str, Any] + + +class SlashCommand(BaseModel): + name: str + description: str + step: Type[Step] + params: Optional[Dict] = {} + + def dict(self, *args, **kwargs): + return { + "name": self.name, + "description": self.description, + "params": self.params, + "step": self.step.__name__, + } + + def slash_command_description(self) -> SlashCommandDescription: + return SlashCommandDescription( + name=self.name, + description=self.description, + ) + + +class CustomCommand(BaseModel): + name: str + prompt: str + description: str + + def slash_command_description(self) -> SlashCommandDescription: + return SlashCommandDescription( + name=self.name, + description=self.description, + ) + + +class RetrievalSettings(BaseModel): + n_retrieve: Optional[int] = Field( + 50, description="Number of results to initially retrieve from vector database" + ) + n_final: Optional[int] = Field( + 10, description="Final number of results to use after re-ranking" + ) + use_reranking: bool = Field( + True, + description="Whether to use re-ranking, which will allow initial selection of n_retrieve results, then will use an LLM to select the top n_final results", + ) + rerank_group_size: int = Field( + 5, + description="Number of results to group together when re-ranking. Each group will be processed in parallel.", + ) + ignore_files: List[str] = Field( + [], + description="Files to ignore when indexing the codebase. You can use glob patterns, such as **/*.py. This is useful for directories that contain generated code, or other directories that are not relevant to the codebase.", + ) + openai_api_key: Optional[str] = Field(None, description="OpenAI API key") + api_base: Optional[str] = Field(None, description="OpenAI API base URL") + api_type: Optional[str] = Field(None, description="OpenAI API type") + api_version: Optional[str] = Field(None, description="OpenAI API version") + organization_id: Optional[str] = Field(None, description="OpenAI organization ID") + + +class ModelDescription(BaseModel): + title: str = Field( + ..., + description="The title you wish to give your model.", + ) + + provider: ModelProvider = Field( + ..., + description="The provider of the model. This is used to determine the type of model, and how to interact with it.", + ) + model: str = Field( + ..., + description="The name of the model. Used to autodetect prompt template.", + ) + api_key: Optional[str] = Field( + None, description="OpenAI, Anthropic, Together, or other API key" + ) + api_base: Optional[str] = Field(None, description="The base URL of the LLM API.") + + context_length: int = Field( + 2048, + description="The maximum context length of the LLM in tokens, as counted by count_tokens.", + ) + template: Optional[TemplateType] = Field( + None, + description="The chat template used to format messages. This is auto-detected for most models, but can be overridden here.", + ) + completion_options: BaseCompletionOptions = Field( + BaseCompletionOptions(), + description="Options for the completion endpoint. Read more about the completion options in the documentation.", + ) + system_message: Optional[str] = Field( + None, + description="A system message that will always be followed by the LLM", + ) + + request_options: RequestOptions = Field( + RequestOptions(), + description="Options for the HTTP request to the LLM.", + ) + + +class ModelRoles(BaseModel): + default: str = Field( + ..., + description="The default model. If other model roles are not set, they will fall back to default.", + ) + chat: Optional[str] = Field( + None, + description="The model to use for chat. If not set, will fall back to default.", + ) + edit: Optional[str] = Field( + None, + description="The model to use for editing. If not set, will fall back to default.", + ) + summarize: Optional[str] = Field( + None, + description="The model to use for summarization. If not set, will fall back to default.", + ) + + +class SerializedContinueConfig(BaseModel): + disallowed_steps: Optional[List[str]] = Field( + [], + description="Steps that are not allowed to be run, and will be skipped if attempted", + ) + allow_anonymous_telemetry: Optional[bool] = Field( + 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( + [ + { + "title": "GPT-4 (trial)", + "provider": "openai-free-trial", + "model": "gpt-4", + "api_key": "", + } + ] + ) + model_roles: ModelRoles = Field( + ModelRoles(default="GPT-4 (trial)"), + description="Roles for models. Each entry should be the title of a model in the models array.", + ) + completion_options: BaseCompletionOptions = Field( + BaseCompletionOptions(), + description="Default options for completion. These will be overriden by any options set for a specific model.", + ) + slash_commands: Optional[List[SlashCommand]] = Field( + [], + description="An array of slash commands that let you map custom Steps to a shortcut.", + ) + custom_commands: Optional[List[CustomCommand]] = Field( + [ + CustomCommand( + name="test", + description="This is an example custom command. Use /config to edit it and create more", + 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.", + ) + ], + description="An array of custom commands that allow you to reuse prompts. Each has name, description, and prompt properties. When you enter / in the text input, it will act as a shortcut to the prompt.", + ) + context_providers: List[StepWithParams] = Field( + [], + description="A list of ContextProvider objects that can be used to provide context to the LLM by typing '@'. Read more about ContextProviders in the documentation.", + ) + user_token: Optional[str] = Field( + None, description="An optional token to identify the user." + ) + data_server_url: Optional[str] = Field( + "https://us-west1-autodebug.cloudfunctions.net", + description="The URL of the server where development data is sent. No data is sent unless a valid user token is provided.", + ) + disable_summaries: Optional[bool] = Field( + False, + description="If set to `True`, Continue will not generate summaries for each Step. This can be useful if you want to save on compute.", + ) + disable_indexing: Optional[bool] = Field( + False, + description="If set to `True`, Continue will not index the codebase. This is mainly used for debugging purposes.", + ) + retrieval_settings: Optional[RetrievalSettings] = Field( + RetrievalSettings(), + description="Settings for the retrieval system. Read more about the retrieval system in the documentation.", + ) diff --git a/server/continuedev/core/config/shared.py b/server/continuedev/core/config/shared.py new file mode 100644 index 000000000..675fa46aa --- /dev/null +++ b/server/continuedev/core/config/shared.py @@ -0,0 +1,137 @@ +from typing import Dict, Literal, Optional +from pydantic import BaseModel, Field + +from ...libs.llm.prompts.chat import ( + llama2_template_messages, + template_alpaca_messages, + phind_template_messages, + zephyr_template_messages, + chatml_template_messages, + anthropic_template_messages, +) + +from ...libs.llm.prompts.edit import ( + codellama_edit_prompt, + alpaca_edit_prompt, + simplest_edit_prompt, +) # TODO: Prompts for the rest of the template types + + +StepName = Literal[ + "AnswerQuestionChroma", + "GenerateShellCommandStep", + "EditHighlightedCodeStep", + "ShareSessionStep", + "CommentCodeStep", + "ClearHistoryStep", + "StackOverflowStep", +] + +TemplateType = Literal["llama2", "alpaca", "zephyr", "phind", "anthropic", "chatml"] + + +def autodetect_template_type(model: str) -> Optional[TemplateType]: + lower = model.lower() + if "gpt" in lower or "chat-bison" in lower: + return None + + if "phind" in lower: + return "phind" + + if "llama" in lower: + return "llama2" + + if "zephyr" in lower: + return "zephyr" + + if "claude" in lower: + return "anthropic" + + if "alpaca" in lower or "wizard" in lower: + return "alpaca" + + return "chatml" + + +def autodetect_template_function(model: str): + template_type = autodetect_template_type(model) + return { + "llama2": llama2_template_messages, + "alpaca": template_alpaca_messages, + "phind": phind_template_messages, + "zephyr": zephyr_template_messages, + "anthropic": anthropic_template_messages, + "chatml": chatml_template_messages, + }[template_type] + + +def autodetect_prompt_templates(model: str): + template_type = autodetect_template_type(model) + + templates = {} + + edit_template = None + if template_type == "llama2": + edit_template = codellama_edit_prompt + elif template_type == "alpaca": + edit_template = alpaca_edit_prompt + elif template_type is not None: + edit_template = simplest_edit_prompt + + if edit_template is not None: + templates["edit"] = edit_template + + return templates + + +ModelProvider = Literal[ + "openai", + "openai-free-trial", + "openai-aiohttp", + "anthropic", + "together", + "ollama", + "huggingface-tgi", + "huggingface-inference-api", + "llama.cpp", + "replicate", + "text-gen-webui", + "google-palm", +] + +MODEL_PROVIDER_TO_MODEL_CLASS = { + "openai": "OpenAI", + "openai-free-trial": "OpenAIFreeTrial", + "openai-aiohttp": "OpenAIFreeTrial", + "anthropic": "AnthropicLLM", + "together": "TogetherLLM", + "ollama": "Ollama", + "huggingface-tgi": "HuggingFaceTGI", + "huggingface-inference-api": "HuggingFaceInferenceAPI", + "llama.cpp": "LlamaCpp", + "replicate": "ReplicateLLM", + "text-gen-webui": "TextGenWebUI", + "google-palm": "GooglePaLMAPI", +} + + +class RequestOptions(BaseModel): + timeout: Optional[int] = Field( + 300, + description="Set the timeout for each request to the LLM. If you are running a local LLM that takes a while to respond, you might want to set this to avoid timeouts.", + ) + verify_ssl: Optional[bool] = Field( + None, description="Whether to verify SSL certificates for requests." + ) + ca_bundle_path: str = Field( + None, + description="Path to a custom CA bundle to use when making the HTTP request", + ) + proxy: Optional[str] = Field( + None, + description="Proxy URL to use when making the HTTP request", + ) + headers: Optional[Dict[str, str]] = Field( + None, + description="Headers to use when making the HTTP request", + ) diff --git a/server/continuedev/core/models.py b/server/continuedev/core/models.py index 2e94d4b7b..7e887ec59 100644 --- a/server/continuedev/core/models.py +++ b/server/continuedev/core/models.py @@ -1,5 +1,6 @@ -from typing import Callable, List, Optional +from typing import Callable, Dict, List, Optional import uuid +from .config.serialized_config import ModelDescription, SerializedContinueConfig from pydantic import BaseModel, validator @@ -16,6 +17,11 @@ from ..libs.llm.openai_free_trial import OpenAIFreeTrial from ..libs.llm.replicate import ReplicateLLM from ..libs.llm.together import TogetherLLM from ..libs.llm.text_gen_webui import TextGenWebUI +from ..core.config.shared import ( + MODEL_PROVIDER_TO_MODEL_CLASS, + autodetect_prompt_templates, + autodetect_template_function, +) class ContinueSDK(BaseModel): @@ -29,7 +35,7 @@ ALL_MODEL_ROLES = [ "chat", ] -MODEL_CLASSES = { +MODEL_CLASSES: Dict[str, LLM] = { cls.__name__: cls for cls in [ OpenAI, @@ -88,6 +94,40 @@ class Models(BaseModel): return values["default"] return v + @staticmethod + def from_serialized_config(config: SerializedContinueConfig) -> "Models": + def model_with_title(title: str, fallback: ModelDescription): + return next(filter(lambda x: x.title == title, config.models), fallback) + + default = model_with_title(config.model_roles.default, config.models[0]) + chat = model_with_title(config.model_roles.chat, default) + edit = model_with_title(config.model_roles.edit, default) + summarize = model_with_title(config.model_roles.summarize, default) + + def create_llm(model: ModelDescription) -> LLM: + model_class = MODEL_CLASSES[MODEL_PROVIDER_TO_MODEL_CLASS[model.provider]] + completion_options = config.completion_options.dict() + completion_options.update(model.completion_options.dict(exclude_none=True)) + model_class.system_message = model.system_message + return LLM( + api_key=model.api_key, + completion_options=completion_options, + request_options=model.request_options, + system_message=model.system_message, + api_base=model.api_base, # TODO + model=model.model, + template_messages=autodetect_template_function(model.model), + prompt_templates=autodetect_prompt_templates(model.model), + context_length=model.context_length, + ) # TODO: This doesn't yet match up with all of the fields. Check individual model types. Update them. Update the docs. + + return Models( + default=create_llm(default), + chat=create_llm(chat), + edit=create_llm(edit), + summarize=create_llm(summarize), + ) + def dict(self, **kwargs): original_dict = super().dict(**kwargs) return original_dict diff --git a/server/continuedev/core/sdk.py b/server/continuedev/core/sdk.py index bd83eac97..62261eafc 100644 --- a/server/continuedev/core/sdk.py +++ b/server/continuedev/core/sdk.py @@ -17,7 +17,7 @@ from ..models.filesystem_edit import ( from ..models.main import Range from ..server.protocols.ide_protocol import AbstractIdeProtocolServer from ..server.protocols.gui_protocol import AbstractGUIProtocolServer -from .config import ContinueConfig +from .config.serialized_config import ContinueConfig from .lsp import ContinueLSPClient from .main import ( ChatMessage, diff --git a/server/continuedev/headless/__init__.py b/server/continuedev/headless/__init__.py index 5bebf3cc7..b6df59f51 100644 --- a/server/continuedev/headless/__init__.py +++ b/server/continuedev/headless/__init__.py @@ -6,7 +6,7 @@ from ..core.context import ContextManager, ContextProvider from ..core.main import SessionState from ..core.autopilot import Autopilot from .headless_ide import LocalIdeProtocol -from ..core.config import ContinueConfig +from ..core.config.serialized_config import ContinueConfig async def get_headless_autopilot( diff --git a/server/continuedev/libs/index/build_index.py b/server/continuedev/libs/index/build_index.py index 30dfa3409..5d38939a3 100644 --- a/server/continuedev/libs/index/build_index.py +++ b/server/continuedev/libs/index/build_index.py @@ -1,6 +1,6 @@ import asyncio from typing import AsyncGenerator -from ...core.config import ContinueConfig +from ...core.config.serialized_config import ContinueConfig from ...server.protocols.ide_protocol import AbstractIdeProtocolServer from ...libs.index.chunkers.chunk_directory import ( stream_chunk_directory, diff --git a/server/continuedev/libs/llm/base.py b/server/continuedev/libs/llm/base.py index c72d8052f..97b8e3a90 100644 --- a/server/continuedev/libs/llm/base.py +++ b/server/continuedev/libs/llm/base.py @@ -5,6 +5,7 @@ from typing import Any, Callable, Coroutine, Dict, Generator, List, Optional, Un import aiohttp import certifi +from ...core.config.shared import RequestOptions from ..util.templating import render_templated_string from pydantic import Field, validator @@ -24,9 +25,7 @@ from ..util.telemetry import posthog_logger from ..util.logging import logger -class CompletionOptions(ContinueBaseModel): - """Options for the completion.""" - +class BaseCompletionOptions(ContinueBaseModel): @validator( "*", pre=True, @@ -35,7 +34,6 @@ class CompletionOptions(ContinueBaseModel): def ignore_none_and_set_default(cls, value, field): return value if value is not None else field.default - model: Optional[str] = Field(None, description="The model name") temperature: Optional[float] = Field( None, description="The temperature of the completion." ) @@ -53,6 +51,20 @@ class CompletionOptions(ContinueBaseModel): max_tokens: int = Field( DEFAULT_MAX_TOKENS, description="The maximum number of tokens to generate." ) + + +class CompletionOptions(BaseCompletionOptions): + """Options for the completion.""" + + @validator( + "*", + pre=True, + always=True, + ) + def ignore_none_and_set_default(cls, value, field): + return value if value is not None else field.default + + model: Optional[str] = Field(None, description="The model name") functions: Optional[List[Any]] = Field( None, description="The functions/tools to make available to the model." ) @@ -82,44 +94,17 @@ class LLM(ContinueBaseModel): 2048, description="The maximum context length of the LLM in tokens, as counted by count_tokens.", ) - max_tokens: int = Field( - DEFAULT_MAX_TOKENS, description="The maximum number of tokens to generate." + + completion_options: BaseCompletionOptions = Field( + BaseCompletionOptions(), + description="Options for the completion endpoint. Read more about the completion options in the documentation.", ) - stop_tokens: Optional[List[str]] = Field( - None, description="Tokens that will stop the completion." - ) - temperature: Optional[float] = Field( - None, description="The temperature of the completion." - ) - top_p: Optional[float] = Field(None, description="The top_p of the completion.") - top_k: Optional[int] = Field(None, description="The top_k of the completion.") - presence_penalty: Optional[float] = Field( - None, description="The presence penalty Aof the completion." - ) - frequency_penalty: Optional[float] = Field( - None, description="The frequency penalty of the completion." + request_options: RequestOptions = Field( + RequestOptions(), + description="Options for the HTTP request to the LLM.", ) - timeout: Optional[int] = Field( - 300, - description="Set the timeout for each request to the LLM. If you are running a local LLM that takes a while to respond, you might want to set this to avoid timeouts.", - ) - verify_ssl: Optional[bool] = Field( - None, description="Whether to verify SSL certificates for requests." - ) - ca_bundle_path: str = Field( - None, - description="Path to a custom CA bundle to use when making the HTTP request", - ) - proxy: Optional[str] = Field( - None, - description="Proxy URL to use when making the HTTP request", - ) - headers: Optional[Dict[str, str]] = Field( - None, - description="Headers to use when making the HTTP request", - ) prompt_templates: dict = Field( {}, 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.', diff --git a/server/continuedev/models/generate_json_schema.py b/server/continuedev/models/generate_json_schema.py index abe8b4003..fef9f2a5f 100644 --- a/server/continuedev/models/generate_json_schema.py +++ b/server/continuedev/models/generate_json_schema.py @@ -2,7 +2,7 @@ import os from pydantic import schema_json_of -from ..core.config import ContinueConfig +from ..core.config.serialized_config import SerializedContinueConfig from ..core.context import ContextItem, ContextItemId from ..core.main import ( SessionInfo, @@ -31,7 +31,7 @@ MODELS_TO_GENERATE = ( SlashCommandDescription, ContextProviderDescription, ] - + [ContinueConfig] + + [SerializedContinueConfig] + [ContextItem, ContextItemId] + [Models] + [LLM] diff --git a/server/continuedev/plugins/policies/commit.py b/server/continuedev/plugins/policies/commit.py index 2e649aec7..0ff002c09 100644 --- a/server/continuedev/plugins/policies/commit.py +++ b/server/continuedev/plugins/policies/commit.py @@ -12,7 +12,7 @@ from textwrap import dedent from typing import Literal -from ...core.config import ContinueConfig +from ...core.config.serialized_config import ContinueConfig from ...core.main import Policy, SessionState, Step from ...core.observation import TextObservation from ...core.sdk import ContinueSDK diff --git a/server/continuedev/plugins/policies/default.py b/server/continuedev/plugins/policies/default.py index e1b06d29e..9a881b1cf 100644 --- a/server/continuedev/plugins/policies/default.py +++ b/server/continuedev/plugins/policies/default.py @@ -7,7 +7,7 @@ from ..steps.clear_history import ClearHistoryStep from ..steps.comment_code import CommentCodeStep from ..steps.share_session import ShareSessionStep from ..steps.codebase import AnswerQuestionChroma -from ...core.config import ContinueConfig +from ...core.config.serialized_config import ContinueConfig from ...core.main import Policy, SessionState, Step from ..steps.chat import SimpleChatStep from ..steps.custom_command import CustomCommandStep diff --git a/server/continuedev/plugins/policies/headless.py b/server/continuedev/plugins/policies/headless.py index 19f36a88a..3dcc4a007 100644 --- a/server/continuedev/plugins/policies/headless.py +++ b/server/continuedev/plugins/policies/headless.py @@ -1,4 +1,4 @@ -from ...core.config import ContinueConfig +from ...core.config.serialized_config import ContinueConfig from ...core.main import Policy, SessionState, Step from ...core.observation import TextObservation from ...core.steps import ShellCommandsStep diff --git a/server/continuedev/server/main.py b/server/continuedev/server/main.py index ab003bb26..60de242bb 100644 --- a/server/continuedev/server/main.py +++ b/server/continuedev/server/main.py @@ -7,7 +7,7 @@ from typing import List, Optional from pydantic import BaseModel from ..core.main import ContextProviderDescription, SlashCommandDescription -from ..core.config import ContinueConfig +from ..core.config.serialized_config import ContinueConfig from ..libs.util.devdata import dev_data_logger import uvicorn diff --git a/server/continuedev/server/protocols/gui.py b/server/continuedev/server/protocols/gui.py index 6ca543bcd..e4b50f2e3 100644 --- a/server/continuedev/server/protocols/gui.py +++ b/server/continuedev/server/protocols/gui.py @@ -1,6 +1,6 @@ from typing import Any, Callable, Dict, List, Optional, TypeVar -from ...core.config import ContinueConfig +from ...core.config.serialized_config import ContinueConfig from ...core.autopilot import Autopilot import socketio import uuid @@ -15,7 +15,7 @@ from ...libs.llm.prompts.chat import ( llama2_template_messages, sqlcoder_template_messages, template_alpaca_messages, - phind_template_messages + phind_template_messages, ) from ...libs.llm.prompts.edit import codellama_edit_prompt, alpaca_edit_prompt from ...libs.util.create_async_task import create_async_task diff --git a/server/continuedev/server/window_manager.py b/server/continuedev/server/window_manager.py index 972625e85..be7554990 100644 --- a/server/continuedev/server/window_manager.py +++ b/server/continuedev/server/window_manager.py @@ -16,7 +16,7 @@ from ..plugins.context_providers.file import FileContextProvider from ..core.main import SessionState from ..core.autopilot import Autopilot from ..libs.util.paths import getConfigFilePath, getDiffsFolderPath -from ..core.config import ContinueConfig +from ..core.config.serialized_config import ContinueConfig from .protocols.ide import IdeProtocolServer, WindowInfo from .protocols.gui import GUIProtocolServer from ..libs.util.logging import logger diff --git a/server/tests/step_test.py b/server/tests/step_test.py index a9132dd3b..62a53b5fc 100644 --- a/server/tests/step_test.py +++ b/server/tests/step_test.py @@ -1,5 +1,5 @@ import pytest -from continuedev.core.config import ContinueConfig +from continuedev.core.config.serialized_config import ContinueConfig from continuedev.core.steps import UserInputStep from continuedev.headless import start_headless_session from continuedev.models.filesystem import Range, RangeInFileWithContents diff --git a/server/tests/util/config.py b/server/tests/util/config.py index 370933a00..7a62b5d22 100644 --- a/server/tests/util/config.py +++ b/server/tests/util/config.py @@ -1,4 +1,4 @@ -from continuedev.core.config import ContinueConfig +from continuedev.core.config.serialized_config import ContinueConfig from continuedev.core.models import Models from continuedev.libs.llm.openai_free_trial import OpenAIFreeTrial