Skip to content

Commit

Permalink
feat(cody_py): improve chat response formatting
Browse files Browse the repository at this point in the history
- Modify CodyAgent.send_chat() to return just the response string
- Update main.py to print chat responses with "Assistant: " prefix
- Add BLUE color code import in main.py for response formatting

The changes aim to enhance the formatting and readability of chat responses
from the CodyAgent. The response is now printed with a consistent "Assistant: "
prefix, making it easier to distinguish from user input. The BLUE color code
is also imported and used for the prefix to improve visual clarity.
  • Loading branch information
PriNova committed May 2, 2024
1 parent 4ec8189 commit 7359f85
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions codypy/cody_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ async def chat(
show_context_files: bool = False,
context_files=None,
is_debugging: bool = False,
) -> str:
):
"""
Sends a chat message to the Cody server and returns the response.
Expand Down Expand Up @@ -462,7 +462,7 @@ async def chat(
return f"{RED}--- Failed to submit chat message ---{RESET}"
debug_method_map["webview/postMessage"] = True
return (
f"{BLUE}{speaker.capitalize()}{RESET}: {response}\n",
response,
context_files_response,
)

Expand Down
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from codypy.client_info import AgentSpecs, Models
from codypy.cody_py import CodyAgent, CodyServer
from codypy.config import GREEN, RESET, YELLOW # , debug_method_map
from codypy.config import BLUE, GREEN, RESET, YELLOW # , debug_method_map
from codypy.context import append_paths
from codypy.logger import log_message, setup_logger

Expand Down Expand Up @@ -97,7 +97,7 @@ async def main():
)
if response == "":
break
print(response)
print(f"{BLUE}Assistant{RESET}: {response}\n")
print("--- Context Files ---")
if context_files_response:
for context in context_files_response:
Expand Down

0 comments on commit 7359f85

Please sign in to comment.