Merge branch 'main' of https://github.com/continuedev/continue
This commit is contained in:
commit
fce7833491
13 changed files with 95 additions and 153 deletions
|
|
@ -25,8 +25,8 @@ class ContinueConfig(BaseModel):
|
|||
disallowed_steps: Optional[List[str]] = []
|
||||
server_url: Optional[str] = None
|
||||
allow_anonymous_telemetry: Optional[bool] = True
|
||||
default_model: Literal["gpt-3.5-turbo",
|
||||
"gpt-4", "starcoder"] = 'gpt-4'
|
||||
default_model: Literal["gpt-3.5-turbo", "gpt-3.5-turbo-16k",
|
||||
"gpt-4"] = 'gpt-4'
|
||||
slash_commands: Optional[List[SlashCommand]] = [
|
||||
# SlashCommand(
|
||||
# name="pytest",
|
||||
|
|
|
|||
|
|
@ -44,6 +44,16 @@ class Models:
|
|||
return OpenAI(api_key=api_key, default_model="gpt-3.5-turbo")
|
||||
return asyncio.get_event_loop().run_until_complete(load_gpt35())
|
||||
|
||||
@cached_property
|
||||
def gpt3516k(self):
|
||||
async def load_gpt3516k():
|
||||
api_key = await self.sdk.get_user_secret(
|
||||
'OPENAI_API_KEY', 'Enter your OpenAI API key, OR press enter to try for free')
|
||||
if api_key == "":
|
||||
return ProxyServer(self.sdk.ide.unique_id, "gpt-3.5-turbo-16k")
|
||||
return OpenAI(api_key=api_key, default_model="gpt-3.5-turbo-16k")
|
||||
return asyncio.get_event_loop().run_until_complete(load_gpt3516k())
|
||||
|
||||
@cached_property
|
||||
def gpt4(self):
|
||||
async def load_gpt4():
|
||||
|
|
@ -59,6 +69,8 @@ class Models:
|
|||
return self.starcoder
|
||||
elif model_name == "gpt-3.5-turbo":
|
||||
return self.gpt35
|
||||
elif model_name == "gpt-3.5-turbo-16k":
|
||||
return self.gpt3516k
|
||||
elif model_name == "gpt-4":
|
||||
return self.gpt4
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -9,13 +9,14 @@ from ..llm import LLM
|
|||
from pydantic import BaseModel, validator
|
||||
import tiktoken
|
||||
|
||||
MAX_TOKENS_FOR_MODEL = {
|
||||
"gpt-3.5-turbo": 4097,
|
||||
"gpt-4": 4097,
|
||||
}
|
||||
DEFAULT_MAX_TOKENS = 2048
|
||||
MAX_TOKENS_FOR_MODEL = {
|
||||
"gpt-3.5-turbo": 4096 - DEFAULT_MAX_TOKENS,
|
||||
"gpt-3.5-turbo-16k": 16384 - DEFAULT_MAX_TOKENS,
|
||||
"gpt-4": 8192 - DEFAULT_MAX_TOKENS
|
||||
}
|
||||
CHAT_MODELS = {
|
||||
"gpt-3.5-turbo", "gpt-4"
|
||||
"gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-4"
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -24,13 +25,17 @@ class OpenAI(LLM):
|
|||
completion_count: int = 0
|
||||
default_model: str
|
||||
|
||||
def __init__(self, api_key: str, default_model: str = "gpt-3.5-turbo", system_message: str = None):
|
||||
def __init__(self, api_key: str, default_model: str, system_message: str = None):
|
||||
self.api_key = api_key
|
||||
self.default_model = default_model
|
||||
self.system_message = system_message
|
||||
|
||||
openai.api_key = api_key
|
||||
|
||||
@cached_property
|
||||
def name(self):
|
||||
return self.default_model
|
||||
|
||||
@cached_property
|
||||
def __encoding_for_model(self):
|
||||
aliases = {
|
||||
|
|
@ -76,7 +81,7 @@ class OpenAI(LLM):
|
|||
return chat_history
|
||||
|
||||
def with_system_message(self, system_message: Union[str, None]):
|
||||
return OpenAI(api_key=self.api_key, system_message=system_message)
|
||||
return OpenAI(api_key=self.api_key, default_model=self.default_model, system_message=system_message)
|
||||
|
||||
def stream_chat(self, prompt, with_history: List[ChatMessage] = [], **kwargs) -> Generator[Union[Any, List, Dict], None, None]:
|
||||
self.completion_count += 1
|
||||
|
|
|
|||
|
|
@ -1,112 +0,0 @@
|
|||
from typing import Any, Callable, List, Tuple, Union
|
||||
from ..llm import LLM
|
||||
from .openai import OpenAI
|
||||
|
||||
|
||||
def cls_method_to_str(cls_name: str, init: str, method: str) -> str:
|
||||
"""Convert class and method info to formatted code"""
|
||||
return f"""class {cls_name}:
|
||||
{init}
|
||||
{method}"""
|
||||
|
||||
|
||||
# Prompter classes
|
||||
class Prompter:
|
||||
def __init__(self, llm: LLM = None):
|
||||
if llm is None:
|
||||
self.llm = OpenAI()
|
||||
else:
|
||||
self.llm = llm
|
||||
|
||||
def _compile_prompt(self, inp: Any) -> Tuple[str, str, Union[str, None]]:
|
||||
"Takes input and returns prompt, prefix, suffix"
|
||||
raise NotImplementedError
|
||||
|
||||
def complete(self, inp: Any, **kwargs) -> str:
|
||||
prompt, prefix, suffix = self._compile_prompt(inp)
|
||||
resp = self.llm.complete(prompt + prefix, suffix=suffix, **kwargs)
|
||||
return prefix + resp + (suffix or "")
|
||||
|
||||
def __call__(self, inp: Any, **kwargs) -> str:
|
||||
return self.complete(inp, **kwargs)
|
||||
|
||||
def parallel_complete(self, inps: List[Any]) -> List[str]:
|
||||
prompts = []
|
||||
prefixes = []
|
||||
suffixes = []
|
||||
for inp in inps:
|
||||
prompt, prefix, suffix = self._compile_prompt(inp)
|
||||
prompts.append(prompt)
|
||||
prefixes.append(prefix)
|
||||
suffixes.append(suffix)
|
||||
|
||||
resps = self.llm.parallel_complete(
|
||||
[prompt + prefix for prompt, prefix in zip(prompts, prefixes)], suffixes=suffixes)
|
||||
return [prefix + resp + (suffix or "") for prefix, resp, suffix in zip(prefixes, resps, suffixes)]
|
||||
|
||||
|
||||
class MixedPrompter(Prompter):
|
||||
def __init__(self, prompters: List[Prompter], router: Callable[[Any], int], llm: LLM = None):
|
||||
super().__init__(llm=llm)
|
||||
self.prompters = prompters
|
||||
self.router = router
|
||||
|
||||
def _compile_prompt(self, inp: Any) -> Tuple[str, str, Union[str, None]]:
|
||||
prompter = self.prompters[self.router(inp)]
|
||||
return prompter._compile_prompt(inp)
|
||||
|
||||
def complete(self, inp: Any, **kwargs) -> str:
|
||||
prompter = self.prompters[self.router(inp)]
|
||||
return prompter.complete(inp, **kwargs)
|
||||
|
||||
|
||||
class SimplePrompter(Prompter):
|
||||
def __init__(self, prompt_fn: Callable[[Any], str], llm: LLM = None):
|
||||
super().__init__(llm=llm)
|
||||
self.prompt_fn = prompt_fn
|
||||
|
||||
def _compile_prompt(self, inp: Any) -> Tuple[str, str, Union[str, None]]:
|
||||
return self.prompt_fn(inp), "", None
|
||||
|
||||
|
||||
class FormatStringPrompter(SimplePrompter):
|
||||
"""Pass a formatted string, and the input should be a dict with the keys to format"""
|
||||
|
||||
def __init__(self, prompt: str, llm: LLM = None):
|
||||
super().__init__(lambda inp: prompt.format(**inp), llm=llm)
|
||||
|
||||
|
||||
class BasicCommentPrompter(SimplePrompter):
|
||||
def __init__(self, comment: str, llm: LLM = None):
|
||||
super().__init__(lambda inp: f"""{inp}
|
||||
|
||||
# {comment}""", llm=llm)
|
||||
|
||||
|
||||
class EditPrompter(Prompter):
|
||||
def __init__(self, prompt_fn: Callable[[Any], Tuple[str, str]], llm: LLM = None):
|
||||
super().__init__(llm=llm)
|
||||
self.prompt_fn = prompt_fn
|
||||
|
||||
def complete(self, inp: str, **kwargs) -> str:
|
||||
inp, instruction = self.prompt_fn(inp)
|
||||
return self.llm.edit(inp, instruction, **kwargs)
|
||||
|
||||
def parallel_complete(self, inps: List[Any]) -> List[str]:
|
||||
prompts = []
|
||||
instructions = []
|
||||
for inp in inps:
|
||||
prompt, instruction = self.prompt_fn(inp)
|
||||
prompts.append(prompt)
|
||||
instructions.append(instruction)
|
||||
|
||||
return self.llm.parallel_edit(prompts, instructions)
|
||||
|
||||
|
||||
class InsertPrompter(Prompter):
|
||||
def __init__(self, prompt_fn: Callable[[Any], Tuple[str, str, str]], llm: LLM = None):
|
||||
super().__init__(llm=llm)
|
||||
self.prompt_fn = prompt_fn
|
||||
|
||||
def _compile_prompt(self, inp: Any) -> Tuple[str, str, Union[str, None]]:
|
||||
return self.prompt_fn(inp)
|
||||
|
|
@ -10,6 +10,7 @@ from ...models.filesystem_edit import EditDiff, FileEdit, FileEditWithFullConten
|
|||
from ...models.filesystem import FileSystem, RangeInFile, RangeInFileWithContents
|
||||
from ...core.observation import Observation, TextObservation, TracebackObservation, UserInputObservation
|
||||
from ...core.main import Step, SequentialStep
|
||||
from ...libs.llm.openai import MAX_TOKENS_FOR_MODEL
|
||||
import difflib
|
||||
|
||||
|
||||
|
|
@ -172,16 +173,62 @@ class DefaultModelEditCodeStep(Step):
|
|||
for rif in rif_with_contents:
|
||||
await sdk.ide.setFileOpen(rif.filepath)
|
||||
|
||||
model_to_use = sdk.models.default
|
||||
|
||||
full_file_contents = await sdk.ide.readFile(rif.filepath)
|
||||
start_index, end_index = rif.range.indices_in_string(
|
||||
full_file_contents)
|
||||
segs = [full_file_contents[:start_index],
|
||||
full_file_contents[end_index:]]
|
||||
|
||||
full_file_contents_lst = full_file_contents.split("\n")
|
||||
|
||||
max_start_line = rif.range.start.line
|
||||
min_end_line = rif.range.end.line
|
||||
cur_start_line = 0
|
||||
cur_end_line = len(full_file_contents_lst) - 1
|
||||
|
||||
def cut_context(model_to_use, total_tokens, cur_start_line, cur_end_line):
|
||||
|
||||
if total_tokens > MAX_TOKENS_FOR_MODEL[model_to_use.name]:
|
||||
while cur_end_line > min_end_line:
|
||||
total_tokens -= model_to_use.count_tokens(full_file_contents_lst[cur_end_line])
|
||||
cur_end_line -= 1
|
||||
if total_tokens < MAX_TOKENS_FOR_MODEL[model_to_use.name]:
|
||||
return cur_start_line, cur_end_line
|
||||
|
||||
if total_tokens > MAX_TOKENS_FOR_MODEL[model_to_use.name]:
|
||||
while cur_start_line < max_start_line:
|
||||
cur_start_line += 1
|
||||
total_tokens -= model_to_use.count_tokens(full_file_contents_lst[cur_end_line])
|
||||
if total_tokens < MAX_TOKENS_FOR_MODEL[model_to_use.name]:
|
||||
return cur_start_line, cur_end_line
|
||||
|
||||
return cur_start_line, cur_end_line
|
||||
|
||||
if model_to_use.name == "gpt-4":
|
||||
|
||||
total_tokens = model_to_use.count_tokens(full_file_contents)
|
||||
cur_start_line, cur_end_line = cut_context(model_to_use, total_tokens, cur_start_line, cur_end_line)
|
||||
|
||||
elif model_to_use.name == "gpt-3.5-turbo" or model_to_use.name == "gpt-3.5-turbo-16k":
|
||||
|
||||
if sdk.models.gpt35.count_tokens(full_file_contents) > MAX_TOKENS_FOR_MODEL["gpt-3.5-turbo"]:
|
||||
|
||||
model_to_use = sdk.models.gpt3516k
|
||||
total_tokens = model_to_use.count_tokens(full_file_contents)
|
||||
cur_start_line, cur_end_line = cut_context(model_to_use, total_tokens, cur_start_line, cur_end_line)
|
||||
|
||||
else:
|
||||
|
||||
raise Exception("Unknown default model")
|
||||
|
||||
code_before = "".join(full_file_contents_lst[cur_start_line:max_start_line])
|
||||
code_after = "".join(full_file_contents_lst[min_end_line:cur_end_line])
|
||||
|
||||
segs = [code_before, code_after]
|
||||
|
||||
prompt = self._prompt.format(
|
||||
code=rif.contents, user_request=self.user_input, file_prefix=segs[0], file_suffix=segs[1])
|
||||
|
||||
completion = str(await sdk.models.default.complete(prompt, with_history=await sdk.get_chat_context()))
|
||||
completion = str(await model_to_use.complete(prompt, with_history=await sdk.get_chat_context()))
|
||||
|
||||
eot_token = "<|endoftext|>"
|
||||
completion = completion.removesuffix(eot_token)
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,9 @@ We don't want to waste your time with install and env setup before you try Conti
|
|||
|
||||
2. Select the `Create new codespace` button and wait 30-90 seconds while it launches and installs the Continue extension. Once complete, it should look like this:
|
||||
|
||||
**TODO: Nate to add a screenshot of what Codespaces + Continue looks like when it is ready**
|
||||

|
||||
|
||||
## Next Steps
|
||||
|
||||
Read the `Getting Started` section of the `README.md` file that has been opened in your codespace, which you can also find [here](https://github.com/continuedev/continue-codespaces-demo/blob/main/README.md)
|
||||
|
||||
If you're ready to download for VS Code, you can do so [here](https://marketplace.visualstudio.com/items?itemName=Continue.continue).
|
||||
- Read the `Getting Started` section of the `README.md` file that has been opened in your codespace, which you can also find [here](https://github.com/continuedev/continue-codespaces-demo/blob/main/README.md)
|
||||
- If you're ready to download for VS Code, you can do so [here](https://marketplace.visualstudio.com/items?itemName=Continue.continue)
|
||||
|
|
@ -12,7 +12,7 @@ If you want to try Continue before installing locally, check out the [GitHub Cod
|
|||
|
||||
3. Once you do this, you will see a message in the bottom right hand corner of VS Code that says `Setting up Continue extension...`. After 30-90 seconds, the Continue extension will then open up. It should look like this when it is complete:
|
||||
|
||||
**TODO: Nate to add a screenshot of what Codespaces + Continue looks like when it is ready**
|
||||

|
||||
|
||||
You can also open the Continue GUI with `cmd+shift+p` on Mac / `ctrl+shift+p` on Windows and then selecting `Continue: Open GUI`
|
||||
|
||||
|
|
@ -22,7 +22,4 @@ If you would like to install Continue from source, please [follow the instructio
|
|||
|
||||
## Next steps
|
||||
|
||||
**TODO: Nate to update VS Code install to have the same getting started as Codespaces**
|
||||
|
||||
Read the `Getting Started` section of the `README.md` file that has been opened in VS Code,
|
||||
which you can also find [here](https://github.com/continuedev/continue-codespaces-demo/blob/main/README.md)
|
||||
- Read the `Getting Started` section of the `README.md` [here](https://github.com/continuedev/continue-codespaces-demo/blob/main/README.md)
|
||||
|
|
@ -11,10 +11,10 @@
|
|||
|
||||
**Continue is the open-source library for accelerating software development with language models**
|
||||
|
||||
You define the scenarios where Large Language Models LLMs like GPT-4 and StarCoder should act as an autopilot, helping you complete software development tasks. You use recipes created by others to automate more steps in your workflows. If a recipe does not exist or work exactly like you want, you can use the Continue SDK to create custom steps and compose them into personalized recipes. Whether you are using a recipe created by yourself or someone else, you can review, reverse, and rerun steps with the Continue GUI, which helps you guide the work done by LLMs and learn when to use and trust them.
|
||||
You determine when Large Language Models (LLMs) like GPT-4 should act as an autopilot, helping you complete software development tasks. You open a file or highlight some code and then use slash commands like `/edit`, `/explain`, and `/comment` and naturual language instructions to tell the language model what to do. If an error or exception occurs when you run Python or JavaScript code, Continue will automatically tell you in plain English what to try to address it. You can also review, reverse, and rerun steps with the Continue GUI, which helps you guide the work done by LLMs and learn when to use and trust them.
|
||||
|
||||
## Why do developers use Continue?
|
||||
|
||||
Many developers have begun to use [GPT-3.5](https://platform.openai.com/docs/models/gpt-3-5) and [GPT-4](https://openai.com/research/gpt-4) through [ChatGPT](https://openai.com/blog/chatgpt) while coding; however, the experience is painful because of how much manual copying, pasting, and editing is required to provide the necessary context and incorporate the generated solutions into your codebase. Continue eliminates this pain by deeply integrating LLMs into your IDE amd workflows.
|
||||
Many developers have begun to use [GPT-3.5](https://platform.openai.com/docs/models/gpt-3-5) and [GPT-4](https://openai.com/research/gpt-4) through [ChatGPT](https://openai.com/blog/chatgpt) while coding; however, the experience is painful because of how much manual copying, pasting, and editing is required to provide the necessary context and incorporate the generated solutions and advice into your codebase. Continue eliminates this pain by enabling LLMs to natively act in your IDE as you complete your workflows.
|
||||
|
||||
Continue accelerates how developers build, ship, and maintain software, while giving them the control to define when LLMs should take actions and the confidence to trust LLMs. In short, it enables developers to do what they have always done: work together to create better and better abstractions that make it easier and easier to automate the repetitive work that people want computers to do.
|
||||
|
|
@ -36,21 +36,19 @@ const config = {
|
|||
presets: [
|
||||
[
|
||||
"classic",
|
||||
{
|
||||
gtag: {
|
||||
trackingID: 'G-M3JWW8N2XQ',
|
||||
},
|
||||
},
|
||||
/** @type {import('@docusaurus/preset-classic').Options} */
|
||||
({
|
||||
docs: {
|
||||
routeBasePath: '/',
|
||||
sidebarPath: require.resolve("./sidebars.js"),
|
||||
editUrl: "https://github.com/continuedev/continue/",
|
||||
editUrl: "https://github.com/continuedev/continue/tree/main/docs",
|
||||
},
|
||||
theme: {
|
||||
customCss: require.resolve("./src/css/custom.css"),
|
||||
},
|
||||
gtag: {
|
||||
trackingID: 'G-M3JWW8N2XQ',
|
||||
},
|
||||
}),
|
||||
],
|
||||
],
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ const sidebars = {
|
|||
"intro",
|
||||
"getting-started",
|
||||
"install",
|
||||
"catalog",
|
||||
"how-continue-works",
|
||||
"telemetry",
|
||||
],
|
||||
|
|
|
|||
|
|
@ -4,32 +4,29 @@ import styles from "./styles.module.css";
|
|||
|
||||
const FeatureList = [
|
||||
{
|
||||
title: "Tell LLMs when to step in",
|
||||
title: "Understand and edit code",
|
||||
Svg: require("@site/static/img/undraw_docusaurus_mountain.svg").default,
|
||||
description: (
|
||||
<>
|
||||
Seamlessly put your repetitive software development tasks
|
||||
on autopilot by leveraging recipes created by others
|
||||
Seamlessly ask language models to help you complete steps in your software development tasks
|
||||
</>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "Write your own recipes",
|
||||
title: "Customizable for your team",
|
||||
Svg: require("@site/static/img/undraw_docusaurus_tree.svg").default,
|
||||
description: (
|
||||
<>
|
||||
Use the Continue SDK to create custom steps and compose
|
||||
them into recipes, guiding LLMs through common tasks
|
||||
Define when and how LLMs should act to accelerate steps in your team-specific workflows
|
||||
</>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "Wield LLMs with confidence",
|
||||
title: "Break down your work step-by-step",
|
||||
Svg: require("@site/static/img/undraw_docusaurus_react.svg").default,
|
||||
description: (
|
||||
<>
|
||||
Use the Continue GUI to review, reverse, and rerun steps or even
|
||||
entire recipes, allowing you to build trust in language models
|
||||
Use the Continue GUI to review, reverse, and rerun steps that LLMs and you have taken together
|
||||
</>
|
||||
),
|
||||
},
|
||||
|
|
|
|||
BIN
docs/static/img/codespaces-install.png
vendored
Normal file
BIN
docs/static/img/codespaces-install.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 488 KiB |
BIN
docs/static/img/vscode-install.png
vendored
Normal file
BIN
docs/static/img/vscode-install.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 310 KiB |
Loading…
Add table
Reference in a new issue