From 013e9dceaf14890c0f0b70bf523b7ac60d46b89a Mon Sep 17 00:00:00 2001 From: Max Sveshnikov Date: Mon, 18 Mar 2024 09:11:34 +0100 Subject: [PATCH] UI --- public/index.html | 1 + server/index.js | 7 ++- server/paint.js | 119 ++++++++++++++++++++++++++++++++++++++++++++++ src/App.js | 12 ++++- src/index.js | 10 ++-- src/theme.js | 13 +++-- 6 files changed, 148 insertions(+), 14 deletions(-) create mode 100644 server/paint.js diff --git a/public/index.html b/public/index.html index 087cbf25..00f86301 100644 --- a/public/index.html +++ b/public/index.html @@ -8,6 +8,7 @@ + Allchat diff --git a/server/index.js b/server/index.js index a1db2e39..b80c7aff 100644 --- a/server/index.js +++ b/server/index.js @@ -4,6 +4,7 @@ import morgan from "morgan"; import rateLimit from "express-rate-limit"; import { getTextGemini } from "./gemini.js"; import { getImageTitan } from "./aws.js"; +import hasPaintWord from "./paint.js"; const MAX_CONTEXT_LENGTH = 4000; @@ -33,7 +34,7 @@ app.post("/interact", async (req, res) => { const textResponse = await getTextGemini(contextPrompt, temperature); userInput = userInput?.toLowerCase(); let imageResponse; - if (userInput.includes("paint") || userInput.includes("draw") || userInput.includes("generate")) { + if (hasPaintWord(userInput)) { imageResponse = await getImageTitan(userInput + textResponse?.trim()?.substr(0, 200)); } @@ -46,6 +47,8 @@ app.post("/interact", async (req, res) => { } }); -app.listen(5000); +app.listen(5000, () => { + console.log(`🚀 Server started on port 5000`); +}); process.env["GOOGLE_APPLICATION_CREDENTIALS"] = "./google.json"; diff --git a/server/paint.js b/server/paint.js new file mode 100644 index 00000000..cba6346c --- /dev/null +++ b/server/paint.js @@ -0,0 +1,119 @@ +const paintingWords = [ + // English + "paint", + "painting", + "draw", + "drawing", + "brush", + "canvas", + "color", + "palette", + "sketch", + "art", + + // Mandarin Chinese + "画", + "绘画", + "油画", + "水彩", + "素描", + "画笔", + "画布", + "颜色", + "调色板", + "艺术", + + // Hindi + "चित्र", + "चित्रकारी", + "रेखाचित्र", + "कैनवास", + "रंग", + "ब्रश", + "पैलेट", + "कला", + + // Spanish + "pintar", + "pintura", + "dibujar", + "dibujo", + "pincel", + "lienzo", + "color", + "paleta", + "boceto", + "arte", + + // Arabic + "رسم", + "لوحة", + "لون", + "فرشاة", + "قماش", + "فن", + + // Bengali + "আঁকা", + "চিত্রকর্ম", + "রেখাচিত্র", + "ক্যানভাস", + "রঙ", + "ব্রাশ", + "প্যালেট", + "শিল্প", + + // Russian + "рисовать", + "картина", + "живопись", + "рисунок", + "кисть", + "холст", + "цвет", + "палитра", + "эскиз", + "искусство", + + // Portuguese + "pintar", + "pintura", + "desenhar", + "desenho", + "pincel", + "tela", + "cor", + "paleta", + "esboço", + "arte", + + // Indonesian + "melukis", + "lukisan", + "gambar", + "kanvas", + "kuas", + "warna", + "palet", + "sketsa", + "seni", + + // French + "peindre", + "peinture", + "dessin", + "dessiner", + "pinceau", + "toile", + "couleur", + "palette", + "esquisse", + "art", +]; + +function hasPaintWord(text) { + const lowerCaseText = text.toLowerCase(); + return paintingWords.some((word) => lowerCaseText.includes(word)); +} + +export default hasPaintWord; diff --git a/src/App.js b/src/App.js index 923ee83c..0b73df79 100644 --- a/src/App.js +++ b/src/App.js @@ -171,7 +171,14 @@ function App() { {chatHistory.map((chat, index) => ( - + {chat.user} {isModelResponding && chat.assistant === null && } {chat.assistant !== null && {chat.assistant}} diff --git a/src/index.js b/src/index.js index a1495f6e..c095671f 100644 --- a/src/index.js +++ b/src/index.js @@ -2,10 +2,14 @@ import React from "react"; import ReactDOM from "react-dom/client"; import "./index.css"; import App from "./App"; +import { ThemeProvider } from "@mui/material"; +import theme from "./theme"; const root = ReactDOM.createRoot(document.getElementById("root")); root.render( - - - + + + + + ); diff --git a/src/theme.js b/src/theme.js index 7ade45f2..4b20de1a 100644 --- a/src/theme.js +++ b/src/theme.js @@ -1,19 +1,18 @@ -import { red } from "@mui/material/colors"; import { createTheme } from "@mui/material/styles"; const theme = (mode) => createTheme({ palette: { mode: mode, - primary: { - main: "#F50057", - }, + // primary: { + // main: "#F50057", + // }, secondary: { main: "#673ab7", }, - error: { - main: red.A400, - }, + }, + typography: { + fontFamily: ["Chilanka", "cursive"].join(","), }, });