details
This commit is contained in:
parent
461fd4df95
commit
c5cee3f4c4
7 changed files with 61 additions and 51 deletions
|
|
@ -1,5 +1,5 @@
|
|||
from textwrap import dedent
|
||||
from typing import List, Tuple, Type
|
||||
from typing import List, Tuple, Type, Union
|
||||
|
||||
from ..steps.welcome import WelcomeStep
|
||||
from .config import ContinueConfig
|
||||
|
|
@ -22,6 +22,34 @@ from ..libs.util.step_name_to_steps import get_step_from_name
|
|||
from ..steps.custom_command import CustomCommandStep
|
||||
|
||||
|
||||
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]
|
||||
after_command = " ".join(inp.split(" ")[1:])
|
||||
|
||||
for slash_command in config.slash_commands:
|
||||
if slash_command.name == command_name[1:]:
|
||||
params = slash_command.params
|
||||
params["user_input"] = after_command
|
||||
return get_step_from_name(slash_command.step_name, params)
|
||||
return None
|
||||
|
||||
|
||||
def parse_custom_command(inp: str, config: ContinueConfig) -> Union[None, Step]:
|
||||
command_name = inp.split(" ")[0]
|
||||
after_command = " ".join(inp.split(" ")[1:])
|
||||
for custom_cmd in config.custom_commands:
|
||||
if custom_cmd.name == command_name[1:]:
|
||||
slash_command = parse_slash_command(custom_cmd.prompt, config)
|
||||
if slash_command is not None:
|
||||
return slash_command
|
||||
return CustomCommandStep(name=custom_cmd.name, prompt=custom_cmd.prompt, user_input=after_command)
|
||||
return None
|
||||
|
||||
|
||||
class DemoPolicy(Policy):
|
||||
ran_code_last: bool = False
|
||||
|
||||
|
|
@ -46,34 +74,14 @@ class DemoPolicy(Policy):
|
|||
# This could be defined with ObservationTypePolicy. Ergonomics not right though.
|
||||
user_input = observation.user_input
|
||||
|
||||
if user_input.startswith("/"):
|
||||
command_name = user_input.split(" ")[0]
|
||||
after_command = " ".join(user_input.split(" ")[1:])
|
||||
for slash_command in config.slash_commands:
|
||||
if slash_command.name == command_name[1:]:
|
||||
params = slash_command.params
|
||||
params["user_input"] = after_command
|
||||
return get_step_from_name(slash_command.step_name, params)
|
||||
slash_command = parse_slash_command(user_input)
|
||||
if slash_command is not None:
|
||||
return slash_command
|
||||
|
||||
for custom_cmd in config.custom_commands:
|
||||
if custom_cmd.name == command_name[1:]:
|
||||
return CustomCommandStep(name=custom_cmd.name, prompt=custom_cmd.prompt, user_input=after_command)
|
||||
custom_command = parse_custom_command(user_input)
|
||||
if custom_command is not None:
|
||||
return custom_command
|
||||
|
||||
# return EditHighlightedCodeStep(user_input=user_input)
|
||||
return ChatWithFunctions(user_input=user_input)
|
||||
return NLDecisionStep(user_input=user_input, steps=[
|
||||
(EditHighlightedCodeStep(user_input=user_input),
|
||||
"Edit the highlighted code"),
|
||||
# AnswerQuestionChroma(question=user_input),
|
||||
# EditFileChroma(request=user_input),
|
||||
(SimpleChatStep(user_input=user_input),
|
||||
"Respond to the user with a chat message. Can answer questions about code or anything else."),
|
||||
], default_step=EditHighlightedCodeStep(user_input=user_input))
|
||||
|
||||
state = history.get_current()
|
||||
|
||||
if observation is not None and isinstance(observation, TracebackObservation):
|
||||
self.ran_code_last = False
|
||||
return SolveTracebackStep(traceback=observation.traceback)
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
|
|
|||
4
extension/package-lock.json
generated
4
extension/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "0.0.109",
|
||||
"version": "0.0.110",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "0.0.109",
|
||||
"version": "0.0.110",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@electron/rebuild": "^3.2.10",
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
"displayName": "Continue",
|
||||
"pricing": "Free",
|
||||
"description": "The open-source coding autopilot",
|
||||
"version": "0.0.109",
|
||||
"version": "0.0.110",
|
||||
"publisher": "Continue",
|
||||
"engines": {
|
||||
"vscode": "^1.67.0"
|
||||
|
|
|
|||
|
|
@ -324,7 +324,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
|
|||
/>
|
||||
))}
|
||||
|
||||
<span className="text-trueGray-400 ml-auto mr-4 text-xs">
|
||||
<span className="text-trueGray-400 ml-auto mr-4 text-xs text-right">
|
||||
Highlight code to include as context. Currently open file included by
|
||||
default. {highlightedCodeSections.length === 0 && ""}
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -11,11 +11,9 @@ import {
|
|||
ChevronDown,
|
||||
ChevronRight,
|
||||
ArrowPath,
|
||||
XMark
|
||||
XMark,
|
||||
} from "@styled-icons/heroicons-outline";
|
||||
import {
|
||||
Stop,
|
||||
} from "@styled-icons/heroicons-solid";
|
||||
import { Stop } from "@styled-icons/heroicons-solid";
|
||||
import { HistoryNode } from "../../../schema/HistoryNode";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
import HeaderButtonWithText from "./HeaderButtonWithText";
|
||||
|
|
@ -213,7 +211,11 @@ function StepContainer(props: StepContainerProps) {
|
|||
text={props.historyNode.active ? "Stop" : "Delete"}
|
||||
active={props.historyNode.active}
|
||||
>
|
||||
{props.historyNode.active ? <Stop size="1.6em" onClick={props.onDelete} /> :<XMark size="1.6em" onClick={props.onDelete} />}
|
||||
{props.historyNode.active ? (
|
||||
<Stop size="1.2em" onClick={props.onDelete} />
|
||||
) : (
|
||||
<XMark size="1.6em" onClick={props.onDelete} />
|
||||
)}
|
||||
</HeaderButtonWithText>
|
||||
{props.historyNode.observation?.error ? (
|
||||
<HeaderButtonWithText
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ interface UserInputContainerProps {
|
|||
historyNode: HistoryNode;
|
||||
}
|
||||
|
||||
const StyledDiv = styled.div<{ hidden: boolean }>`
|
||||
background-color: rgb(50 50 50);
|
||||
const StyledDiv = styled.div`
|
||||
background-color: rgb(45 45 45);
|
||||
padding: 8px;
|
||||
padding-left: 16px;
|
||||
padding-right: 16px;
|
||||
|
|
@ -24,14 +24,12 @@ const StyledDiv = styled.div<{ hidden: boolean }>`
|
|||
font-size: 13px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
visibility: ${(props) => (props.hidden ? "hidden" : "visible")};
|
||||
height: ${(props) => (props.hidden ? "0px" : "auto")};
|
||||
`;
|
||||
|
||||
const UserInputContainer = (props: UserInputContainerProps) => {
|
||||
return (
|
||||
<StyledDiv hidden={props.historyNode.step.hide as any}>
|
||||
{props.children}
|
||||
<StyledDiv>
|
||||
<b>{props.children}</b>
|
||||
<div style={{ marginLeft: "auto" }}>
|
||||
<HeaderButtonWithText
|
||||
onClick={(e) => {
|
||||
|
|
|
|||
|
|
@ -295,14 +295,16 @@ function GUI(props: GUIProps) {
|
|||
)}
|
||||
{history?.timeline.map((node: HistoryNode, index: number) => {
|
||||
return node.step.name === "User Input" ? (
|
||||
<UserInputContainer
|
||||
onDelete={() => {
|
||||
client?.deleteAtIndex(index);
|
||||
}}
|
||||
historyNode={node}
|
||||
>
|
||||
{node.step.description as string}
|
||||
</UserInputContainer>
|
||||
node.step.hide || (
|
||||
<UserInputContainer
|
||||
onDelete={() => {
|
||||
client?.deleteAtIndex(index);
|
||||
}}
|
||||
historyNode={node}
|
||||
>
|
||||
{node.step.description as string}
|
||||
</UserInputContainer>
|
||||
)
|
||||
) : (
|
||||
<StepContainer
|
||||
isLast={index === history.timeline.length - 1}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue