diff --git a/.gitignore b/.gitignore index b167e2d..6f37fcb 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ # next.js /.next/ /out/ +dist # production /build diff --git a/package.json b/package.json index 3a55032..1670115 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "dev": "next dev", - "build": "next build", + "build": "next build && next export -o dist", "export": "next export", "start": "next start", "tauri": "tauri", diff --git a/pages/api/models.ts b/pages/api/models.ts index 433b7f7..2304c1f 100644 --- a/pages/api/models.ts +++ b/pages/api/models.ts @@ -9,6 +9,7 @@ const handler = async (req: Request): Promise => { const { key } = (await req.json()) as { key: string; }; + console.log("key", key); const response = await fetch("https://api.openai.com/v1/models", { headers: { @@ -23,6 +24,8 @@ const handler = async (req: Request): Promise => { const json = await response.json(); + console.log("json", json); + const models: OpenAIModel[] = json.data .map((model: any) => { for (const [key, value] of Object.entries(OpenAIModelID)) { @@ -36,6 +39,8 @@ const handler = async (req: Request): Promise => { }) .filter(Boolean); + console.log("models", models); + return new Response(JSON.stringify(models), { status: 200 }); } catch (error) { console.error(error); diff --git a/pages/index.tsx b/pages/index.tsx index e846502..7d0bfde 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -155,6 +155,7 @@ export default function Home() { }; const fetchModels = async (key: string) => { + console.log(key); const response = await fetch("/api/models", { method: "POST", headers: { @@ -170,6 +171,8 @@ export default function Home() { return; } + console.log(response.json()); + const data = await response.json(); if (!data) { @@ -189,6 +192,7 @@ export default function Home() { const handleApiKeyChange = (apiKey: string) => { setApiKey(apiKey); localStorage.setItem("apiKey", apiKey); + fetchModels(apiKey); }; const handleExportConversations = () => { @@ -280,10 +284,6 @@ export default function Home() { } }, [selectedConversation]); - useEffect(() => { - fetchModels(apiKey); - }, [apiKey]); - useEffect(() => { const theme = localStorage.getItem("theme"); if (theme) { diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index a40cce2..0abf9a9 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -17,7 +17,7 @@ tauri-build = { version = "1.2.1", features = [] } [dependencies] serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } -tauri = { version = "1.2.4", features = ["api-all"] } +tauri = { version = "1.2.4", features = ["api-all", "macos-private-api"] } [features] # by default Tauri runs in production mode @@ -26,3 +26,7 @@ default = [ "custom-protocol" ] # this feature is used for production builds where `devPath` points to the filesystem # DO NOT remove this custom-protocol = [ "tauri/custom-protocol" ] + +[profile.release.package.wry] +debug = true +debug-assertions = true diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index c2a89a8..1aad0ca 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,9 +1,9 @@ { "build": { - "beforeBuildCommand": "npm run build && npm run export", + "beforeBuildCommand": "npm run build", "beforeDevCommand": "npm run dev", "devPath": "http://localhost:3000", - "distDir": "../out" + "distDir": "../dist" }, "package": { "productName": "Chatbot UI", @@ -14,7 +14,7 @@ "all": true, "http": { "all": true, - "scope": ["https://**"] + "scope": ["tauri://localhost/api/models"] } }, "bundle": { @@ -26,7 +26,7 @@ }, "externalBin": [], "icon": ["icons/32x32.png", "icons/128x128.png", "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico"], - "identifier": "chabotui", + "identifier": "com.mckaywrigley.chatbotui", "longDescription": "", "macOS": { "entitlements": null, @@ -50,6 +50,7 @@ "updater": { "active": false }, + "macOSPrivateApi": true, "windows": [ { "fullscreen": false,