docs: 📝 working on autogenerated docs

This commit is contained in:
Nate Sesti 2023-09-11 18:33:17 -07:00
parent 0c9482681f
commit e9afb41bed
23 changed files with 254 additions and 26 deletions

7
.vscode/launch.json vendored
View file

@ -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",

View file

@ -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]:

View file

@ -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

View file

@ -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"<ClassPropertyRef name='{prop}' details='{json.dumps(details)}' required={{{required}}}/>"
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"<ClassPropertyRef name='{prop}' details='{json.dumps(details)}' required={{{required}}}/>"
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)

View file

@ -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:]:

View file

@ -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.

View file

View file

@ -0,0 +1 @@
# Other Configuration

View file

@ -0,0 +1 @@
# Intro

View file

@ -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
<ClassPropertyRef name='api_key' details='{"title": "Api Key", "type": "string"}' required={true}/><ClassPropertyRef name='title' details='{"title": "Title", "type": "string"}' required={false}/><ClassPropertyRef name='system_message' details='{"title": "System Message", "type": "string"}' required={false}/><ClassPropertyRef name='context_length' details='{"title": "Context Length", "default": 2048, "type": "integer"}' required={false}/><ClassPropertyRef name='unique_id' details='{"title": "Unique Id", "type": "string"}' required={false}/><ClassPropertyRef name='model' details='{"title": "Model", "default": "claude-2", "type": "string"}' required={false}/><ClassPropertyRef name='timeout' details='{"title": "Timeout", "default": 300, "type": "integer"}' required={false}/><ClassPropertyRef name='prompt_templates' details='{"title": "Prompt Templates", "default": {}, "type": "object"}' required={false}/>

View file

@ -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
<ClassPropertyRef name='title' details='{"title": "Title", "type": "string"}' required={false}/><ClassPropertyRef name='system_message' details='{"title": "System Message", "type": "string"}' required={false}/><ClassPropertyRef name='context_length' details='{"title": "Context Length", "default": 2048, "type": "integer"}' required={false}/><ClassPropertyRef name='unique_id' details='{"title": "Unique Id", "type": "string"}' required={false}/><ClassPropertyRef name='model' details='{"title": "Model", "default": "ggml", "type": "string"}' required={false}/><ClassPropertyRef name='timeout' details='{"title": "Timeout", "default": 300, "type": "integer"}' required={false}/><ClassPropertyRef name='prompt_templates' details='{"title": "Prompt Templates", "default": {"edit": "[INST] Consider the following code:\n```\n{{code_to_edit}}\n```\nEdit the code to perfectly satisfy the following user request:\n{{user_input}}\nOutput nothing except for the code. No code block, no English explanation, no start/end tags.\n[/INST]"}, "type": "object"}' required={false}/><ClassPropertyRef name='api_key' details='{"title": "Api Key", "type": "string"}' required={false}/><ClassPropertyRef name='server_url' details='{"title": "Server Url", "default": "http://localhost:8000", "type": "string"}' required={false}/><ClassPropertyRef name='verify_ssl' details='{"title": "Verify Ssl", "type": "boolean"}' required={false}/><ClassPropertyRef name='ca_bundle_path' details='{"title": "Ca Bundle Path", "type": "string"}' required={false}/>

View file

@ -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
<ClassPropertyRef name='title' details='{"title": "Title", "type": "string"}' required={false}/><ClassPropertyRef name='system_message' details='{"title": "System Message", "type": "string"}' required={false}/><ClassPropertyRef name='context_length' details='{"title": "Context Length", "default": 2048, "type": "integer"}' required={false}/><ClassPropertyRef name='unique_id' details='{"title": "Unique Id", "type": "string"}' required={false}/><ClassPropertyRef name='model' details='{"title": "Model", "default": "llamacpp", "type": "string"}' required={false}/><ClassPropertyRef name='timeout' details='{"title": "Timeout", "default": 300, "type": "integer"}' required={false}/><ClassPropertyRef name='prompt_templates' details='{"title": "Prompt Templates", "default": {"edit": "[INST] Consider the following code:\n```\n{{code_to_edit}}\n```\nEdit the code to perfectly satisfy the following user request:\n{{user_input}}\nOutput nothing except for the code. No code block, no English explanation, no start/end tags.\n[/INST]"}, "type": "object"}' required={false}/><ClassPropertyRef name='api_key' details='{"title": "Api Key", "type": "string"}' required={false}/><ClassPropertyRef name='server_url' details='{"title": "Server Url", "default": "http://localhost:8080", "type": "string"}' required={false}/><ClassPropertyRef name='verify_ssl' details='{"title": "Verify Ssl", "type": "boolean"}' required={false}/><ClassPropertyRef name='llama_cpp_args' details='{"title": "Llama Cpp Args", "default": {"stop": ["[INST]"]}, "type": "object"}' required={false}/><ClassPropertyRef name='use_command' details='{"title": "Use Command", "type": "string"}' required={false}/>

