deepparallel 0.2.0__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.
@@ -0,0 +1,211 @@
1
+ """Compact Rich UI for the DeepParallel CLI.
2
+
3
+ Brand-forward: leads with "DeepParallel" and attributes Crowe Logic. Keeps
4
+ the underlying model and Azure/Foundry transport internals out of the surface.
5
+
6
+ Identity accent stays cyan (DP_ACCENT); the glyph alphabet, gutter layout, and
7
+ status colors follow the Crowe Logic CLI family patterns.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ from rich import box
13
+ from rich.console import Console, Group
14
+ from rich.markdown import Markdown
15
+ from rich.padding import Padding
16
+ from rich.panel import Panel
17
+ from rich.text import Text
18
+
19
+ console = Console()
20
+
21
+ DP_ACCENT = "bright_cyan"
22
+ CROWE_ACCENT = "bright_green"
23
+ DIM = "grey50"
24
+
25
+ GREEN_HEX = "#6fbf73"
26
+ RED_HEX = "#bf6f6f"
27
+ AMBER_HEX = "#d4a645"
28
+ BLUE_HEX = "#8fa4bf"
29
+ WHITE_HEX = "#ffffff"
30
+
31
+ MARK = "◆"
32
+ RULE = "─"
33
+ DOT = "·"
34
+ BAR = "│"
35
+ CHECK = "✓"
36
+ CROSS = "✗"
37
+ ARROW = "›"
38
+ GUTTER = 2
39
+ TRANSCRIPT_MAX_WIDTH = 96
40
+
41
+
42
+ def welcome(backend_label: str) -> None:
43
+ title = Text("DeepParallel", style=f"bold {DP_ACCENT}")
44
+ body = Text()
45
+ body.append("served via ", style=DIM)
46
+ body.append("Crowe Logic\n", style=f"bold {CROWE_ACCENT}")
47
+ body.append("Backend: ", style=DIM)
48
+ body.append(backend_label, style="white")
49
+ body.append("\n\nType your question. ", style=DIM)
50
+ body.append("/help", style="bold")
51
+ body.append(" for commands, ", style=DIM)
52
+ body.append("/quit", style="bold")
53
+ body.append(" to exit.", style=DIM)
54
+ console.print(Panel(body, title=title, border_style=DP_ACCENT, box=box.ROUNDED))
55
+
56
+
57
+ def user_prefix() -> str:
58
+ return f"[bold {CROWE_ACCENT}]you[/] "
59
+
60
+
61
+ def model_prefix() -> str:
62
+ return f"[bold {DP_ACCENT}]DeepParallel[/] "
63
+
64
+
65
+ def thinking(text: str) -> None:
66
+ console.print(f"[{DIM}]{text}[/]", end="", soft_wrap=True, highlight=False)
67
+
68
+
69
+ def info(msg: str) -> None:
70
+ console.print(f"[{DIM}]{msg}[/]")
71
+
72
+
73
+ def error(msg: str) -> None:
74
+ console.print(f"[bold red]error[/] {msg}")
75
+
76
+
77
+ def attribution_footer() -> None:
78
+ console.print(
79
+ f"[{DIM}]DeepParallel - served via Crowe Logic infrastructure. https://crowelogic.com[/]"
80
+ )
81
+
82
+
83
+ def preview_tool_args(args: str, limit: int = 84) -> str:
84
+ """Compact a tool argument/result string to a single truncated line."""
85
+ s = " ".join(str(args).split())
86
+ if len(s) > limit:
87
+ return s[:limit] + "..."
88
+ return s
89
+
90
+
91
+ def _gutter(renderable):
92
+ return Padding(renderable, (0, 0, 0, GUTTER))
93
+
94
+
95
+ def render_tool_card(
96
+ console: Console,
97
+ name: str,
98
+ args: str,
99
+ status: str,
100
+ result: str = "",
101
+ duration_ms: int = 0,
102
+ ) -> None:
103
+ """Render a tool call as a running line, or a done/failed panel."""
104
+ if status == "running":
105
+ line = Text()
106
+ line.append(f"{ARROW} ", style=DP_ACCENT)
107
+ line.append("ACTION ", style=AMBER_HEX)
108
+ line.append(name, style=f"bold {DP_ACCENT}")
109
+ if args:
110
+ line.append(" " + preview_tool_args(args), style=DIM)
111
+ console.print(_gutter(line))
112
+ return
113
+
114
+ ok = status == "ok"
115
+ glyph = CHECK if ok else CROSS
116
+ accent = GREEN_HEX if ok else RED_HEX
117
+ header = Text()
118
+ header.append(f"{glyph} ", style=accent)
119
+ header.append(name, style=f"bold {DP_ACCENT}")
120
+ header.append(f" {DOT} {duration_ms / 1000:.1f}s", style=DIM)
121
+ parts = [header]
122
+ if args:
123
+ parts.append(Text(preview_tool_args(args), style=DIM))
124
+ if result:
125
+ parts.append(Text(preview_tool_args(result, limit=200), style=WHITE_HEX))
126
+ group = Group(*parts) if len(parts) > 1 else header
127
+ console.print(_gutter(Panel(group, border_style=accent, box=box.ROUNDED)))
128
+
129
+
130
+ def render_error(console: Console, title: str, detail: str = "") -> None:
131
+ """Render a red error block with an optional detail body."""
132
+ header = Text()
133
+ header.append(f"{CROSS} ", style=RED_HEX)
134
+ header.append(title, style=f"bold {RED_HEX}")
135
+ group = Group(header, Text(detail, style=DIM)) if detail else header
136
+ console.print(_gutter(Panel(group, border_style=RED_HEX, box=box.ROUNDED)))
137
+
138
+
139
+ def render_confirm_body(console: Console, action_title: str, detail: str) -> None:
140
+ """Render the confirmation panel (title + detail + y/n hint). The y/n read
141
+ happens in the renderer, not here, so this stays pure and testable."""
142
+ body = Text()
143
+ body.append(action_title + "\n", style=f"bold {AMBER_HEX}")
144
+ for line in detail.splitlines():
145
+ body.append(line + "\n", style=DIM)
146
+ body.append(f"{ARROW} approve? [y/n]", style=AMBER_HEX)
147
+ console.print(_gutter(Panel(body, border_style=AMBER_HEX, box=box.ROUNDED)))
148
+
149
+
150
+ def build_transcript_markdown(console: Console, text: str, title: str = "answer"):
151
+ """Build a bordered markdown panel for an answer block."""
152
+ return _gutter(
153
+ Panel(
154
+ Markdown(text or ""),
155
+ title=Text(f"{MARK} {title}", style=DP_ACCENT),
156
+ title_align="left",
157
+ border_style=DP_ACCENT,
158
+ box=box.ROUNDED,
159
+ )
160
+ )
161
+
162
+
163
+ _WORDMARK = (
164
+ "████ █████ █████ ████ ████ █████ ████ █████ █ █ █████ █ \n"
165
+ "█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ \n"
166
+ "█ █ ████ ████ ████ ████ █████ ████ █████ █ █ ████ █ \n"
167
+ "█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ \n"
168
+ "████ █████ █████ █ █ █ █ █ █ █ █ █████ █████ █████ █████"
169
+ )
170
+
171
+
172
+ def wordmark_lines() -> list[str]:
173
+ """The full DEEPPARALLEL block-letter banner, one string per row.
174
+
175
+ The D, both P stems, and the parallel 'll' share a left vertical stroke,
176
+ so the letters align into a rhythm of parallel vertical bars - the logo
177
+ performs the brand (parallel models, one verdict).
178
+ """
179
+ return _WORDMARK.split("\n")
180
+
181
+
182
+ def status_text(
183
+ *, version: str, tool_count: int, fusion_modes: tuple[str, ...], backend_label: str
184
+ ):
185
+ """Build the intro status + tips block shown under the wordmark."""
186
+ fusion = " · ".join(fusion_modes) if fusion_modes else "off"
187
+ body = Text()
188
+ body.append("DeepParallel", style=f"bold {DP_ACCENT}")
189
+ body.append(f" {DOT} v{version} {DOT} ", style=DIM)
190
+ body.append("served via Crowe Logic\n", style=f"bold {CROWE_ACCENT}")
191
+ body.append(f"{tool_count} tools", style=WHITE_HEX)
192
+ body.append(f" {DOT} fusion: {fusion}\n", style=DIM)
193
+ body.append("Backend: ", style=DIM)
194
+ body.append(f"{backend_label}\n\n", style="white")
195
+ body.append("/help", style="bold")
196
+ body.append(" /tools /fast //deep //fuse ", style=DIM)
197
+ body.append("/quit", style="bold")
198
+ return _gutter(body)
199
+
200
+
201
+ def build_reasoning_panel(console: Console, text: str):
202
+ """Build a dim reasoning panel, visually distinct from the answer."""
203
+ return _gutter(
204
+ Panel(
205
+ Text(text or "", style=DIM),
206
+ title=Text(f"{MARK} reasoning", style=DIM),
207
+ title_align="left",
208
+ border_style=DIM,
209
+ box=box.ROUNDED,
210
+ )
211
+ )