small fixes

This commit is contained in:
Nate Sesti 2023-06-29 17:32:03 -07:00
parent 2719d7ad18
commit 03aac35a07
5 changed files with 70 additions and 50 deletions

View file

@ -31,6 +31,8 @@ def get_error_title(e: Exception) -> str:
return e._message
elif isinstance(e, ClientPayloadError):
return "The request to OpenAI failed. Please try again."
elif isinstance(e, openai_errors.APIConnectionError):
return "The request failed. Please check your internet connection and try again."
return e.__repr__()

View file

@ -111,7 +111,7 @@ class HistoryNode(ContinueBaseModel):
content=json.dumps({
"description": self.step.description or "Function complete",
}),
summary=f"Ran function {self.step.name}"
summary=f"Called function {self.step.name}"
)]

View file

@ -1,6 +1,8 @@
import json
from typing import Any, Coroutine, List
from pydantic import Field
from .main import EditHighlightedCodeStep
from .core.core import MessageStep
from ..core.main import FunctionCall, Models
@ -113,8 +115,10 @@ class ViewDirectoryTreeStep(Step):
class EditFileStep(Step):
name: str = "Edit File"
description: str = "Edit a file in the workspace that is not currently open."
filename: str
instructions: str
filename: str = Field(
..., description="The name of the file to edit.")
instructions: str = Field(
..., description="The instructions to edit the file.")
hide: bool = True
async def run(self, sdk: ContinueSDK):
@ -201,7 +205,7 @@ class ChatWithFunctions(Step):
# name=func_name,
# arguments=func_args
# ),
# summary=f"Ran function {func_name}"
# summary=f"Called function {func_name}"
# ))
# self.chat_context.append(ChatMessage(
# role="user",
@ -212,7 +216,11 @@ class ChatWithFunctions(Step):
# continue
# Call the function, then continue to chat
func_args = "{}" if func_args == "" else func_args
fn_call_params = json.loads(func_args)
try:
fn_call_params = json.loads(func_args)
except json.JSONDecodeError:
raise Exception(
"The model returned invalid JSON. Please try again")
self.chat_context.append(ChatMessage(
role="assistant",
content=None,
@ -220,7 +228,7 @@ class ChatWithFunctions(Step):
name=func_name,
arguments=func_args
),
summary=f"Ran function {func_name}"
summary=f"Called function {func_name}"
))
last_function_called_index_in_history = sdk.history.current_index + 1
step_to_run = step_name_step_class_map[func_name](
@ -234,5 +242,10 @@ class ChatWithFunctions(Step):
# self.description += f"\nAdded directory `{func_args['directory_name']}`"
# else:
# self.description += f"\n`Running function {func_name}`\n\n"
if func_name == "EditHighlightedCodeStep":
step_to_run.user_input = self.user_input
elif func_name == "EditFile":
step_to_run.instructions = self.user_input
await sdk.run_step(step_to_run)
await sdk.update_ui()

View file

@ -454,7 +454,7 @@ class DefaultModelEditCodeStep(Step):
self._prompt_and_completion += prompt + completion
async def run(self, sdk: ContinueSDK) -> Coroutine[Observation, None, None]:
self.description = f"{self.user_input}"
self.description = f"`{self.user_input}`"
await sdk.update_ui()
rif_with_contents = []

View file

@ -65,51 +65,56 @@ function CodeBlock(props: { children: React.ReactNode }) {
const [result, setResult] = useState<AutoHighlightResult | undefined>(
undefined
);
const [highlightTimeout, setHighlightTimeout] = useState<
NodeJS.Timeout | undefined
>(undefined);
useEffect(() => {
const result = hljs.highlightAuto(
(props.children as any).props.children[0],
[
"python",
"javascript",
"typescript",
"bash",
"html",
"css",
"json",
"yaml",
"markdown",
"sql",
"java",
"c",
"cpp",
"csharp",
"go",
"kotlin",
"php",
"ruby",
"rust",
"scala",
"swift",
"dart",
"haskell",
"perl",
"r",
"matlab",
"powershell",
"lua",
"elixir",
"clojure",
"groovy",
"julia",
"vbnet",
"objectivec",
"fsharp",
"erlang",
"ocaml",
]
// Don't highlight more than once every 100ms
if (highlightTimeout) {
return;
}
setHighlightTimeout(
setTimeout(() => {
const result = hljs.highlightAuto(
(props.children as any).props.children[0],
[
"python",
"javascript",
"typescript",
"bash",
"html",
"css",
"json",
"yaml",
"markdown",
"sql",
"java",
"c",
"cpp",
"csharp",
"go",
"kotlin",
"php",
"ruby",
"rust",
"scala",
"swift",
"dart",
"haskell",
"perl",
"r",
"julia",
"objectivec",
"ocaml",
]
);
setResult(result);
setHighlightTimeout(undefined);
}, 100)
);
console.log(result);
setResult(result);
}, [props.children]);
const [hovered, setHovered] = useState<boolean>(false);