View file

@ -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
<ClassPropertyRef name='title' details='{"title": "Title", "type": "string"}' required={false}/><ClassPropertyRef name='system_message' details='{"title": "System Message", "type": "string"}' required={false}/><ClassPropertyRef name='context_length' details='{"title": "Context Length", "default": 2048, "type": "integer"}' required={false}/><ClassPropertyRef name='unique_id' details='{"title": "Unique Id", "type": "string"}' required={false}/><ClassPropertyRef name='model' details='{"title": "Model", "default": "llama2", "type": "string"}' required={false}/><ClassPropertyRef name='timeout' details='{"title": "Timeout", "default": 300, "type": "integer"}' required={false}/><ClassPropertyRef name='prompt_templates' details='{"title": "Prompt Templates", "default": {"edit": "[INST] Consider the following code:\n```\n{{code_to_edit}}\n```\nEdit the code to perfectly satisfy the following user request:\n{{user_input}}\nOutput nothing except for the code. No code block, no English explanation, no start/end tags.\n[/INST]"}, "type": "object"}' required={false}/><ClassPropertyRef name='api_key' details='{"title": "Api Key", "type": "string"}' required={false}/><ClassPropertyRef name='server_url' details='{"title": "Server Url", "default": "http://localhost:11434", "type": "string"}' required={false}/>

View file

@ -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
<ClassPropertyRef name='model' details='{"title": "Model", "type": "string"}' required={true}/><ClassPropertyRef name='api_key' details='{"title": "Api Key", "description": "OpenAI API key", "type": "string"}' required={true}/><ClassPropertyRef name='title' details='{"title": "Title", "type": "string"}' required={false}/><ClassPropertyRef name='system_message' details='{"title": "System Message", "type": "string"}' required={false}/><ClassPropertyRef name='context_length' details='{"title": "Context Length", "default": 2048, "type": "integer"}' required={false}/><ClassPropertyRef name='unique_id' details='{"title": "Unique Id", "type": "string"}' required={false}/><ClassPropertyRef name='timeout' details='{"title": "Timeout", "default": 300, "type": "integer"}' required={false}/><ClassPropertyRef name='prompt_templates' details='{"title": "Prompt Templates", "default": {}, "type": "object"}' required={false}/><ClassPropertyRef name='verify_ssl' details='{"title": "Verify Ssl", "type": "boolean"}' required={false}/><ClassPropertyRef name='ca_bundle_path' details='{"title": "Ca Bundle Path", "type": "string"}' required={false}/><ClassPropertyRef name='proxy' details='{"title": "Proxy", "type": "string"}' required={false}/><ClassPropertyRef name='api_base' details='{"title": "Api Base", "type": "string"}' required={false}/><ClassPropertyRef name='api_type' details='{"title": "Api Type", "enum": ["azure", "openai"], "type": "string"}' required={false}/><ClassPropertyRef name='api_version' details='{"title": "Api Version", "type": "string"}' required={false}/><ClassPropertyRef name='engine' details='{"title": "Engine", "type": "string"}' required={false}/>

View file

@ -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
<ClassPropertyRef name='llm' details='{"$ref": "#/definitions/LLM"}' required={true}/><ClassPropertyRef name='title' details='{"title": "Title", "type": "string"}' required={false}/><ClassPropertyRef name='system_message' details='{"title": "System Message", "type": "string"}' required={false}/><ClassPropertyRef name='context_length' details='{"title": "Context Length", "default": 2048, "type": "integer"}' required={false}/><ClassPropertyRef name='unique_id' details='{"title": "Unique Id", "type": "string"}' required={false}/><ClassPropertyRef name='model' details='{"title": "Model", "default": "queued", "type": "string"}' required={false}/><ClassPropertyRef name='timeout' details='{"title": "Timeout", "default": 300, "type": "integer"}' required={false}/><ClassPropertyRef name='prompt_templates' details='{"title": "Prompt Templates", "default": {}, "type": "object"}' required={false}/><ClassPropertyRef name='api_key' details='{"title": "Api Key", "type": "string"}' required={false}/>

View file

