Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Commit

Permalink
Color replaced with style in stream (#493)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakethekoenig authored Jan 18, 2024
1 parent 8a2e610 commit e0c3578
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion mentat/command/commands/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async def apply(self, *args: str) -> None:
)
stream.send(f"{rel_path} added to context", style="success")
else:
stream.send("(Y/n)")
stream.send("(Y/n)", style="input")
user_input: str = (
await collect_user_input(plain=True)
).data.strip()
Expand Down
2 changes: 1 addition & 1 deletion mentat/feature_filters/llm_feature_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ async def filter(
except (PathValidationError, AssertionError):
stream.send(
f"LLM selected invalid path: {selected_ref}, skipping.",
color="light_yellow",
style="warning",
)

# Truncate again to enforce max_tokens
Expand Down
22 changes: 10 additions & 12 deletions mentat/parsers/file_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async def _ask_user_change(
session_context = SESSION_CONTEXT.get()
stream = session_context.stream

stream.send(text, color="light_blue")
stream.send(text, style="input")
return await ask_yes_no(default_yes=True)


Expand Down Expand Up @@ -153,14 +153,14 @@ def is_valid(self) -> bool:
if self.file_path.exists():
stream.send(
f"File {display_path} already exists, canceling creation.",
color="light_yellow",
style="warning",
)
return False
else:
if not self.file_path.exists():
stream.send(
f"File {display_path} does not exist, canceling all edits to file.",
color="light_yellow",
style="warning",
)
return False
file_features_in_context = [
Expand All @@ -173,7 +173,7 @@ def is_valid(self) -> bool:
):
stream.send(
f"File {display_path} not in context, canceling all edits to file.",
color="light_yellow",
style="warning",
)
return False

Expand All @@ -184,7 +184,7 @@ def is_valid(self) -> bool:
stream.send(
f"File {display_path} being renamed to existing file"
f" {rel_rename_path or self.rename_file_path}, canceling rename.",
color="light_yellow",
style="warning",
)
self.rename_file_path = None
return True
Expand Down Expand Up @@ -236,7 +236,7 @@ def _print_resolution(self, first: Replacement, second: Replacement):
stream.send(self.file_path)
stream.send(change_delimiter)
for line in first.new_lines + second.new_lines:
stream.send("+ " + line, color="green")
stream.send("+ " + line, style="success")
stream.send(change_delimiter)

def resolve_conflicts(self):
Expand Down Expand Up @@ -291,7 +291,7 @@ def undo(self):

self._display_creation(prefix=prefix)
ctx.stream.send(
f"Creation of file {self.file_path} undone", color="light_blue"
f"Creation of file {self.file_path} undone", style="success"
)
return

Expand All @@ -311,7 +311,7 @@ def undo(self):
self._display_rename(prefix=prefix)
ctx.stream.send(
f"Rename of file {self.file_path} to {self.rename_file_path} undone",
color="light_blue",
style="success",
)

if self.is_deletion:
Expand All @@ -330,7 +330,7 @@ def undo(self):

self._display_deletion(self.previous_file_lines, prefix=prefix)
ctx.stream.send(
f"Deletion of file {self.file_path} undone", color="light_red"
f"Deletion of file {self.file_path} undone", style="success"
)
elif self.replacements:
if not self.file_path.exists():
Expand All @@ -345,6 +345,4 @@ def undo(self):
f.write("\n".join(self.previous_file_lines))

self._display_replacements(self.previous_file_lines, prefix=prefix)
ctx.stream.send(
f"Edits to file {self.file_path} undone", color="light_blue"
)
ctx.stream.send(f"Edits to file {self.file_path} undone", style="success")
4 changes: 2 additions & 2 deletions mentat/parsers/json_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ async def stream_and_parse_llm_response(
validate(instance=response_json, schema=output_schema)
except JSONDecodeError:
# Should never happen with OpenAI's response_format set to json
stream.send("Error processing model response: Invalid JSON", color="red")
stream.send("Error processing model response: Invalid JSON", style="error")
return ParsedLLMResponse(message, "", [])
except ValidationError:
stream.send(
"Error processing model response: Invalid format given", color="red"
"Error processing model response: Invalid format given", style="error"
)
return ParsedLLMResponse(message, "", [])

Expand Down
2 changes: 1 addition & 1 deletion mentat/terminal/themes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"success": "green",
"input": "light_blue",
"error": "red",
"warning": "blue",
"warning": "yellow",
},
"dark": {
"code": "blue",
Expand Down

0 comments on commit e0c3578

Please sign in to comment.