From ff2616c1634e0b790e520db0b72ea2bad344fdc3 Mon Sep 17 00:00:00 2001 From: Udara Jay Date: Sat, 27 Jan 2024 23:30:21 -0500 Subject: [PATCH] v0.9.3 cleanup --- release/app/package-lock.json | 4 ++-- src/main/handlers/vectorIndex.ts | 8 ++++++++ src/main/utils/pileVectorIndex.js | 20 +++++++++++++++---- src/renderer/context/AutoUpdateContext.js | 6 ++---- src/renderer/context/IndexContext.js | 6 ++++++ src/renderer/pages/Pile/Layout.tsx | 4 +++- .../Pile/Reflections/Reflections.module.scss | 5 +++++ src/renderer/pages/Pile/Reflections/index.jsx | 6 ++++-- .../pages/Pile/Settings/Settings.module.scss | 7 +++++-- src/renderer/pages/Pile/Settings/index.jsx | 7 ++++--- 10 files changed, 55 insertions(+), 18 deletions(-) diff --git a/release/app/package-lock.json b/release/app/package-lock.json index a136bdc..ee69cad 100644 --- a/release/app/package-lock.json +++ b/release/app/package-lock.json @@ -1,12 +1,12 @@ { "name": "pile", - "version": "0.8.3", + "version": "0.9.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "pile", - "version": "0.8.3", + "version": "0.9.3", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/src/main/handlers/vectorIndex.ts b/src/main/handlers/vectorIndex.ts index 833dc95..6ef37c4 100644 --- a/src/main/handlers/vectorIndex.ts +++ b/src/main/handlers/vectorIndex.ts @@ -21,6 +21,14 @@ ipcMain.handle('vectorindex-query', (event, text) => pileVectorIndex.query(text) ); +ipcMain.handle('vectorindex-reset-chat', (event) => + pileVectorIndex.chat() +); + +ipcMain.handle('vectorindex-chat', (event, text) => + pileVectorIndex.chat(text) +); + ipcMain.handle('vectorindex-retriever', (event, text) => pileVectorIndex.query(text) ); diff --git a/src/main/utils/pileVectorIndex.js b/src/main/utils/pileVectorIndex.js index 6e666aa..366aabe 100644 --- a/src/main/utils/pileVectorIndex.js +++ b/src/main/utils/pileVectorIndex.js @@ -78,8 +78,8 @@ class PileVectorIndex { this.serviceContext = serviceContextFromDefaults({ llm: new OpenAI({ model: 'gpt-4-0613', - temperature: 0.9, - prompt: 'As a wise librarian, how would you respond to this inquiry', + temperature: 0.85, + prompt: 'As a wise librarian of this humans journals, how would you respond to this inquiry', }), }); } @@ -114,7 +114,7 @@ class PileVectorIndex { async initQueryEngine() { const retriever = this.vectorIndex.asRetriever(); - retriever.similarityTopK = 10; + retriever.similarityTopK = 20; const nodePostprocessor = new SimilarityPostprocessor({ similarityCutoff: 0.7, @@ -130,7 +130,7 @@ class PileVectorIndex { async initChatEngine() { const retriever = this.vectorIndex.asRetriever(); - retriever.similarityTopK = 10; + retriever.similarityTopK = 20; this.chatEngine = new ContextChatEngine({ retriever }); } @@ -247,6 +247,18 @@ class PileVectorIndex { return response; } + async chat(text) { + if (!this.chatEngine) { + console.warn( + 'Chat engine is not initialized. Please initialize it first.' + ); + return; + } + + const response = await this.chatEngine.chat({message: text}); + return response; + } + async addDocument(thread) { try { // Generate embeddings for the document node diff --git a/src/renderer/context/AutoUpdateContext.js b/src/renderer/context/AutoUpdateContext.js index 3564d37..098369c 100644 --- a/src/renderer/context/AutoUpdateContext.js +++ b/src/renderer/context/AutoUpdateContext.js @@ -15,7 +15,7 @@ export const AutoUpdateContextProvider = ({ children }) => { addNotification({ id: 'auto-update', message: 'Update available', - dismissTime: 3000, + dismissTime: 2000, }); addNotification({ @@ -23,7 +23,6 @@ export const AutoUpdateContextProvider = ({ children }) => { type: 'waiting', message: 'Downloading update...', dismissTime: 5000, - immediate: true, }); setUpdateAvailable(true); @@ -40,7 +39,6 @@ export const AutoUpdateContextProvider = ({ children }) => { type: 'failed', message: 'Auto update failed', dismissTime: 5000, - immediate: true, }); setUpdateError(error); @@ -52,7 +50,7 @@ export const AutoUpdateContextProvider = ({ children }) => { message: 'Pile is up-to-date', type: 'success', dismissTime: 5000, - immediate: true, + immediate: false, }); setUpdateNotAvailable(true); diff --git a/src/renderer/context/IndexContext.js b/src/renderer/context/IndexContext.js index 6567945..d87f0a3 100644 --- a/src/renderer/context/IndexContext.js +++ b/src/renderer/context/IndexContext.js @@ -87,6 +87,11 @@ export const IndexContextProvider = ({ children }) => { [currentPile] ); + const chat = useCallback( + async (text) => window.electron.ipc.invoke('vectorindex-chat', text), + [currentPile] + ); + const getVectorIndex = useCallback(async () => { const pilePath = getCurrentPilePath(); const vIndex = await window.electron.ipc.invoke( @@ -106,6 +111,7 @@ export const IndexContextProvider = ({ children }) => { getVectorIndex, updateIndex, query, + chat, }; return ( diff --git a/src/renderer/pages/Pile/Layout.tsx b/src/renderer/pages/Pile/Layout.tsx index df7d00b..c000336 100644 --- a/src/renderer/pages/Pile/Layout.tsx +++ b/src/renderer/pages/Pile/Layout.tsx @@ -13,6 +13,7 @@ import Reflections from './Reflections'; import { useTimelineContext } from 'renderer/context/TimelineContext'; import { AnimatePresence, motion } from 'framer-motion'; import InstallUpdate from './InstallUpdate'; +import Chat from './Chat'; export default function PileLayout({ children }) { const { pileName } = useParams(); @@ -86,7 +87,8 @@ export default function PileLayout({ children }) {
- + + diff --git a/src/renderer/pages/Pile/Reflections/Reflections.module.scss b/src/renderer/pages/Pile/Reflections/Reflections.module.scss index c7528e3..5c2d726 100644 --- a/src/renderer/pages/Pile/Reflections/Reflections.module.scss +++ b/src/renderer/pages/Pile/Reflections/Reflections.module.scss @@ -48,6 +48,7 @@ input { animation: overlayShow 120ms cubic-bezier(0.16, 1, 0.3, 1); opacity: 0.9; z-index: 4; + overflow-y: overlay; } .DialogContent { @@ -73,6 +74,9 @@ input { margin: 0 auto; padding: 0 40px; max-width: 600px; + overflow-y: overlay; + overflow-x: hidden; + display: block; } .DialogContentOverlay { @@ -148,6 +152,7 @@ input { background: linear-gradient(to bottom left, var(--primary), var(--secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; + overflow:hidden; &::placeholder { color: var(--secondary); diff --git a/src/renderer/pages/Pile/Reflections/index.jsx b/src/renderer/pages/Pile/Reflections/index.jsx index 689cd72..8694ad9 100644 --- a/src/renderer/pages/Pile/Reflections/index.jsx +++ b/src/renderer/pages/Pile/Reflections/index.jsx @@ -25,7 +25,7 @@ import { AnimatePresence, motion } from 'framer-motion'; const prompts = [ 'Pose me any riddle or wonderment you wish', - 'You may consult this mind on any matter, mysterious or mundane.', + 'You may consult this mind on any matter, mysterious or mundane', ]; export default function Reflections() { @@ -37,6 +37,8 @@ export default function Reflections() { const [querying, setQuerying] = useState(false); const [response, setResponse] = useState(null); + let randomPrompt = useMemo(() => prompts[Math.floor(Math.random() * prompts.length)], []); + const onChangeText = (e) => { setText(e.target.value); }; @@ -109,7 +111,7 @@ export default function Reflections() { onChange={onChangeText} className={styles.textarea} onKeyDown={handleKeyPress} - placeholder="Pose me any riddle or wonderment you wish" + placeholder={randomPrompt} />