@ -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
<ClassPropertyRef name='api_key' details='{"title": "Api Key", "type": "string"}' required={true}/><ClassPropertyRef name='title' details='{"title": "Title", "type": "string"}' required={false}/><ClassPropertyRef name='system_message' details='{"title": "System Message", "type": "string"}' required={false}/><ClassPropertyRef name='context_length' details='{"title": "Context Length", "default": 2048, "type": "integer"}' required={false}/><ClassPropertyRef name='unique_id' details='{"title": "Unique Id", "type": "string"}' required={false}/><ClassPropertyRef name='model' details='{"title": "Model", "default": "replicate/llama-2-70b-chat:58d078176e02c219e11eb4da5a02a7830a283b14cf8f94537af893ccff5ee781", "type": "string"}' required={false}/><ClassPropertyRef name='timeout' details='{"title": "Timeout", "default": 300, "type": "integer"}' required={false}/><ClassPropertyRef name='prompt_templates' details='{"title": "Prompt Templates", "default": {"edit": "[INST] Consider the following code:\n```\n{{code_to_edit}}\n```\nEdit the code to perfectly satisfy the following user request:\n{{user_input}}\nOutput nothing except for the code. No code block, no English explanation, no start/end tags.\n[/INST]"}, "type": "object"}' required={false}/>

View file

@ -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
<ClassPropertyRef name='title' details='{"title": "Title", "type": "string"}' required={false}/><ClassPropertyRef name='system_message' details='{"title": "System Message", "type": "string"}' required={false}/><ClassPropertyRef name='context_length' details='{"title": "Context Length", "default": 2048, "type": "integer"}' required={false}/><ClassPropertyRef name='unique_id' details='{"title": "Unique Id", "type": "string"}' required={false}/><ClassPropertyRef name='model' details='{"title": "Model", "default": "text-gen-ui", "type": "string"}' required={false}/><ClassPropertyRef name='timeout' details='{"title": "Timeout", "default": 300, "type": "integer"}' required={false}/><ClassPropertyRef name='prompt_templates' details='{"title": "Prompt Templates", "default": {"edit": "[INST] Consider the following code:\n```\n{{code_to_edit}}\n```\nEdit the code to perfectly satisfy the following user request:\n{{user_input}}\nOutput nothing except for the code. No code block, no English explanation, no start/end tags.\n[/INST]"}, "type": "object"}' required={false}/><ClassPropertyRef name='api_key' details='{"title": "Api Key", "type": "string"}' required={false}/><ClassPropertyRef name='server_url' details='{"title": "Server Url", "default": "http://localhost:5000", "type": "string"}' required={false}/><ClassPropertyRef name='streaming_url' details='{"title": "Streaming Url", "default": "http://localhost:5005", "type": "string"}' required={false}/><ClassPropertyRef name='verify_ssl' details='{"title": "Verify Ssl", "type": "boolean"}' required={false}/>

View file

@ -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
<ClassPropertyRef name='api_key' details='{"title": "Api Key", "type": "string"}' required={true}/><ClassPropertyRef name='title' details='{"title": "Title", "type": "string"}' required={false}/><ClassPropertyRef name='system_message' details='{"title": "System Message", "type": "string"}' required={false}/><ClassPropertyRef name='context_length' details='{"title": "Context Length", "default": 2048, "type": "integer"}' required={false}/><ClassPropertyRef name='unique_id' details='{"title": "Unique Id", "type": "string"}' required={false}/><ClassPropertyRef name='model' details='{"title": "Model", "default": "togethercomputer/RedPajama-INCITE-7B-Instruct", "type": "string"}' required={false}/><ClassPropertyRef name='timeout' details='{"title": "Timeout", "default": 300, "type": "integer"}' required={false}/><ClassPropertyRef name='prompt_templates' details='{"title": "Prompt Templates", "default": {"edit": "[INST] Consider the following code:\n```\n{{code_to_edit}}\n```\nEdit the code to perfectly satisfy the following user request:\n{{user_input}}\nOutput nothing except for the code. No code block, no English explanation, no start/end tags.\n[/INST]"}, "type": "object"}' required={false}/><ClassPropertyRef name='base_url' details='{"title": "Base Url", "default": "https://api.together.xyz", "type": "string"}' required={false}/><ClassPropertyRef name='verify_ssl' details='{"title": "Verify Ssl", "type": "boolean"}' required={false}/>

View file

@ -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",
},
],
},
],
};

View file

@ -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 (
<>
<div>
<h4 style={{ display: "inline-block", marginRight: "10px" }}>
{props.name}
</h4>
<span style={{ color: "red", fontSize: "11px", marginRight: "4px" }}>
{props.required && "REQUIRED"}
</span>
<span>{details.type && `(${details.type})`}</span>
</div>
<p>{details.description}</p>
</>
);
}

21
test.py
View file

@ -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()