This commit is contained in:
Mckay Wrigley
2023-03-22 12:55:20 -06:00
parent 1ebae96dca
commit ec20db24de
6 changed files with 21 additions and 10 deletions
+1
View File
@@ -11,6 +11,7 @@
# next.js # next.js
/.next/ /.next/
/out/ /out/
dist
# production # production
/build /build
+1 -1
View File
@@ -4,7 +4,7 @@
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",
"build": "next build", "build": "next build && next export -o dist",
"export": "next export", "export": "next export",
"start": "next start", "start": "next start",
"tauri": "tauri", "tauri": "tauri",
+5
View File
@@ -9,6 +9,7 @@ const handler = async (req: Request): Promise<Response> => {
const { key } = (await req.json()) as { const { key } = (await req.json()) as {
key: string; key: string;
}; };
console.log("key", key);
const response = await fetch("https://api.openai.com/v1/models", { const response = await fetch("https://api.openai.com/v1/models", {
headers: { headers: {
@@ -23,6 +24,8 @@ const handler = async (req: Request): Promise<Response> => {
const json = await response.json(); const json = await response.json();
console.log("json", json);
const models: OpenAIModel[] = json.data const models: OpenAIModel[] = json.data
.map((model: any) => { .map((model: any) => {
for (const [key, value] of Object.entries(OpenAIModelID)) { for (const [key, value] of Object.entries(OpenAIModelID)) {
@@ -36,6 +39,8 @@ const handler = async (req: Request): Promise<Response> => {
}) })
.filter(Boolean); .filter(Boolean);
console.log("models", models);
return new Response(JSON.stringify(models), { status: 200 }); return new Response(JSON.stringify(models), { status: 200 });
} catch (error) { } catch (error) {
console.error(error); console.error(error);
+4 -4
View File
@@ -155,6 +155,7 @@ export default function Home() {
}; };
const fetchModels = async (key: string) => { const fetchModels = async (key: string) => {
console.log(key);
const response = await fetch("/api/models", { const response = await fetch("/api/models", {
method: "POST", method: "POST",
headers: { headers: {
@@ -170,6 +171,8 @@ export default function Home() {
return; return;
} }
console.log(response.json());
const data = await response.json(); const data = await response.json();
if (!data) { if (!data) {
@@ -189,6 +192,7 @@ export default function Home() {
const handleApiKeyChange = (apiKey: string) => { const handleApiKeyChange = (apiKey: string) => {
setApiKey(apiKey); setApiKey(apiKey);
localStorage.setItem("apiKey", apiKey); localStorage.setItem("apiKey", apiKey);
fetchModels(apiKey);
}; };
const handleExportConversations = () => { const handleExportConversations = () => {
@@ -280,10 +284,6 @@ export default function Home() {
} }
}, [selectedConversation]); }, [selectedConversation]);
useEffect(() => {
fetchModels(apiKey);
}, [apiKey]);
useEffect(() => { useEffect(() => {
const theme = localStorage.getItem("theme"); const theme = localStorage.getItem("theme");
if (theme) { if (theme) {
+5 -1
View File
@@ -17,7 +17,7 @@ tauri-build = { version = "1.2.1", features = [] }
[dependencies] [dependencies]
serde_json = "1.0" serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] } 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] [features]
# by default Tauri runs in production mode # 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 # this feature is used for production builds where `devPath` points to the filesystem
# DO NOT remove this # DO NOT remove this
custom-protocol = [ "tauri/custom-protocol" ] custom-protocol = [ "tauri/custom-protocol" ]
[profile.release.package.wry]
debug = true
debug-assertions = true
+5 -4
View File
@@ -1,9 +1,9 @@
{ {
"build": { "build": {
"beforeBuildCommand": "npm run build && npm run export", "beforeBuildCommand": "npm run build",
"beforeDevCommand": "npm run dev", "beforeDevCommand": "npm run dev",
"devPath": "http://localhost:3000", "devPath": "http://localhost:3000",
"distDir": "../out" "distDir": "../dist"
}, },
"package": { "package": {
"productName": "Chatbot UI", "productName": "Chatbot UI",
@@ -14,7 +14,7 @@
"all": true, "all": true,
"http": { "http": {
"all": true, "all": true,
"scope": ["https://**"] "scope": ["tauri://localhost/api/models"]
} }
}, },
"bundle": { "bundle": {
@@ -26,7 +26,7 @@
}, },
"externalBin": [], "externalBin": [],
"icon": ["icons/32x32.png", "icons/128x128.png", "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico"], "icon": ["icons/32x32.png", "icons/128x128.png", "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico"],
"identifier": "chabotui", "identifier": "com.mckaywrigley.chatbotui",
"longDescription": "", "longDescription": "",
"macOS": { "macOS": {
"entitlements": null, "entitlements": null,
@@ -50,6 +50,7 @@
"updater": { "updater": {
"active": false "active": false
}, },
"macOSPrivateApi": true,
"windows": [ "windows": [
{ {
"fullscreen": false, "fullscreen": false,