Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save chats #21

Merged
merged 27 commits into from
Feb 14, 2024
Merged

Save chats #21

merged 27 commits into from
Feb 14, 2024

Conversation

jackitaliano
Copy link
Contributor

Save Chats

Allow Saving Multiple Chats and Chat History

  • any number of chats can now be saved
  • chat histories will persist through reload of page and new page
Save-Chats

Multiple chats open

Save-Chats-Delete

Deleting a chat

Changes

Navbar

import { Navbar } from 'components';

Problem

  • need to know what chat you're currently in
  • need to be able to toggle a view of the chat's and histories

Solution

  • added Navbar component with toggle
    • toggle menu button (opens sidebar)
      • toggles open state
    • name of current chat
    • Bidara logo and name
  • disable view on welcome

Sidebar

import { Sidebar } from 'components';

Problem

  • Need to know what chat's have been saved
  • Need to be able to create new chats
  • Don't want to flood threads with empties

Solution

  • added toggleable Sidebar component with list of chats
    • toggle bound with open state
    • list of current open chats
    • new chat button
  • disable new chat creation when current is empty
  • switch to current empty chats instead of creating a new one
  • fullscreen on mobile (<700px), sidebar on desktop (>700px)
  • disable view on welcome

Chat (sidebar item)

import { Chat } from 'components/Chat.svelte';

Problem

  • Need to know details of chat to select
  • Need to be able to select/delete chats

Solution

  • added Chat component sidebar item
    • Includes name of chat
    • slide (left) to delete
    • click to select

Deepchat

Problem

  • deep-chat is somewhat difficult to work with in changing environments, namely width

Solution

  • put into chat-container
  • change width from welcome to "signed in"
    • 100dvw on welcome -> 100% on "signed in"
  • assign thread_id and load_chat_history on initialization
  • reload on changing of thread_id

Storage

import { ... } from 'utils/threadUtils';
import { ... } from 'utils/openaiUtils';
import { ... } from 'utils/threadUtils';

Problem

  • Need to store histories of chats
  • Need to store what chat is currently active
  • Want to decouple storage method from storage implementation

Solution

  • store current active OpenAI thread
    • { 'openai-active-thread': { 'id': 'thread_123456789', 'name': 'thread name' } }
  • store list of threads in reverse order of creation time
    • { 'openai-threads': [ { 'id': 'thread_123456789', 'name': 'thread name' }, ... ] }
  • Move local storage methods to separate file
  • change method of storage to:
    • getStorage(key)
    • getStorageJSON(key)
    • setStorage(key, value)
    • setStorageJSON(key, value)
  • set method of storage within these functions to local storage (can be swapped out for alternative storage method)
    • setLocal(key, value)
    • getLocal(key)
  • add storage methods for each current storage use
    • getStoredAPIKey()
    • getStoredAsstId()
    • getStoredActiveThread()
    • getStoredThreads()
    • setStoredAPIKey(value)
    • setStoredAsstId(value)
    • setStoredActiveThread(value)
    • setStoredThreads(value)
    • filterStoredThreads(thread_filter)

Threads

Problem

  • handling of threads (storage, retrieval, error handling, etc.) began to bloat openaiUtils
  • much of the logic was unrelated to openai, thus it was no longer an openai utility

Solution

  • moved thread logic not related to api to src/utils/threadUtils.s

File Structure

Problem

  • added several new components and utils files, cluttering directory

Solution

  • created dirs src/components, src/utils, src/assistant and moved relevant files into them

Known Issues

  • images generated by Dalle-e-3 (function call get_image_from_description) currently are not stored with chat histories
    • if return url to assistant, saves in history but reads out entire url in voice mode
    • if not return url, doesn't read url but doesn't save in chat history

@jackitaliano jackitaliano linked an issue Feb 12, 2024 that may be closed by this pull request
@bruffridge bruffridge merged commit 6b65fe6 into main Feb 14, 2024
@bruffridge bruffridge deleted the save-chats branch February 14, 2024 21:05
@bruffridge bruffridge restored the save-chats branch February 14, 2024 21:14
@bruffridge bruffridge mentioned this pull request Feb 14, 2024
Onsang1 pushed a commit that referenced this pull request Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

multiple chats
2 participants