Fix nits in CLI (#108)
Fixes: - [Opening browser doesn't work in ssh](https://app.clickup.com/t/86b2h46f7) - ["bright black" color text in `arcade chat -d` is invisible in iTerm](https://app.clickup.com/t/86b2h494v) - [Colors and styles are inconsistent in non-zsh shells](https://app.clickup.com/t/86b2h49kb)
This commit is contained in:
parent
0c63110d66
commit
c81da86460
3 changed files with 24 additions and 12 deletions
|
|
@ -116,11 +116,12 @@ def display_tool_messages(tool_messages: list[dict]) -> None:
|
||||||
if message["role"] == "assistant":
|
if message["role"] == "assistant":
|
||||||
for tool_call in message.get("tool_calls", []):
|
for tool_call in message.get("tool_calls", []):
|
||||||
console.print(
|
console.print(
|
||||||
f"[bright_black][bold]Called tool '{tool_call['function']['name']}'[/bold]\n[bold]Parameters:[/bold]{tool_call['function']['arguments']}[/bright_black]"
|
f"[bold]Called tool '{tool_call['function']['name']}' with parameters:[/bold] {tool_call['function']['arguments']}",
|
||||||
|
style="dim",
|
||||||
)
|
)
|
||||||
elif message["role"] == "tool":
|
elif message["role"] == "tool":
|
||||||
console.print(
|
console.print(
|
||||||
f"[bright_black][bold]'{message['name']}' tool returned:[/bold]{message['content']}[/bright_black]"
|
f"[bold]'{message['name']}' tool returned:[/bold] {message['content']}", style="dim"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,8 +76,13 @@ def login(
|
||||||
callback_uri = "http://localhost:9905/callback"
|
callback_uri = "http://localhost:9905/callback"
|
||||||
params = urlencode({"callback_uri": callback_uri, "state": state})
|
params = urlencode({"callback_uri": callback_uri, "state": state})
|
||||||
login_url = f"https://{host}/api/v1/auth/cli_login?{params}"
|
login_url = f"https://{host}/api/v1/auth/cli_login?{params}"
|
||||||
|
|
||||||
console.print("Opening a browser to log you in...")
|
console.print("Opening a browser to log you in...")
|
||||||
webbrowser.open(login_url)
|
if not webbrowser.open(login_url):
|
||||||
|
console.print(
|
||||||
|
f"If a browser doesn't open automatically, copy this URL and paste it into your browser: {login_url}",
|
||||||
|
style="dim",
|
||||||
|
)
|
||||||
|
|
||||||
# Wait for the server thread to finish
|
# Wait for the server thread to finish
|
||||||
server_thread.join()
|
server_thread.join()
|
||||||
|
|
@ -230,7 +235,6 @@ def chat(
|
||||||
|
|
||||||
client = Arcade(api_key=config.api.key, base_url=config.engine_url)
|
client = Arcade(api_key=config.api.key, base_url=config.engine_url)
|
||||||
user_email = config.user.email if config.user else None
|
user_email = config.user.email if config.user else None
|
||||||
user_attribution = f"({user_email})" if user_email else ""
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# start messages conversation
|
# start messages conversation
|
||||||
|
|
@ -245,7 +249,7 @@ def chat(
|
||||||
log_engine_health(client)
|
log_engine_health(client)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
console.print(f"\n[magenta][bold]User[/bold] {user_attribution}:[/magenta] ")
|
console.print(f"\n[magenta][bold]User[/bold] ({user_email}):[/magenta] ")
|
||||||
|
|
||||||
# Use input() instead of console.input() to leverage readline history
|
# Use input() instead of console.input() to leverage readline history
|
||||||
user_input = input()
|
user_input = input()
|
||||||
|
|
@ -331,7 +335,8 @@ def config(
|
||||||
console.print("✅ Configuration updated successfully.", style="bold green")
|
console.print("✅ Configuration updated successfully.", style="bold green")
|
||||||
else:
|
else:
|
||||||
console.print(
|
console.print(
|
||||||
f"❌ Invalid configuration name: {name} in section: {section}", style="bold red"
|
f"❌ Invalid configuration name: {name} in section: {section}",
|
||||||
|
style="bold red",
|
||||||
)
|
)
|
||||||
raise typer.Exit(code=1)
|
raise typer.Exit(code=1)
|
||||||
else:
|
else:
|
||||||
|
|
@ -350,7 +355,10 @@ def evals(
|
||||||
help="Maximum number of concurrent evaluations (default: 1)",
|
help="Maximum number of concurrent evaluations (default: 1)",
|
||||||
),
|
),
|
||||||
models: str = typer.Option(
|
models: str = typer.Option(
|
||||||
"gpt-4o", "--models", "-m", help="The models to use for evaluation (default: gpt-4o)"
|
"gpt-4o",
|
||||||
|
"--models",
|
||||||
|
"-m",
|
||||||
|
help="The models to use for evaluation (default: gpt-4o)",
|
||||||
),
|
),
|
||||||
host: str = typer.Option(
|
host: str = typer.Option(
|
||||||
None,
|
None,
|
||||||
|
|
@ -409,7 +417,8 @@ def evals(
|
||||||
if show_details:
|
if show_details:
|
||||||
suite_label = "suite" if len(eval_suites) == 1 else "suites"
|
suite_label = "suite" if len(eval_suites) == 1 else "suites"
|
||||||
console.print(
|
console.print(
|
||||||
f"\nFound {len(eval_suites)} {suite_label} in the evaluation files.", style="bold"
|
f"\nFound {len(eval_suites)} {suite_label} in the evaluation files.",
|
||||||
|
style="bold",
|
||||||
)
|
)
|
||||||
|
|
||||||
async def run_evaluations() -> None:
|
async def run_evaluations() -> None:
|
||||||
|
|
@ -466,7 +475,9 @@ def dev(
|
||||||
@cli.command(help="Start a local Arcade Actor server", rich_help_panel="Launch", hidden=True)
|
@cli.command(help="Start a local Arcade Actor server", rich_help_panel="Launch", hidden=True)
|
||||||
def actorup(
|
def actorup(
|
||||||
host: str = typer.Option(
|
host: str = typer.Option(
|
||||||
"127.0.0.1", help="Host for the app, from settings by default.", show_default=True
|
"127.0.0.1",
|
||||||
|
help="Host for the app, from settings by default.",
|
||||||
|
show_default=True,
|
||||||
),
|
),
|
||||||
port: int = typer.Option(
|
port: int = typer.Option(
|
||||||
"8002", "-p", "--port", help="Port for the app, defaults to ", show_default=True
|
"8002", "-p", "--port", help="Port for the app, defaults to ", show_default=True
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ def handle_streaming_content(stream: Stream[ChatCompletionChunk], model: str) ->
|
||||||
if role == "":
|
if role == "":
|
||||||
role = choice.delta.role or ""
|
role = choice.delta.role or ""
|
||||||
if role == "assistant":
|
if role == "assistant":
|
||||||
console.print(f"\n[bold blue]Assistant ({model}):[/bold blue] ")
|
console.print(f"\n[blue][bold]Assistant[/bold] ({model}):[/blue] ")
|
||||||
if chunk_message:
|
if chunk_message:
|
||||||
full_message += chunk_message
|
full_message += chunk_message
|
||||||
markdown_chunk = Markdown(full_message)
|
markdown_chunk = Markdown(full_message)
|
||||||
|
|
@ -292,10 +292,10 @@ def handle_chat_interaction(
|
||||||
if role == "assistant":
|
if role == "assistant":
|
||||||
message_content = markdownify_urls(message_content)
|
message_content = markdownify_urls(message_content)
|
||||||
console.print(
|
console.print(
|
||||||
f"\n[bold blue]Assistant ({model}):[/bold blue] ", Markdown(message_content)
|
f"\n[blue][bold]Assistant[/bold] ({model}):[/blue] ", Markdown(message_content)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
console.print(f"\n[bold magenta]{role}:[/bold magenta] {message_content}")
|
console.print(f"\n[bold]{role}:[/bold] {message_content}")
|
||||||
|
|
||||||
history += tool_messages
|
history += tool_messages
|
||||||
history.append({"role": role, "content": message_content})
|
history.append({"role": role, "content": message_content})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue