From e9afb41bed9a723876cf1cf95d636b2ea498a6b3 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Mon, 11 Sep 2023 18:33:17 -0700 Subject: [PATCH] docs: :memo: working on autogenerated docs --- .vscode/launch.json | 7 ++ continuedev/src/continuedev/core/context.py | 1 + .../src/continuedev/libs/llm/openai.py | 11 +++- .../src/continuedev/models/reference/test.py | 64 +++++++++++++++++++ .../continuedev/plugins/policies/default.py | 4 +- .../{ => customization}/context-providers.md | 0 docs/docs/customization/intro.md | 10 +++ docs/docs/customization/models.md | 0 .../docs/customization/other-configuration.md | 1 + docs/docs/customization/slash-commands.md | 0 .../docs/reference/Context Providers/intro.md | 1 + docs/docs/reference/Models/anthropic.md | 11 ++++ docs/docs/reference/Models/ggml.md | 11 ++++ docs/docs/reference/Models/llamacpp.md | 11 ++++ docs/docs/reference/Models/ollama.md | 11 ++++ docs/docs/reference/Models/openai.md | 13 ++++ docs/docs/reference/Models/queued.md | 11 ++++ docs/docs/reference/Models/replicate.md | 11 ++++ .../reference/Models/text_gen_interface.md | 11 ++++ docs/docs/reference/Models/together.md | 11 ++++ docs/sidebars.js | 33 +++++++++- docs/src/components/ClassPropertyRef.tsx | 26 ++++++++ test.py | 21 ------ 23 files changed, 254 insertions(+), 26 deletions(-) create mode 100644 continuedev/src/continuedev/models/reference/test.py rename docs/docs/{ => customization}/context-providers.md (100%) create mode 100644 docs/docs/customization/intro.md create mode 100644 docs/docs/customization/models.md create mode 100644 docs/docs/customization/other-configuration.md create mode 100644 docs/docs/customization/slash-commands.md create mode 100644 docs/docs/reference/Context Providers/intro.md create mode 100644 docs/docs/reference/Models/anthropic.md create mode 100644 docs/docs/reference/Models/ggml.md create mode 100644 docs/docs/reference/Models/llamacpp.md create mode 100644 docs/docs/reference/Models/ollama.md create mode 100644 docs/docs/reference/Models/openai.md create mode 100644 docs/docs/reference/Models/queued.md create mode 100644 docs/docs/reference/Models/replicate.md create mode 100644 docs/docs/reference/Models/text_gen_interface.md create mode 100644 docs/docs/reference/Models/together.md create mode 100644 docs/src/components/ClassPropertyRef.tsx delete mode 100644 test.py diff --git a/.vscode/launch.json b/.vscode/launch.json index e264c3673..674c23a40 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -25,6 +25,13 @@ "justMyCode": true, "subProcess": true }, + { + "name": "Reference", + "type": "python", + "request": "launch", + "module": "continuedev.src.continuedev.models.reference.test", + "justMyCode": true + }, { "name": "Server", "type": "python", diff --git a/continuedev/src/continuedev/core/context.py b/continuedev/src/continuedev/core/context.py index 25f6be144..c9768a97d 100644 --- a/continuedev/src/continuedev/core/context.py +++ b/continuedev/src/continuedev/core/context.py @@ -192,6 +192,7 @@ class ContextManager: requires_query=provider.requires_query, ) for provider in self.context_providers.values() + if provider.title != "code" ] async def get_selected_items(self) -> List[ContextItem]: diff --git a/continuedev/src/continuedev/libs/llm/openai.py b/continuedev/src/continuedev/libs/llm/openai.py index 857dc52da..705949730 100644 --- a/continuedev/src/continuedev/libs/llm/openai.py +++ b/continuedev/src/continuedev/libs/llm/openai.py @@ -2,6 +2,7 @@ from typing import Callable, List, Literal, Optional import certifi import openai +from pydantic import Field from ...core.main import ChatMessage from ..llm import LLM @@ -26,7 +27,15 @@ MAX_TOKENS_FOR_MODEL = { class OpenAI(LLM): - api_key: str + """ + The OpenAI class can be used to access OpenAI models like gpt-4 and gpt-3.5-turbo. + + If you are running a local model with an OpenAI-compatible API, you can also use the OpenAI class by changing the `api_base` argument. + """ + + api_key: str = Field( + description="OpenAI API key", + ) "OpenAI API key" verify_ssl: Optional[bool] = None diff --git a/continuedev/src/continuedev/models/reference/test.py b/continuedev/src/continuedev/models/reference/test.py new file mode 100644 index 000000000..2d1db3e1f --- /dev/null +++ b/continuedev/src/continuedev/models/reference/test.py @@ -0,0 +1,64 @@ +import importlib +import json +from textwrap import dedent # noqa: F401 + +LLM_MODULES = [ + ("openai", "OpenAI"), + ("anthropic", "AnthropicLLM"), + ("ggml", "GGML"), + ("llamacpp", "LlamaCpp"), + ("text_gen_interface", "TextGenUI"), + ("ollama", "Ollama"), + ("queued", "QueuedLLM"), + ("replicate", "ReplicateLLM"), + ("together", "TogetherLLM"), +] + + +def import_llm_module(module_name, module_title): + module_name = f"continuedev.src.continuedev.libs.llm.{module_name}" + module = importlib.import_module(module_name) + obj = getattr(module, module_title) + return obj + + +def llm_docs_from_schema(schema, filename): + # Generate markdown docs + markdown_docs = dedent( + f"""\ +import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; + +# {schema['title']} + +{dedent(schema.get("description", ""))} + +[View the source](https://github.com/continuedev/continue/tree/main/continuedev/src/continuedev/libs/llm/{filename}.py) + +## Properties + +""" + ) + + for prop, details in schema["properties"].items(): + required = prop in schema.get("required", []) + if not required: + continue + required = "true" if required else "false" + markdown_docs += f"" + + for prop, details in schema["properties"].items(): + required = prop in schema.get("required", []) + if required: + continue + required = "true" if required else "false" + markdown_docs += f"" + + return markdown_docs + + +for module_name, module_title in LLM_MODULES: + obj = import_llm_module(module_name, module_title) + schema = obj.schema() + markdown_docs = llm_docs_from_schema(schema, module_name) + with open(f"docs/docs/reference/Models/{module_name}.md", "w") as f: + f.write(markdown_docs) diff --git a/continuedev/src/continuedev/plugins/policies/default.py b/continuedev/src/continuedev/plugins/policies/default.py index 550defa9f..26b6bd48c 100644 --- a/continuedev/src/continuedev/plugins/policies/default.py +++ b/continuedev/src/continuedev/plugins/policies/default.py @@ -18,7 +18,7 @@ def parse_slash_command(inp: str, config: ContinueConfig) -> Union[None, Step]: Parses a slash command, returning the command name and the rest of the input. """ if inp.startswith("/"): - command_name = inp.split(" ")[0] + command_name = inp.split(" ")[0].strip() after_command = " ".join(inp.split(" ")[1:]) for slash_command in config.slash_commands: @@ -35,7 +35,7 @@ def parse_slash_command(inp: str, config: ContinueConfig) -> Union[None, Step]: def parse_custom_command(inp: str, config: ContinueConfig) -> Union[None, Step]: - command_name = inp.split(" ")[0] + command_name = inp.split(" ")[0].strip() after_command = " ".join(inp.split(" ")[1:]) for custom_cmd in config.custom_commands: if custom_cmd.name == command_name[1:]: diff --git a/docs/docs/context-providers.md b/docs/docs/customization/context-providers.md similarity index 100% rename from docs/docs/context-providers.md rename to docs/docs/customization/context-providers.md diff --git a/docs/docs/customization/intro.md b/docs/docs/customization/intro.md new file mode 100644 index 000000000..a82b5dbf6 --- /dev/null +++ b/docs/docs/customization/intro.md @@ -0,0 +1,10 @@ +# Customizing Continue + +Continue can be deeply customized by editing the `ContinueConfig` object in `~/.continue/config.py` (`%userprofile%\.continue\config.py` for Windows) on your machine. This file is created the first time you run Continue. + +Currently, you can customize the following: + +- [Models](./models.md) - Use Continue with any LLM, including local models, Azure OpenAI service, and any OpenAI-compatible API. +- [Context Providers](./context-providers.md) - Define which sources you want to collect context from to share with the LLM. Just type '@' to easily add attachments to your prompt. +- [Slash Commands](./slash-commands.md) - Call custom prompts or programs written with our SDK by typing `/` in the prompt. +- [Other Configuration](./other-configuration.md) - Configure other settings like the system message, temperature, and more. diff --git a/docs/docs/customization/models.md b/docs/docs/customization/models.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/docs/customization/other-configuration.md b/docs/docs/customization/other-configuration.md new file mode 100644 index 000000000..088b2aac0 --- /dev/null +++ b/docs/docs/customization/other-configuration.md @@ -0,0 +1 @@ +# Other Configuration diff --git a/docs/docs/customization/slash-commands.md b/docs/docs/customization/slash-commands.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/docs/reference/Context Providers/intro.md b/docs/docs/reference/Context Providers/intro.md new file mode 100644 index 000000000..1e0981f10 --- /dev/null +++ b/docs/docs/reference/Context Providers/intro.md @@ -0,0 +1 @@ +# Intro diff --git a/docs/docs/reference/Models/anthropic.md b/docs/docs/reference/Models/anthropic.md new file mode 100644 index 000000000..1aa313242 --- /dev/null +++ b/docs/docs/reference/Models/anthropic.md @@ -0,0 +1,11 @@ +import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; + +# AnthropicLLM + + + +[View the source](https://github.com/continuedev/continue/tree/main/continuedev/src/continuedev/libs/llm/anthropic.py) + +## Properties + + \ No newline at end of file diff --git a/docs/docs/reference/Models/ggml.md b/docs/docs/reference/Models/ggml.md new file mode 100644 index 000000000..dafc8870d --- /dev/null +++ b/docs/docs/reference/Models/ggml.md @@ -0,0 +1,11 @@ +import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; + +# GGML + + + +[View the source](https://github.com/continuedev/continue/tree/main/continuedev/src/continuedev/libs/llm/ggml.py) + +## Properties + + \ No newline at end of file diff --git a/docs/docs/reference/Models/llamacpp.md b/docs/docs/reference/Models/llamacpp.md new file mode 100644 index 000000000..7ce755743 --- /dev/null +++ b/docs/docs/reference/Models/llamacpp.md @@ -0,0 +1,11 @@ +import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; + +# LlamaCpp + + + +[View the source](https://github.com/continuedev/continue/tree/main/continuedev/src/continuedev/libs/llm/llamacpp.py) + +## Properties + + \ No newline at end of file diff --git a/docs/docs/reference/Models/ollama.md b/docs/docs/reference/Models/ollama.md new file mode 100644 index 000000000..ef0581197 --- /dev/null +++ b/docs/docs/reference/Models/ollama.md @@ -0,0 +1,11 @@ +import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; + +# Ollama + + + +[View the source](https://github.com/continuedev/continue/tree/main/continuedev/src/continuedev/libs/llm/ollama.py) + +## Properties + + \ No newline at end of file diff --git a/docs/docs/reference/Models/openai.md b/docs/docs/reference/Models/openai.md new file mode 100644 index 000000000..d325ca2f4 --- /dev/null +++ b/docs/docs/reference/Models/openai.md @@ -0,0 +1,13 @@ +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. + +If you are running a local model with an OpenAI-compatible API, you can also use the OpenAI class by changing the `api_base` argument. + +[View the source](https://github.com/continuedev/continue/tree/main/continuedev/src/continuedev/libs/llm/openai.py) + +## Properties + + \ No newline at end of file diff --git a/docs/docs/reference/Models/queued.md b/docs/docs/reference/Models/queued.md new file mode 100644 index 000000000..6888a4e50 --- /dev/null +++ b/docs/docs/reference/Models/queued.md @@ -0,0 +1,11 @@ +import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; + +# QueuedLLM + + + +[View the source](https://github.com/continuedev/continue/tree/main/continuedev/src/continuedev/libs/llm/queued.py) + +## Properties + + \ No newline at end of file diff --git a/docs/docs/reference/Models/replicate.md b/docs/docs/reference/Models/replicate.md new file mode 100644 index 000000000..4f05cdfa1 --- /dev/null +++ b/docs/docs/reference/Models/replicate.md @@ -0,0 +1,11 @@ +import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; + +# ReplicateLLM + + + +[View the source](https://github.com/continuedev/continue/tree/main/continuedev/src/continuedev/libs/llm/replicate.py) + +## Properties + + \ No newline at end of file diff --git a/docs/docs/reference/Models/text_gen_interface.md b/docs/docs/reference/Models/text_gen_interface.md new file mode 100644 index 000000000..a59a41668 --- /dev/null +++ b/docs/docs/reference/Models/text_gen_interface.md @@ -0,0 +1,11 @@ +import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; + +# TextGenUI + + + +[View the source](https://github.com/continuedev/continue/tree/main/continuedev/src/continuedev/libs/llm/text_gen_interface.py) + +## Properties + + \ No newline at end of file diff --git a/docs/docs/reference/Models/together.md b/docs/docs/reference/Models/together.md new file mode 100644 index 000000000..e436644c6 --- /dev/null +++ b/docs/docs/reference/Models/together.md @@ -0,0 +1,11 @@ +import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; + +# TogetherLLM + + + +[View the source](https://github.com/continuedev/continue/tree/main/continuedev/src/continuedev/libs/llm/together.py) + +## Properties + + \ No newline at end of file diff --git a/docs/sidebars.js b/docs/sidebars.js index 6d205bab3..2121fea6a 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -18,11 +18,40 @@ const sidebars = { "getting-started", "how-to-use-continue", "how-continue-works", - "customization", - "context-providers", + { + type: "category", + label: "Customization", + collapsible: true, + collapsed: false, + items: [ + "customization/models", + "customization/context-providers", + "customization/slash-commands", + "customization/other-configuration", + ], + }, "collecting-data", "telemetry", "troubleshooting", + { + type: "category", + label: "Walkthroughs", + collapsible: true, + collapsed: false, + items: ["walkthroughs/codellama"], + }, + { + type: "category", + label: "Reference", + collapsible: true, + collapsed: false, + items: [ + { + type: "autogenerated", + dirName: "reference", + }, + ], + }, ], }; diff --git a/docs/src/components/ClassPropertyRef.tsx b/docs/src/components/ClassPropertyRef.tsx new file mode 100644 index 000000000..46664c4c9 --- /dev/null +++ b/docs/src/components/ClassPropertyRef.tsx @@ -0,0 +1,26 @@ +import React from "react"; + +interface ClassPropertyRefProps { + name: string; + details: string; + required: boolean; +} + +export default function ClassPropertyRef(props: ClassPropertyRefProps) { + const details = JSON.parse(props.details); + + return ( + <> +
+

+ {props.name} +

+ + {props.required && "REQUIRED"} + + {details.type && `(${details.type})`} +
+

{details.description}

+ + ); +} diff --git a/test.py b/test.py deleted file mode 100644 index 5bd57e0e8..000000000 --- a/test.py +++ /dev/null @@ -1,21 +0,0 @@ -import unittest - - -def sort_numbers(numbers): - for i in range(len(numbers)): - for j in range(i + 1, len(numbers)): - if numbers[i] > numbers[j]: - numbers[i], numbers[j] = numbers[j], numbers[i] - return numbers[:-1] # Error here: We're not returning the last number - - -class TestSortNumbers(unittest.TestCase): - def test_sort_numbers(self): - self.assertEqual(sort_numbers([3, 2, 1]), [1, 2, 3]) # This test will fail - self.assertEqual( - sort_numbers([4, 2, 5, 1, 3]), [1, 2, 3, 4, 5] - ) # This test will fail - - -if __name__ == "__main__": - unittest.main()