made types optional and, workbench get repo fix
Browse files- app/components/chat/BaseChat.tsx +18 -14
- app/lib/stores/workbench.ts +4 -3
app/components/chat/BaseChat.tsx
CHANGED
@@ -24,16 +24,16 @@ const EXAMPLE_PROMPTS = [
|
|
24 |
{ text: 'How do I center a div?' },
|
25 |
];
|
26 |
|
27 |
-
const providerList = [...new Set(MODEL_LIST.map((model) => model.provider))]
|
28 |
|
29 |
const ModelSelector = ({ model, setModel, provider, setProvider, modelList, providerList }) => {
|
30 |
return (
|
31 |
<div className="mb-2 flex gap-2">
|
32 |
-
<select
|
33 |
value={provider}
|
34 |
onChange={(e) => {
|
35 |
setProvider(e.target.value);
|
36 |
-
const firstModel = [...modelList].find(m => m.provider == e.target.value);
|
37 |
setModel(firstModel ? firstModel.name : '');
|
38 |
}}
|
39 |
className="flex-1 p-2 rounded-lg border border-bolt-elements-borderColor bg-bolt-elements-prompt-background text-bolt-elements-textPrimary focus:outline-none focus:ring-2 focus:ring-bolt-elements-focus transition-all"
|
@@ -58,11 +58,13 @@ const ModelSelector = ({ model, setModel, provider, setProvider, modelList, prov
|
|
58 |
onChange={(e) => setModel(e.target.value)}
|
59 |
className="flex-1 p-2 rounded-lg border border-bolt-elements-borderColor bg-bolt-elements-prompt-background text-bolt-elements-textPrimary focus:outline-none focus:ring-2 focus:ring-bolt-elements-focus transition-all"
|
60 |
>
|
61 |
-
{[...modelList]
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
|
|
66 |
</select>
|
67 |
</div>
|
68 |
);
|
@@ -81,10 +83,10 @@ interface BaseChatProps {
|
|
81 |
enhancingPrompt?: boolean;
|
82 |
promptEnhanced?: boolean;
|
83 |
input?: string;
|
84 |
-
model
|
85 |
-
setModel
|
86 |
provider: string;
|
87 |
-
setProvider
|
88 |
handleStop?: () => void;
|
89 |
sendMessage?: (event: React.UIEvent, messageInput?: string) => void;
|
90 |
handleInputChange?: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
@@ -144,7 +146,7 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
|
|
144 |
expires: 30, // 30 days
|
145 |
secure: true, // Only send over HTTPS
|
146 |
sameSite: 'strict', // Protect against CSRF
|
147 |
-
path: '/' // Accessible across the site
|
148 |
});
|
149 |
} catch (error) {
|
150 |
console.error('Error saving API keys to cookies:', error);
|
@@ -281,7 +283,9 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
|
|
281 |
</div>
|
282 |
{input.length > 3 ? (
|
283 |
<div className="text-xs text-bolt-elements-textTertiary">
|
284 |
-
Use <kbd className="kdb px-1.5 py-0.5 rounded bg-bolt-elements-background-depth-2">Shift</kbd> +
|
|
|
|
|
285 |
</div>
|
286 |
) : null}
|
287 |
</div>
|
@@ -315,4 +319,4 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
|
|
315 |
</div>
|
316 |
);
|
317 |
},
|
318 |
-
);
|
|
|
24 |
{ text: 'How do I center a div?' },
|
25 |
];
|
26 |
|
27 |
+
const providerList = [...new Set(MODEL_LIST.map((model) => model.provider))];
|
28 |
|
29 |
const ModelSelector = ({ model, setModel, provider, setProvider, modelList, providerList }) => {
|
30 |
return (
|
31 |
<div className="mb-2 flex gap-2">
|
32 |
+
<select
|
33 |
value={provider}
|
34 |
onChange={(e) => {
|
35 |
setProvider(e.target.value);
|
36 |
+
const firstModel = [...modelList].find((m) => m.provider == e.target.value);
|
37 |
setModel(firstModel ? firstModel.name : '');
|
38 |
}}
|
39 |
className="flex-1 p-2 rounded-lg border border-bolt-elements-borderColor bg-bolt-elements-prompt-background text-bolt-elements-textPrimary focus:outline-none focus:ring-2 focus:ring-bolt-elements-focus transition-all"
|
|
|
58 |
onChange={(e) => setModel(e.target.value)}
|
59 |
className="flex-1 p-2 rounded-lg border border-bolt-elements-borderColor bg-bolt-elements-prompt-background text-bolt-elements-textPrimary focus:outline-none focus:ring-2 focus:ring-bolt-elements-focus transition-all"
|
60 |
>
|
61 |
+
{[...modelList]
|
62 |
+
.filter((e) => e.provider == provider && e.name)
|
63 |
+
.map((modelOption) => (
|
64 |
+
<option key={modelOption.name} value={modelOption.name}>
|
65 |
+
{modelOption.label}
|
66 |
+
</option>
|
67 |
+
))}
|
68 |
</select>
|
69 |
</div>
|
70 |
);
|
|
|
83 |
enhancingPrompt?: boolean;
|
84 |
promptEnhanced?: boolean;
|
85 |
input?: string;
|
86 |
+
model?: string;
|
87 |
+
setModel?: (model: string) => void;
|
88 |
provider: string;
|
89 |
+
setProvider?: (provider: string) => void;
|
90 |
handleStop?: () => void;
|
91 |
sendMessage?: (event: React.UIEvent, messageInput?: string) => void;
|
92 |
handleInputChange?: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
|
146 |
expires: 30, // 30 days
|
147 |
secure: true, // Only send over HTTPS
|
148 |
sameSite: 'strict', // Protect against CSRF
|
149 |
+
path: '/', // Accessible across the site
|
150 |
});
|
151 |
} catch (error) {
|
152 |
console.error('Error saving API keys to cookies:', error);
|
|
|
283 |
</div>
|
284 |
{input.length > 3 ? (
|
285 |
<div className="text-xs text-bolt-elements-textTertiary">
|
286 |
+
Use <kbd className="kdb px-1.5 py-0.5 rounded bg-bolt-elements-background-depth-2">Shift</kbd> +{' '}
|
287 |
+
<kbd className="kdb px-1.5 py-0.5 rounded bg-bolt-elements-background-depth-2">Return</kbd> for
|
288 |
+
a new line
|
289 |
</div>
|
290 |
) : null}
|
291 |
</div>
|
|
|
319 |
</div>
|
320 |
);
|
321 |
},
|
322 |
+
);
|
app/lib/stores/workbench.ts
CHANGED
@@ -11,7 +11,7 @@ import { PreviewsStore } from './previews';
|
|
11 |
import { TerminalStore } from './terminal';
|
12 |
import JSZip from 'jszip';
|
13 |
import { saveAs } from 'file-saver';
|
14 |
-
import { Octokit } from "@octokit/rest";
|
15 |
import * as nodePath from 'node:path';
|
16 |
import type { WebContainerProcess } from '@webcontainer/api';
|
17 |
|
@@ -382,9 +382,10 @@ export class WorkbenchStore {
|
|
382 |
const octokit = new Octokit({ auth: githubToken });
|
383 |
|
384 |
// Check if the repository already exists before creating it
|
385 |
-
let repo
|
386 |
try {
|
387 |
-
|
|
|
388 |
} catch (error) {
|
389 |
if (error instanceof Error && 'status' in error && error.status === 404) {
|
390 |
// Repository doesn't exist, so create a new one
|
|
|
11 |
import { TerminalStore } from './terminal';
|
12 |
import JSZip from 'jszip';
|
13 |
import { saveAs } from 'file-saver';
|
14 |
+
import { Octokit, type RestEndpointMethodTypes } from "@octokit/rest";
|
15 |
import * as nodePath from 'node:path';
|
16 |
import type { WebContainerProcess } from '@webcontainer/api';
|
17 |
|
|
|
382 |
const octokit = new Octokit({ auth: githubToken });
|
383 |
|
384 |
// Check if the repository already exists before creating it
|
385 |
+
let repo: RestEndpointMethodTypes["repos"]["get"]["response"]['data']
|
386 |
try {
|
387 |
+
let resp = await octokit.repos.get({ owner: owner, repo: repoName });
|
388 |
+
repo = resp.data
|
389 |
} catch (error) {
|
390 |
if (error instanceof Error && 'status' in error && error.status === 404) {
|
391 |
// Repository doesn't exist, so create a new one
|