create-tether-app 0.1.0
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.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +729 -0
- package/package.json +59 -0
- package/template/.env.example +18 -0
- package/template/README.md.template +123 -0
- package/template/backend/app/__init__.py.template +5 -0
- package/template/backend/app/main.py +66 -0
- package/template/backend/app/routes/__init__.py +3 -0
- package/template/backend/app/routes/chat.py +151 -0
- package/template/backend/app/routes/health.py +28 -0
- package/template/backend/app/routes/models.py +126 -0
- package/template/backend/app/services/__init__.py +3 -0
- package/template/backend/app/services/llm.py +526 -0
- package/template/backend/pyproject.toml.template +34 -0
- package/template/backend/scripts/build.py +112 -0
- package/template/frontend/App.css +58 -0
- package/template/frontend/App.tsx +62 -0
- package/template/frontend/components/Chat.css +220 -0
- package/template/frontend/components/Chat.tsx +284 -0
- package/template/frontend/components/ChatMessage.css +206 -0
- package/template/frontend/components/ChatMessage.tsx +62 -0
- package/template/frontend/components/ModelStatus.css +62 -0
- package/template/frontend/components/ModelStatus.tsx +103 -0
- package/template/frontend/hooks/useApi.ts +334 -0
- package/template/frontend/index.css +92 -0
- package/template/frontend/main.tsx +10 -0
- package/template/frontend/vite-env.d.ts +1 -0
- package/template/index.html.template +13 -0
- package/template/package.json.template +33 -0
- package/template/postcss.config.js.template +6 -0
- package/template/public/tether.svg +15 -0
- package/template/src-tauri/.cargo/config.toml +66 -0
- package/template/src-tauri/Cargo.lock +4764 -0
- package/template/src-tauri/Cargo.toml +24 -0
- package/template/src-tauri/build.rs +3 -0
- package/template/src-tauri/capabilities/default.json +40 -0
- package/template/src-tauri/icons/128x128.png +0 -0
- package/template/src-tauri/icons/128x128@2x.png +0 -0
- package/template/src-tauri/icons/32x32.png +0 -0
- package/template/src-tauri/icons/icon.icns +0 -0
- package/template/src-tauri/icons/icon.ico +0 -0
- package/template/src-tauri/src/main.rs +65 -0
- package/template/src-tauri/src/sidecar.rs +110 -0
- package/template/src-tauri/tauri.conf.json.template +44 -0
- package/template/tailwind.config.js.template +19 -0
- package/template/tsconfig.json +21 -0
- package/template/tsconfig.node.json +11 -0
- package/template/vite.config.ts +27 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
.message {
|
|
2
|
+
padding: 0.75rem 1rem;
|
|
3
|
+
border-radius: var(--radius);
|
|
4
|
+
max-width: 80%;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.message-user {
|
|
8
|
+
background-color: var(--color-primary);
|
|
9
|
+
color: white;
|
|
10
|
+
align-self: flex-end;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.message-assistant {
|
|
14
|
+
background-color: var(--color-surface);
|
|
15
|
+
border: 1px solid var(--color-border);
|
|
16
|
+
align-self: flex-start;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.message-header {
|
|
20
|
+
display: flex;
|
|
21
|
+
justify-content: space-between;
|
|
22
|
+
align-items: center;
|
|
23
|
+
margin-bottom: 0.25rem;
|
|
24
|
+
font-size: 0.75rem;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.message-role {
|
|
28
|
+
font-weight: 600;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.message-user .message-role {
|
|
32
|
+
color: rgba(255, 255, 255, 0.8);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.message-assistant .message-role {
|
|
36
|
+
color: var(--color-text-muted);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.message-time {
|
|
40
|
+
opacity: 0.6;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.message-content {
|
|
44
|
+
word-break: break-word;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.message-user .message-content {
|
|
48
|
+
white-space: pre-wrap;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Markdown styles for assistant messages */
|
|
52
|
+
.message-assistant .message-content p {
|
|
53
|
+
margin: 0 0 0.5rem 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.message-assistant .message-content p:last-child {
|
|
57
|
+
margin-bottom: 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.message-assistant .message-content code {
|
|
61
|
+
font-family: var(--font-mono, 'SF Mono', Monaco, 'Courier New', monospace);
|
|
62
|
+
font-size: 0.875em;
|
|
63
|
+
background: rgba(0, 0, 0, 0.1);
|
|
64
|
+
padding: 0.125rem 0.25rem;
|
|
65
|
+
border-radius: 3px;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.message-assistant .message-content pre {
|
|
69
|
+
margin: 0.5rem 0;
|
|
70
|
+
padding: 0.75rem;
|
|
71
|
+
background: rgba(0, 0, 0, 0.05);
|
|
72
|
+
border-radius: var(--radius);
|
|
73
|
+
overflow-x: auto;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.message-assistant .message-content pre code {
|
|
77
|
+
background: none;
|
|
78
|
+
padding: 0;
|
|
79
|
+
font-size: 0.8125rem;
|
|
80
|
+
line-height: 1.5;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.message-assistant .message-content ul,
|
|
84
|
+
.message-assistant .message-content ol {
|
|
85
|
+
margin: 0.5rem 0;
|
|
86
|
+
padding-left: 1.5rem;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.message-assistant .message-content li {
|
|
90
|
+
margin: 0.25rem 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.message-assistant .message-content h1,
|
|
94
|
+
.message-assistant .message-content h2,
|
|
95
|
+
.message-assistant .message-content h3 {
|
|
96
|
+
margin: 0.75rem 0 0.5rem 0;
|
|
97
|
+
font-weight: 600;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.message-assistant .message-content h1 {
|
|
101
|
+
font-size: 1.25rem;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.message-assistant .message-content h2 {
|
|
105
|
+
font-size: 1.125rem;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.message-assistant .message-content h3 {
|
|
109
|
+
font-size: 1rem;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.message-assistant .message-content blockquote {
|
|
113
|
+
margin: 0.5rem 0;
|
|
114
|
+
padding-left: 0.75rem;
|
|
115
|
+
border-left: 3px solid var(--color-border);
|
|
116
|
+
color: var(--color-text-muted);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.message-assistant .message-content a {
|
|
120
|
+
color: var(--color-primary);
|
|
121
|
+
text-decoration: underline;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.message-assistant .message-content hr {
|
|
125
|
+
margin: 0.75rem 0;
|
|
126
|
+
border: none;
|
|
127
|
+
border-top: 1px solid var(--color-border);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* Thinking section for thinking models (e.g., Qwen3) */
|
|
131
|
+
.message-thinking {
|
|
132
|
+
margin-bottom: 0.5rem;
|
|
133
|
+
border-radius: 6px;
|
|
134
|
+
background: rgba(147, 51, 234, 0.08);
|
|
135
|
+
border: 1px solid rgba(147, 51, 234, 0.2);
|
|
136
|
+
overflow: hidden;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.thinking-toggle {
|
|
140
|
+
display: flex;
|
|
141
|
+
align-items: center;
|
|
142
|
+
gap: 0.375rem;
|
|
143
|
+
width: 100%;
|
|
144
|
+
padding: 0.5rem 0.75rem;
|
|
145
|
+
background: none;
|
|
146
|
+
border: none;
|
|
147
|
+
color: rgb(147, 51, 234);
|
|
148
|
+
font-size: 0.75rem;
|
|
149
|
+
font-weight: 600;
|
|
150
|
+
cursor: pointer;
|
|
151
|
+
text-align: left;
|
|
152
|
+
transition: background-color 0.15s;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.thinking-toggle:hover {
|
|
156
|
+
background: rgba(147, 51, 234, 0.05);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.thinking-chevron {
|
|
160
|
+
font-size: 0.625rem;
|
|
161
|
+
transition: transform 0.15s;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.thinking-chevron.expanded {
|
|
165
|
+
transform: rotate(0deg);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.thinking-content {
|
|
169
|
+
padding: 0 0.75rem 0.75rem 0.75rem;
|
|
170
|
+
font-size: 0.8125rem;
|
|
171
|
+
color: var(--color-text-muted);
|
|
172
|
+
line-height: 1.5;
|
|
173
|
+
border-top: 1px solid rgba(147, 51, 234, 0.15);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.thinking-content p {
|
|
177
|
+
margin: 0.375rem 0;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.thinking-content p:first-child {
|
|
181
|
+
margin-top: 0.5rem;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.thinking-content p:last-child {
|
|
185
|
+
margin-bottom: 0;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/* Message images */
|
|
189
|
+
.message-images {
|
|
190
|
+
display: flex;
|
|
191
|
+
flex-wrap: wrap;
|
|
192
|
+
gap: 0.5rem;
|
|
193
|
+
margin-bottom: 0.5rem;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.message-image {
|
|
197
|
+
max-width: 200px;
|
|
198
|
+
max-height: 200px;
|
|
199
|
+
border-radius: 6px;
|
|
200
|
+
object-fit: contain;
|
|
201
|
+
cursor: pointer;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.message-image:hover {
|
|
205
|
+
opacity: 0.9;
|
|
206
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import Markdown from "react-markdown";
|
|
3
|
+
import type { ChatMessage as ChatMessageType } from "../hooks/useApi";
|
|
4
|
+
import "./ChatMessage.css";
|
|
5
|
+
|
|
6
|
+
interface ChatMessageProps {
|
|
7
|
+
message: ChatMessageType;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function ChatMessage({ message }: ChatMessageProps) {
|
|
11
|
+
const isUser = message.role === "user";
|
|
12
|
+
const [showThinking, setShowThinking] = useState(false);
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div className={`message ${isUser ? "message-user" : "message-assistant"}`}>
|
|
16
|
+
<div className="message-header">
|
|
17
|
+
<span className="message-role">{isUser ? "You" : "Assistant"}</span>
|
|
18
|
+
{message.timestamp && (
|
|
19
|
+
<span className="message-time">
|
|
20
|
+
{new Date(message.timestamp).toLocaleTimeString()}
|
|
21
|
+
</span>
|
|
22
|
+
)}
|
|
23
|
+
</div>
|
|
24
|
+
{message.images && message.images.length > 0 && (
|
|
25
|
+
<div className="message-images">
|
|
26
|
+
{message.images.map((img, index) => (
|
|
27
|
+
<img
|
|
28
|
+
key={index}
|
|
29
|
+
src={`data:image/jpeg;base64,${img}`}
|
|
30
|
+
alt={`Attached ${index + 1}`}
|
|
31
|
+
className="message-image"
|
|
32
|
+
/>
|
|
33
|
+
))}
|
|
34
|
+
</div>
|
|
35
|
+
)}
|
|
36
|
+
{message.thinking && (
|
|
37
|
+
<div className="message-thinking">
|
|
38
|
+
<button
|
|
39
|
+
className="thinking-toggle"
|
|
40
|
+
onClick={() => setShowThinking(!showThinking)}
|
|
41
|
+
aria-expanded={showThinking}
|
|
42
|
+
>
|
|
43
|
+
<span
|
|
44
|
+
className={`thinking-chevron ${showThinking ? "expanded" : ""}`}
|
|
45
|
+
>
|
|
46
|
+
{showThinking ? "\u25BC" : "\u25B6"}
|
|
47
|
+
</span>
|
|
48
|
+
Thinking
|
|
49
|
+
</button>
|
|
50
|
+
{showThinking && (
|
|
51
|
+
<div className="thinking-content">
|
|
52
|
+
<Markdown>{message.thinking}</Markdown>
|
|
53
|
+
</div>
|
|
54
|
+
)}
|
|
55
|
+
</div>
|
|
56
|
+
)}
|
|
57
|
+
<div className="message-content">
|
|
58
|
+
{isUser ? message.content : <Markdown>{message.content}</Markdown>}
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
.model-status {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: 0.5rem;
|
|
5
|
+
font-size: 0.875rem;
|
|
6
|
+
color: var(--color-text-muted);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.status-indicator {
|
|
10
|
+
width: 8px;
|
|
11
|
+
height: 8px;
|
|
12
|
+
border-radius: 50%;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.status-text {
|
|
16
|
+
font-weight: 500;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.model-name {
|
|
20
|
+
font-family: var(--font-mono, monospace);
|
|
21
|
+
font-size: 0.75rem;
|
|
22
|
+
background: var(--color-surface, rgba(0, 0, 0, 0.1));
|
|
23
|
+
padding: 0.125rem 0.375rem;
|
|
24
|
+
border-radius: 4px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.backend-type {
|
|
28
|
+
font-size: 0.75rem;
|
|
29
|
+
opacity: 0.7;
|
|
30
|
+
text-transform: capitalize;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.model-select {
|
|
34
|
+
font-family: var(--font-mono, monospace);
|
|
35
|
+
font-size: 0.75rem;
|
|
36
|
+
background: var(--color-surface, #f3f4f6);
|
|
37
|
+
border: 1px solid var(--color-border, #e5e7eb);
|
|
38
|
+
padding: 0.25rem 1.5rem 0.25rem 0.5rem;
|
|
39
|
+
border-radius: 6px;
|
|
40
|
+
color: inherit;
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
appearance: none;
|
|
43
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
|
|
44
|
+
background-repeat: no-repeat;
|
|
45
|
+
background-position: right 0.35rem center;
|
|
46
|
+
transition: border-color 0.15s, box-shadow 0.15s;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.model-select:hover:not(:disabled) {
|
|
50
|
+
border-color: var(--color-primary, #3b82f6);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.model-select:focus {
|
|
54
|
+
outline: none;
|
|
55
|
+
border-color: var(--color-primary, #3b82f6);
|
|
56
|
+
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.model-select:disabled {
|
|
60
|
+
opacity: 0.5;
|
|
61
|
+
cursor: not-allowed;
|
|
62
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import type {
|
|
3
|
+
ConnectionStatus,
|
|
4
|
+
HealthResponse,
|
|
5
|
+
ModelsResponse,
|
|
6
|
+
SwitchModelResponse,
|
|
7
|
+
} from "../hooks/useApi";
|
|
8
|
+
import "./ModelStatus.css";
|
|
9
|
+
|
|
10
|
+
interface ModelStatusProps {
|
|
11
|
+
status: ConnectionStatus;
|
|
12
|
+
health: HealthResponse | null;
|
|
13
|
+
modelInfo: ModelsResponse | null;
|
|
14
|
+
onModelChange?: (model: string) => Promise<SwitchModelResponse>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function ModelStatus({
|
|
18
|
+
status,
|
|
19
|
+
health,
|
|
20
|
+
modelInfo,
|
|
21
|
+
onModelChange,
|
|
22
|
+
}: ModelStatusProps) {
|
|
23
|
+
const [isSwitching, setIsSwitching] = useState(false);
|
|
24
|
+
|
|
25
|
+
const getStatusColor = () => {
|
|
26
|
+
switch (status) {
|
|
27
|
+
case "connected":
|
|
28
|
+
return "var(--color-success)";
|
|
29
|
+
case "connecting":
|
|
30
|
+
return "var(--color-warning)";
|
|
31
|
+
case "error":
|
|
32
|
+
case "disconnected":
|
|
33
|
+
return "var(--color-error)";
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const getStatusText = () => {
|
|
38
|
+
if (isSwitching) return "Switching...";
|
|
39
|
+
switch (status) {
|
|
40
|
+
case "connected":
|
|
41
|
+
return health?.model_loaded ? "Ready" : "Connected";
|
|
42
|
+
case "connecting":
|
|
43
|
+
return "Connecting...";
|
|
44
|
+
case "error":
|
|
45
|
+
return "Error";
|
|
46
|
+
case "disconnected":
|
|
47
|
+
return "Disconnected";
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const formatBackend = (backend: string) => {
|
|
52
|
+
return backend.charAt(0).toUpperCase() + backend.slice(1);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const handleModelChange = async (
|
|
56
|
+
event: React.ChangeEvent<HTMLSelectElement>,
|
|
57
|
+
) => {
|
|
58
|
+
const newModel = event.target.value;
|
|
59
|
+
if (!onModelChange || newModel === modelInfo?.current_model) return;
|
|
60
|
+
|
|
61
|
+
setIsSwitching(true);
|
|
62
|
+
try {
|
|
63
|
+
await onModelChange(newModel);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.error("Failed to switch model:", error);
|
|
66
|
+
} finally {
|
|
67
|
+
setIsSwitching(false);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const hasMultipleModels = modelInfo?.models && modelInfo.models.length > 1;
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<div className="model-status">
|
|
75
|
+
<span
|
|
76
|
+
className="status-indicator"
|
|
77
|
+
style={{ backgroundColor: getStatusColor() }}
|
|
78
|
+
/>
|
|
79
|
+
<span className="status-text">{getStatusText()}</span>
|
|
80
|
+
{modelInfo && hasMultipleModels && onModelChange ? (
|
|
81
|
+
<select
|
|
82
|
+
className="model-select"
|
|
83
|
+
value={modelInfo.current_model || ""}
|
|
84
|
+
onChange={handleModelChange}
|
|
85
|
+
disabled={isSwitching || status !== "connected"}
|
|
86
|
+
>
|
|
87
|
+
{modelInfo.models.map((model) => (
|
|
88
|
+
<option key={model} value={model}>
|
|
89
|
+
{model}
|
|
90
|
+
</option>
|
|
91
|
+
))}
|
|
92
|
+
</select>
|
|
93
|
+
) : modelInfo?.current_model ? (
|
|
94
|
+
<span className="model-name" title={`Backend: ${modelInfo.backend}`}>
|
|
95
|
+
{modelInfo.current_model}
|
|
96
|
+
</span>
|
|
97
|
+
) : null}
|
|
98
|
+
{modelInfo?.backend && (
|
|
99
|
+
<span className="backend-type">{formatBackend(modelInfo.backend)}</span>
|
|
100
|
+
)}
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
}
|