Merge branch 'main' into play-button
This commit is contained in:
commit
8cf2962eb6
8 changed files with 132 additions and 30 deletions
|
|
@ -154,10 +154,11 @@ class DefaultModelEditCodeStep(Step):
|
|||
async def describe(self, models: Models) -> Coroutine[str, None, None]:
|
||||
description = await models.gpt35.complete(
|
||||
f"{self._prompt_and_completion}\n\nPlease give brief a description of the changes made above using markdown bullet points. Be concise and only mention changes made to the commit before, not prefix or suffix:")
|
||||
return description
|
||||
self.name = await models.gpt35.complete(f"Write a very short title to describe this requested change: '{self.user_input}'. This is the title:")
|
||||
return f"`{self.user_input}`\n\n" + description
|
||||
|
||||
async def run(self, sdk: ContinueSDK) -> Coroutine[Observation, None, None]:
|
||||
self.name = self.user_input
|
||||
self.description = f"`{self.user_input}`"
|
||||
await sdk.update_ui()
|
||||
|
||||
rif_with_contents = []
|
||||
|
|
@ -174,7 +175,7 @@ class DefaultModelEditCodeStep(Step):
|
|||
await sdk.ide.setFileOpen(rif.filepath)
|
||||
|
||||
model_to_use = sdk.models.default
|
||||
|
||||
|
||||
full_file_contents = await sdk.ide.readFile(rif.filepath)
|
||||
|
||||
full_file_contents_lst = full_file_contents.split("\n")
|
||||
|
|
@ -185,42 +186,49 @@ class DefaultModelEditCodeStep(Step):
|
|||
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])
|
||||
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])
|
||||
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)
|
||||
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":
|
||||
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)
|
||||
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])
|
||||
|
||||
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]
|
||||
|
||||
|
|
|
|||
21
extension/react-app/package-lock.json
generated
21
extension/react-app/package-lock.json
generated
|
|
@ -16,6 +16,7 @@
|
|||
"react-dom": "^18.2.0",
|
||||
"react-markdown": "^8.0.5",
|
||||
"react-redux": "^8.0.5",
|
||||
"react-switch": "^7.0.0",
|
||||
"styled-components": "^5.3.6",
|
||||
"vscode-webview": "^1.0.1-beta.1"
|
||||
},
|
||||
|
|
@ -2721,6 +2722,18 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/react-switch": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/react-switch/-/react-switch-7.0.0.tgz",
|
||||
"integrity": "sha512-KkDeW+cozZXI6knDPyUt3KBN1rmhoVYgAdCJqAh7st7tk8YE6N0iR89zjCWO8T8dUTeJGTR0KU+5CHCRMRffiA==",
|
||||
"dependencies": {
|
||||
"prop-types": "^15.7.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^15.3.0 || ^16.0.0 || ^17.0.0 || ^18.0.0",
|
||||
"react-dom": "^15.3.0 || ^16.0.0 || ^17.0.0 || ^18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/read-cache": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz",
|
||||
|
|
@ -4983,6 +4996,14 @@
|
|||
"use-sync-external-store": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"react-switch": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/react-switch/-/react-switch-7.0.0.tgz",
|
||||
"integrity": "sha512-KkDeW+cozZXI6knDPyUt3KBN1rmhoVYgAdCJqAh7st7tk8YE6N0iR89zjCWO8T8dUTeJGTR0KU+5CHCRMRffiA==",
|
||||
"requires": {
|
||||
"prop-types": "^15.7.2"
|
||||
}
|
||||
},
|
||||
"read-cache": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz",
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
"react-dom": "^18.2.0",
|
||||
"react-markdown": "^8.0.5",
|
||||
"react-redux": "^8.0.5",
|
||||
"react-switch": "^7.0.0",
|
||||
"styled-components": "^5.3.6",
|
||||
"vscode-webview": "^1.0.1-beta.1"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ const StyledCopyButton = styled.button<{ visible: boolean }>`
|
|||
/* position: relative; */
|
||||
float: right;
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
background-color: ${secondaryDark};
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
/* margin: 4px; */
|
||||
|
|
@ -77,7 +77,10 @@ function CodeBlock(props: { language?: string; children: string }) {
|
|||
setHovered(false);
|
||||
}}
|
||||
>
|
||||
<CopyButton visible={hovered} textToCopy={props.children} />
|
||||
<CopyButton
|
||||
visible={hovered}
|
||||
textToCopy={(props.children as any).props.children[0]}
|
||||
/>
|
||||
<StyledCode>{props.children}</StyledCode>
|
||||
</StyledPre>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -116,6 +116,15 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
|
|||
disabled={props.disabled}
|
||||
placeholder="Type '/' to see available slash commands."
|
||||
{...getInputProps({
|
||||
onChange: (e) => {
|
||||
const target = e.target as HTMLTextAreaElement;
|
||||
// Update the height of the textarea to match the content, up to a max of 200px.
|
||||
target.style.height = "auto";
|
||||
target.style.height = `${Math.min(
|
||||
target.scrollHeight,
|
||||
200
|
||||
).toString()}px`;
|
||||
},
|
||||
onKeyDown: (event) => {
|
||||
if (event.key === "Enter" && event.shiftKey) {
|
||||
// Prevent Downshift's default 'Enter' behavior.
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ const HeaderButtonWithText = (props: HeaderButtonWithTextProps) => {
|
|||
const [hover, setHover] = useState(false);
|
||||
return (
|
||||
<HeaderButton
|
||||
style={{ padding: "3px" }}
|
||||
style={{ padding: "1px", paddingLeft: hover ? "4px" : "1px" }}
|
||||
onMouseEnter={() => setHover(true)}
|
||||
onMouseLeave={() => {
|
||||
setHover(false);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,5 @@
|
|||
import styled from "styled-components";
|
||||
import {
|
||||
defaultBorderRadius,
|
||||
vscBackground,
|
||||
Loader,
|
||||
MainTextInput,
|
||||
HeaderButton,
|
||||
} from "../components";
|
||||
import { defaultBorderRadius, Loader } from "../components";
|
||||
import ContinueButton from "../components/ContinueButton";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { History } from "../../../schema/History";
|
||||
|
|
@ -20,6 +14,10 @@ import {
|
|||
import ComboBox from "../components/ComboBox";
|
||||
import TextDialog from "../components/TextDialog";
|
||||
import HeaderButtonWithText from "../components/HeaderButtonWithText";
|
||||
import ReactSwitch from "react-switch";
|
||||
import { usePostHog } from "posthog-js/react";
|
||||
import { useSelector } from "react-redux";
|
||||
import { RootStore } from "../redux/store";
|
||||
|
||||
const TopGUIDiv = styled.div`
|
||||
overflow: hidden;
|
||||
|
|
@ -33,7 +31,7 @@ const UserInputQueueItem = styled.div`
|
|||
text-align: center;
|
||||
`;
|
||||
|
||||
const Footer = styled.footer`
|
||||
const Footer = styled.footer<{ dataSwitchChecked: boolean }>`
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 8px;
|
||||
|
|
@ -42,6 +40,8 @@ const Footer = styled.footer`
|
|||
align-items: center;
|
||||
margin-top: 8px;
|
||||
border-top: 0.1px solid gray;
|
||||
background-color: ${(props) =>
|
||||
props.dataSwitchChecked ? "#12887a33" : "transparent"};
|
||||
`;
|
||||
|
||||
interface GUIProps {
|
||||
|
|
@ -49,11 +49,18 @@ interface GUIProps {
|
|||
}
|
||||
|
||||
function GUI(props: GUIProps) {
|
||||
const posthog = usePostHog();
|
||||
const vscMachineId = useSelector(
|
||||
(state: RootStore) => state.config.vscMachineId
|
||||
);
|
||||
|
||||
const [waitingForSteps, setWaitingForSteps] = useState(false);
|
||||
const [userInputQueue, setUserInputQueue] = useState<string[]>([]);
|
||||
const [availableSlashCommands, setAvailableSlashCommands] = useState<
|
||||
{ name: string; description: string }[]
|
||||
>([]);
|
||||
const [dataSwitchChecked, setDataSwitchChecked] = useState(false);
|
||||
const [showDataSharingInfo, setShowDataSharingInfo] = useState(false);
|
||||
const [stepsOpen, setStepsOpen] = useState<boolean[]>([]);
|
||||
const [history, setHistory] = useState<History | undefined>();
|
||||
// {
|
||||
|
|
@ -390,7 +397,62 @@ function GUI(props: GUIProps) {
|
|||
/>
|
||||
<ContinueButton onClick={onMainTextInput} />
|
||||
</TopGUIDiv>
|
||||
<Footer>
|
||||
<div
|
||||
style={{
|
||||
position: "fixed",
|
||||
bottom: "50px",
|
||||
backgroundColor: "white",
|
||||
color: "black",
|
||||
borderRadius: defaultBorderRadius,
|
||||
padding: "16px",
|
||||
margin: "16px",
|
||||
}}
|
||||
hidden={!showDataSharingInfo}
|
||||
>
|
||||
By turning on the switch, you will anonymously contribute your Continue
|
||||
history to an open-source dataset used to train LLMs to use tools just
|
||||
like a developer in their IDE.
|
||||
<br />
|
||||
<br />
|
||||
<b>
|
||||
{dataSwitchChecked
|
||||
? "You are currently contributing data."
|
||||
: "Your data is not being shared."}
|
||||
</b>
|
||||
</div>
|
||||
<Footer dataSwitchChecked={dataSwitchChecked}>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
gap: "4px",
|
||||
marginRight: "auto",
|
||||
alignItems: "center",
|
||||
}}
|
||||
onMouseEnter={() => {
|
||||
setShowDataSharingInfo(true);
|
||||
}}
|
||||
onMouseLeave={() => {
|
||||
setShowDataSharingInfo(false);
|
||||
}}
|
||||
>
|
||||
<ReactSwitch
|
||||
height={20}
|
||||
handleDiameter={20}
|
||||
width={40}
|
||||
onChange={() => {
|
||||
posthog?.capture("data_switch_toggled", {
|
||||
vscMachineId: vscMachineId,
|
||||
dataSwitchChecked: !dataSwitchChecked,
|
||||
});
|
||||
setDataSwitchChecked((prev) => !prev);
|
||||
}}
|
||||
onColor="#12887a"
|
||||
checked={dataSwitchChecked}
|
||||
/>
|
||||
<span style={{ cursor: "help", fontSize: "16px" }}>
|
||||
Contribute Data
|
||||
</span>
|
||||
</div>
|
||||
<HeaderButtonWithText
|
||||
onClick={() => {
|
||||
client?.sendClear();
|
||||
|
|
|
|||
|
|
@ -62,9 +62,7 @@ const commandsMap: { [command: string]: (...args: any) => any } = {
|
|||
"continue.acceptSuggestion": acceptSuggestionCommand,
|
||||
"continue.rejectSuggestion": rejectSuggestionCommand,
|
||||
"continue.focusContinueInput": async () => {
|
||||
if (!debugPanelWebview) {
|
||||
vscode.commands.executeCommand("continue.continueGUIView.focus");
|
||||
}
|
||||
vscode.commands.executeCommand("continue.continueGUIView.focus");
|
||||
debugPanelWebview?.postMessage({
|
||||
type: "focusContinueInput",
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue