qbraid-cli 0.9.0a0__py3-none-any.whl → 0.9.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of qbraid-cli might be problematic. Click here for more details.

qbraid_cli/_version.py CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.9.0a0'
16
- __version_tuple__ = version_tuple = (0, 9, 0)
15
+ __version__ = version = '0.9.1'
16
+ __version_tuple__ = version_tuple = (0, 9, 1)
qbraid_cli/account/app.py CHANGED
@@ -28,7 +28,7 @@ def account_credits():
28
28
 
29
29
  qbraid_credits: float = run_progress_task(get_credits)
30
30
  typer.secho(
31
- f"\n{typer.style('qBraid credits remaining:')} "
31
+ f"{typer.style('qBraid credits remaining:')} "
32
32
  f"{typer.style(f'{qbraid_credits:.4f}', fg=typer.colors.MAGENTA, bold=True)}",
33
33
  nl=True, # Ensure a newline after output (default is True)
34
34
  )
@@ -0,0 +1,11 @@
1
+ # Copyright (c) 2024, qBraid Development Team
2
+ # All rights reserved.
3
+
4
+ """
5
+ Module defining the qbraid chat namespace
6
+
7
+ """
8
+
9
+ from .app import chat_app
10
+
11
+ __all__ = ["chat_app"]
qbraid_cli/chat/app.py ADDED
@@ -0,0 +1,96 @@
1
+ # Copyright (c) 2024, qBraid Development Team
2
+ # All rights reserved.
3
+
4
+ """
5
+ Module defining commands in the 'qbraid chat' namespace.
6
+
7
+ """
8
+ from enum import Enum
9
+
10
+ import typer
11
+ from rich.console import Console
12
+ from rich.table import Table
13
+
14
+ from qbraid_cli.handlers import handle_error, run_progress_task
15
+
16
+ chat_app = typer.Typer(
17
+ help="Interact with qBraid AI chat service.", pretty_exceptions_show_locals=False
18
+ )
19
+
20
+
21
+ class ChatFormat(str, Enum):
22
+ """Format of the response from the chat service."""
23
+
24
+ text = "text" # pylint: disable=invalid-name
25
+ code = "code" # pylint: disable=invalid-name
26
+
27
+
28
+ @chat_app.command("send")
29
+ def chat_send(
30
+ prompt: str = typer.Argument(..., help="The prompt to send to the chat service."),
31
+ model: str = typer.Option(None, "--model", "-m", help="The model to use for the chat service."),
32
+ response_format: ChatFormat = typer.Option(
33
+ ChatFormat.text, "--format", "-f", help="The format of the response."
34
+ ),
35
+ stream: bool = typer.Option(False, "--stream", "-s", help="Stream the response."),
36
+ ):
37
+ """
38
+ Interact with qBraid AI chat service.
39
+
40
+ """
41
+ # pylint: disable-next=import-outside-toplevel
42
+ from qbraid_core.services.chat import ChatClient, ChatServiceRequestError
43
+
44
+ client = ChatClient()
45
+
46
+ if response_format == ChatFormat.code:
47
+ prompt += " Return only raw code. Do not include any text outside of code blocks."
48
+
49
+ if stream:
50
+ try:
51
+ for chunk in client.chat_stream(prompt, model, response_format):
52
+ print(chunk, end="")
53
+ except ChatServiceRequestError as err:
54
+ handle_error(message=str(err), include_traceback=False)
55
+ else:
56
+ content = run_progress_task(
57
+ client.chat,
58
+ prompt,
59
+ model,
60
+ response_format,
61
+ description="Connecting to chat service...",
62
+ include_error_traceback=False,
63
+ )
64
+ print(content)
65
+
66
+
67
+ @chat_app.command(name="models")
68
+ def chat_models():
69
+ """List available chat models."""
70
+ # pylint: disable-next=import-outside-toplevel
71
+ from qbraid_core.services.chat import ChatClient
72
+
73
+ client = ChatClient()
74
+
75
+ models = run_progress_task(
76
+ client.get_models,
77
+ description="Connecting to chat service...",
78
+ include_error_traceback=False,
79
+ )
80
+
81
+ console = Console()
82
+ table = Table(title="Available Chat Models\n", show_lines=True, title_justify="left")
83
+
84
+ table.add_column("Model", style="cyan", no_wrap=True)
85
+ table.add_column("Pricing [not bold](1k tokens ~750 words)", style="magenta")
86
+ table.add_column("Description", style="green")
87
+
88
+ for model in models:
89
+ table.add_row(
90
+ model["model"],
91
+ f"{model['pricing']['input']} credits / 1M input tokens\n"
92
+ f"{model['pricing']['output']} credits / 1M output tokens",
93
+ model["description"],
94
+ )
95
+
96
+ console.print(table)
qbraid_cli/devices/app.py CHANGED
@@ -60,7 +60,7 @@ def devices_list( # pylint: disable=too-many-branches
60
60
  header_3 = "ID"
61
61
  header_4 = "Status"
62
62
  console.print(
63
- f"\n[bold]{header_1.ljust(12)}{header_2.ljust(35)}{header_3.ljust(41)}{header_4}[/bold]"
63
+ f"[bold]{header_1.ljust(12)}{header_2.ljust(35)}{header_3.ljust(41)}{header_4}[/bold]"
64
64
  )
65
65
  for device_provider, device_name, device_id, device_status in device_data:
66
66
  if device_status == "ONLINE":
qbraid_cli/envs/app.py CHANGED
@@ -88,7 +88,7 @@ def envs_create( # pylint: disable=too-many-statements
88
88
  slug_path = env_path / slug
89
89
  description = "None" if description == "" else description
90
90
 
91
- typer.echo("\n\n## qBraid Metadata ##\n")
91
+ typer.echo("## qBraid Metadata ##\n")
92
92
  typer.echo(f" name: {display_name}")
93
93
  typer.echo(f" description: {description}")
94
94
  typer.echo(f" tags: {tags}")
@@ -127,7 +127,7 @@ def envs_create( # pylint: disable=too-many-statements
127
127
 
128
128
  console = Console()
129
129
  console.print(
130
- f"\n[bold green]Successfully created qBraid environment: "
130
+ f"[bold green]Successfully created qBraid environment: "
131
131
  f"[/bold green][bold magenta]{name}[/bold magenta]\n"
132
132
  )
133
133
  typer.echo("# To activate this environment, use")
@@ -192,7 +192,7 @@ def envs_remove(
192
192
  description="Deleting local environment...",
193
193
  error_message="Failed to delete qBraid environment",
194
194
  )
195
- typer.echo(f"\nEnvironment '{name}' successfully removed.")
195
+ typer.echo(f"Environment '{name}' successfully removed.")
196
196
 
197
197
 
198
198
  @envs_app.command(name="list")
qbraid_cli/handlers.py CHANGED
@@ -10,11 +10,12 @@ and executing operations with progress tracking within the qBraid CLI.
10
10
  import os
11
11
  import traceback
12
12
  from pathlib import Path
13
+ from time import sleep
13
14
  from typing import Any, Callable, Optional, Union
14
15
 
15
16
  import typer
16
17
  from rich.console import Console
17
- from rich.progress import Progress, SpinnerColumn, TextColumn
18
+ from rich.progress import Progress, SpinnerColumn, TaskID, TextColumn
18
19
 
19
20
  from .exceptions import DEFAULT_ERROR_MESSAGE, QbraidException
20
21
 
@@ -24,6 +25,14 @@ def _should_display_progress():
24
25
  return os.getenv("QBRAID_CLI_SHOW_PROGRESS", "true").lower() in ["true", "1", "t", "y", "yes"]
25
26
 
26
27
 
28
+ def _update_completed_task(
29
+ progress: Progress, task_id: TaskID, success: bool = True, sleep_time: float = 0.15
30
+ ):
31
+ status = "Done" if success else "Failed"
32
+ progress.update(task_id, completed=100, status=status)
33
+ sleep(sleep_time)
34
+
35
+
27
36
  def handle_error(
28
37
  error_type: Optional[str] = None, message: Optional[str] = None, include_traceback: bool = True
29
38
  ) -> None:
@@ -85,6 +94,7 @@ def run_progress_task(
85
94
  *args,
86
95
  description: Optional[str] = None,
87
96
  error_message: Optional[str] = None,
97
+ include_error_traceback: bool = True,
88
98
  **kwargs,
89
99
  ) -> Any:
90
100
  """
@@ -102,6 +112,8 @@ def run_progress_task(
102
112
  error_message (optional, str): Custom error message to display if the operation.
103
113
  fails. Defaults to None, in which case the
104
114
  exception's message is used.
115
+ include_error_traceback (bool): Whether to include the traceback in the error message.
116
+ Defaults to True.
105
117
  **kwargs: Arbitrary keyword arguments for the operation.
106
118
 
107
119
  Returns:
@@ -115,7 +127,7 @@ def run_progress_task(
115
127
  return operation(*args, **kwargs)
116
128
  except Exception as err: # pylint: disable=broad-exception-caught
117
129
  custom_message = error_message if error_message else str(err)
118
- return handle_error(message=custom_message)
130
+ return handle_error(message=custom_message, include_traceback=include_error_traceback)
119
131
 
120
132
  console = Console()
121
133
  with Progress(
@@ -128,12 +140,14 @@ def run_progress_task(
128
140
  task = progress.add_task(description, status="In Progress", total=None)
129
141
  try:
130
142
  result = operation(*args, **kwargs)
131
- progress.update(task, completed=100, status="Done")
143
+ _update_completed_task(progress, task, success=True)
132
144
  return result
133
145
  except Exception as err: # pylint: disable=broad-exception-caught
134
- progress.update(task, completed=100, status="Failed")
146
+ _update_completed_task(progress, task, success=False)
135
147
  custom_message = error_message if error_message else str(err)
136
- return handle_error(message=custom_message)
148
+ return handle_error(message=custom_message, include_traceback=include_error_traceback)
149
+ finally:
150
+ progress.remove_task(task)
137
151
 
138
152
 
139
153
  def _format_list_items(items: list[str]) -> str:
qbraid_cli/jobs/app.py CHANGED
@@ -120,7 +120,7 @@ def jobs_list(
120
120
  header_1 = "Job ID"
121
121
  header_2 = "Submitted"
122
122
  header_3 = "Status"
123
- console.print(f"\n[bold]{header_1.ljust(spacing)}{header_2.ljust(36)}{header_3}[/bold]")
123
+ console.print(f"[bold]{header_1.ljust(spacing)}{header_2.ljust(36)}{header_3}[/bold]")
124
124
  for job_id, submitted, status in job_data:
125
125
  if status == "COMPLETED":
126
126
  status_color = "green"
@@ -103,7 +103,7 @@ def confirm_updates(
103
103
  else:
104
104
  raise ValueError(f"Invalid mode: {mode}. Expected 'enable' or 'disable'.")
105
105
 
106
- typer.echo(f"\n==> WARNING: {provider}/{core_package} package required <==")
106
+ typer.echo(f"==> WARNING: {provider}/{core_package} package required <==")
107
107
  if (
108
108
  installed_version is not None
109
109
  and target_version is not None
qbraid_cli/main.py CHANGED
@@ -6,10 +6,12 @@ Entrypoint for the qBraid CLI.
6
6
 
7
7
  """
8
8
 
9
+ import rich
9
10
  import typer
10
11
 
11
12
  from qbraid_cli.account.app import account_app
12
13
  from qbraid_cli.admin.app import admin_app
14
+ from qbraid_cli.chat.app import chat_app
13
15
  from qbraid_cli.configure.app import configure_app
14
16
  from qbraid_cli.devices.app import devices_app
15
17
  from qbraid_cli.jobs.app import jobs_app
@@ -26,6 +28,7 @@ except ImportError:
26
28
  app = typer.Typer(context_settings={"help_option_names": ["-h", "--help"]})
27
29
 
28
30
  app.add_typer(admin_app, name="admin")
31
+ app.add_typer(chat_app, name="chat")
29
32
  app.add_typer(configure_app, name="configure")
30
33
  app.add_typer(account_app, name="account")
31
34
  app.add_typer(devices_app, name="devices")
@@ -67,7 +70,7 @@ def show_banner():
67
70
  typer.echo("")
68
71
  typer.echo("- Use 'qbraid --version' to see the current version.")
69
72
  typer.echo("")
70
- typer.echo("Reference Docs: https://docs.qbraid.com/cli/api-reference/qbraid")
73
+ rich.print("Reference Docs: https://docs.qbraid.com/cli/api-reference/qbraid")
71
74
 
72
75
 
73
76
  @app.callback(invoke_without_command=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: qbraid-cli
3
- Version: 0.9.0a0
3
+ Version: 0.9.1
4
4
  Summary: Command Line Interface for interacting with all parts of the qBraid platform.
5
5
  Author-email: qBraid Development Team <contact@qbraid.com>
6
6
  License: Proprietary
@@ -29,16 +29,16 @@ Description-Content-Type: text/markdown
29
29
  License-File: LICENSE
30
30
  Requires-Dist: typer>=0.12.1
31
31
  Requires-Dist: rich>=10.11.0
32
- Requires-Dist: qbraid-core>=0.1.28
32
+ Requires-Dist: qbraid-core>=0.1.30
33
+ Provides-Extra: jobs
34
+ Requires-Dist: amazon-braket-sdk>=1.48.1; extra == "jobs"
35
+ Provides-Extra: envs
36
+ Requires-Dist: qbraid-core[environments]; extra == "envs"
33
37
  Provides-Extra: dev
34
38
  Requires-Dist: isort; extra == "dev"
35
39
  Requires-Dist: black; extra == "dev"
36
40
  Requires-Dist: pytest; extra == "dev"
37
41
  Requires-Dist: pytest-cov; extra == "dev"
38
- Provides-Extra: envs
39
- Requires-Dist: qbraid-core[environments]; extra == "envs"
40
- Provides-Extra: jobs
41
- Requires-Dist: amazon-braket-sdk>=1.48.1; extra == "jobs"
42
42
 
43
43
  <img width="full" alt="qbraid_cli" src="https://qbraid-static.s3.amazonaws.com/logos/qbraid-cli-banner.png">
44
44
 
@@ -1,38 +1,40 @@
1
1
  qbraid_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- qbraid_cli/_version.py,sha256=HjY1UzcNtKKrJ8GVdemZ4PKAbhmYJUmCc4zQTJY4W0I,413
2
+ qbraid_cli/_version.py,sha256=_P6tBRUyis5e8UBMut-5M8NVccs2HwAQXTxErAP99SI,411
3
3
  qbraid_cli/exceptions.py,sha256=KjlhYJhSHMVazaNiBjD_Ur06w4sekP8zRsFzBdyIpno,672
4
- qbraid_cli/handlers.py,sha256=3RTG5FHL5GTyDoBUv81x5sLyqwf8nzkcqBi0k1ayoW8,7034
5
- qbraid_cli/main.py,sha256=wjfPLM4FKmvk4Y3xQ7wW12RmRKy9kMIkdVtRlw6Nrbg,2749
4
+ qbraid_cli/handlers.py,sha256=B9H1Qw6yx8izrqp9OGR2TgSJa_mxA8KLXUkX8LB7Feg,7650
5
+ qbraid_cli/main.py,sha256=Xhqbkfi9MtxulrIbEDnBK_gpfHluBGa5YluCIkJuoLg,2839
6
6
  qbraid_cli/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  qbraid_cli/account/__init__.py,sha256=smlpUcVkM3QEbJG0norGM7i71XBJlUGQYByswTfPnmg,181
8
- qbraid_cli/account/app.py,sha256=-dVlAdGG0xKvjzk9248p3EcHnvKamVSmiZBW_xCMGII,1823
8
+ qbraid_cli/account/app.py,sha256=ggvft1Q4d5IIv0lf3adbIkcz0nIYiEriJu91SPyo5_4,1821
9
9
  qbraid_cli/admin/__init__.py,sha256=qcWD5mQEUCtr49mrUpZmk7eGDe0L_Gtc8RwZmzIXSwo,175
10
10
  qbraid_cli/admin/app.py,sha256=NGisg2aouk8qK2oFogwblFTBK0vvTiL_zJYjeanC4x0,1576
11
11
  qbraid_cli/admin/headers.py,sha256=WqpRYp81CQcF5-Afumo_qQrf-5XCfbndBJ6I7vOADKE,7133
12
12
  qbraid_cli/admin/validation.py,sha256=U_8RFWBwRUNPe6LdjNpl-Yz8Br57PLWMoPbpR-jBS-M,979
13
+ qbraid_cli/chat/__init__.py,sha256=0He19OpSsEoyCGxZLMTWey1fKAAls5mHTCFlO5-gl2Y,172
14
+ qbraid_cli/chat/app.py,sha256=QQqwCi3dk-_i5XTe8labQFPN5xttFKoLf7oWIrhlmyQ,2913
13
15
  qbraid_cli/configure/__init__.py,sha256=YaJ74Ztz2vl3eYp8_jVBucWkXscxz7EZEIzr70OfuOM,187
14
16
  qbraid_cli/configure/actions.py,sha256=-BduRmnxvf8JMNonb6VWFtdlHlcHPOPz3Bj5g8kfmBU,3197
15
17
  qbraid_cli/configure/app.py,sha256=1uRe2lkUA4TtYb5b4mbD4LH-cKCbsZGT3Wfk7fpNzX0,2414
16
18
  qbraid_cli/devices/__init__.py,sha256=hiScO-px6jCL5cJj5Hbty55EUfNejTO4bmqUZuS3aqc,181
17
- qbraid_cli/devices/app.py,sha256=3Ly5PPNVhipzbX2h3FrB3fWawLbUcQFcUqv_cZv5eYk,2523
19
+ qbraid_cli/devices/app.py,sha256=K5NBtXgwncn8x0lzZlXuagb_jWCKXBBdhFMm96eDJBM,2521
18
20
  qbraid_cli/devices/validation.py,sha256=YhShyUufgrKnx2XjXOXF-PqFJYklJT9CgeqIwKcNam4,809
19
21
  qbraid_cli/envs/__init__.py,sha256=1-cMvrATsddYxcetPJWxq6bEOqJWMktGdhoZ4qm8euA,172
20
22
  qbraid_cli/envs/activate.py,sha256=VpvVYSfQDlcmlNWJOgkLIQ2p8YXPPLG8Jbl5t8GHUDw,2140
21
- qbraid_cli/envs/app.py,sha256=5bb6OQUgcyCPw0REqEyjFHrjqsuhEn8zCsI3d6abgpI,8455
23
+ qbraid_cli/envs/app.py,sha256=2iJ0Ik39zf_5Kj0hCvkykAdU8ESdUoLodw1-tpcKXyE,8447
22
24
  qbraid_cli/envs/create.py,sha256=xudzkLCNegY34zkXN_Vfl_0zVzg_tW83LcVx9quoWfU,988
23
25
  qbraid_cli/envs/data_handling.py,sha256=Ibnp2yJoUDpivb_sNqi0suYgJZNat_LmM6Ya0Ovez5s,1288
24
26
  qbraid_cli/jobs/__init__.py,sha256=qVLRHYIzP4XHpx_QWP_vCzd3LsCscCORaEx-Vcbx29U,172
25
- qbraid_cli/jobs/app.py,sha256=veyY5aunlPaDYCVmAHmEtaIo_veUVWRXmCB_GBJHEuQ,4918
26
- qbraid_cli/jobs/toggle_braket.py,sha256=lQOG6h39vG3JsRh90LuJ8g_3hNuMSq8jdpRjjBG6SyQ,7446
27
+ qbraid_cli/jobs/app.py,sha256=x4mF8KfP9FWyYKZLG5MkkHFQErgYO4VoYEQbtq7q_-Q,4916
28
+ qbraid_cli/jobs/toggle_braket.py,sha256=3AEu-Z5q4avduB-fJMyMTVTuyZXuA8m-hnvi325wIv4,7444
27
29
  qbraid_cli/jobs/validation.py,sha256=KlkqVH1-vlNCHSayEpxzyXU86_TMN5prGfMFEoyBsFs,2971
28
30
  qbraid_cli/kernels/__init__.py,sha256=jORS9vV17s5laQyq8gSVB18EPBImgEIbMZ1wKC094DA,181
29
31
  qbraid_cli/kernels/app.py,sha256=Sl57U1JXDKWoeMQDSXJRHlKzDYSdKIbV7tSytZXo5PM,2926
30
32
  qbraid_cli/pip/__init__.py,sha256=tJtU0rxn-ODogNh5Y4pp_BgDQXMN-3JY1QGj0OZHwjQ,169
31
33
  qbraid_cli/pip/app.py,sha256=wzvjX5NL37XIFtZ5KvTZ-nj9xwFKt8QLYZ_vGvk3tXo,1440
32
34
  qbraid_cli/pip/hooks.py,sha256=jkIeev3cOd-cmaoJSdSqbmhTYCs6z1we84FMqa3ZoZw,2124
33
- qbraid_cli-0.9.0a0.dist-info/LICENSE,sha256=P1gi-ofB8lmkRt_mxDoJpcgQq9Ckq9WhRAS1oYk-G1s,2506
34
- qbraid_cli-0.9.0a0.dist-info/METADATA,sha256=YM5B8T3TY-xOKLffoclGkb89xsbrGUnB60T-b7ZSono,6787
35
- qbraid_cli-0.9.0a0.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
36
- qbraid_cli-0.9.0a0.dist-info/entry_points.txt,sha256=c5ZJ7NjbxhDqMpou9q5F03_b_KG34HzFDijIDmEIwgQ,47
37
- qbraid_cli-0.9.0a0.dist-info/top_level.txt,sha256=LTYJgeYSCHo9Il8vZu0yIPuGdGyNaIw6iRy6BeoZo8o,11
38
- qbraid_cli-0.9.0a0.dist-info/RECORD,,
35
+ qbraid_cli-0.9.1.dist-info/LICENSE,sha256=P1gi-ofB8lmkRt_mxDoJpcgQq9Ckq9WhRAS1oYk-G1s,2506
36
+ qbraid_cli-0.9.1.dist-info/METADATA,sha256=L2lfHPXbMA5GIsg3b94GxeooGVA502ZsJknonMNJBg0,6785
37
+ qbraid_cli-0.9.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
38
+ qbraid_cli-0.9.1.dist-info/entry_points.txt,sha256=c5ZJ7NjbxhDqMpou9q5F03_b_KG34HzFDijIDmEIwgQ,47
39
+ qbraid_cli-0.9.1.dist-info/top_level.txt,sha256=LTYJgeYSCHo9Il8vZu0yIPuGdGyNaIw6iRy6BeoZo8o,11
40
+ qbraid_cli-0.9.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.3.0)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5