Niek / chatgpt-web

ChatGPT web interface using the OpenAI API
https://niek.github.io/chatgpt-web/
GNU General Public License v3.0
1.78k stars 464 forks source link

exportAllAsMarkdown + Select Default Model #174

Open PrimalOutshoot opened 1 year ago

PrimalOutshoot commented 1 year ago

expoertAllAsMarkdown:

A much needed feature in the main repo is exportAllAsMarkdown, where with a click of a button you can exportAllAsMarkdown as a zip. (Would be awesome if you could export all as JSON and then import all as JSON but I think that would be secondary to Markdown because Markdown can be imported into more things and JSON would be specific to the app.)

In my old version of chatgpt-web and in the new updated version I've been using some customized code to do this daily:

"save all my files as a zip and then delete them (as opposed to one at a time).

Unfortunately I am finding that updating chatgpt-web whenever changes occurs breaks the feature and I have to readd my own custom code again. Same challenge when using my own custom prompts.csv - though dropping in a saved prompts.csv feels less challenging than manually copying and pasting my custom code each time.

I am unfamiliar with git and github and most of my attempts to use git end up with errors of some kind making it a frustrating experience - but thought I would share here what I have done in hopes that a similar feature would be added to the main repo:

npm install jszip

ChatOptionsMenu.svelte // I couldn't figure out how to add my new font icons in this version of chatgpt-web, unimportant import { exportAsMarkdown, exportAllAsMarkdown, exportChatAsJSON } from './Export.svelte' <a href={'#'} class="dropdown-item" class:is-disabled={!chatId} on:click|preventDefault={() => { if (chatId) close(); exportAllAsMarkdown(chatId) }}> Export All Chats

Export.svelte // exportAllAsMarkdown const createMarkdownContent = (chat: Chat) => { const messages = chat.messages; let markdownContent = # ${chat.name}\n;

messages.forEach((message) => { const author = message.role; const content = message.content; const messageMarkdown = ## ${author}\n${content}\n\n;

markdownContent += messageMarkdown;

});

return markdownContent; };

export async function exportAllAsMarkdown() { const chats = get(chatsStorage); const zip = new JSZip(); for (const chat of chats) { const markdownContent = createMarkdownContent(chat); zip.file(${chat.name}.md, markdownContent); }

const blob = await zip.generateAsync({ type: 'blob' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.download = 'chats.zip';
a.href = url;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);

}

This code successfully onClick exports all current files as Markdown into a zip file that upon extraction retains a copy of all Markdown files extracted.

Select Default Model:

Other code I experimented with was choosing a Default Model, but that was with the old version of chatgpt-web not the new one and my code was kinda buggy, as I was experimenting with having it default to the last used model and after a few chats the model would reset to the default. I also found that I often did not want to use the last used model, but rather my default preferred model. I think selecting a default Model may be more efficient. I am likely to experiment with this feature at some point, but thought I would bring that up, as my attempts at tinkering with that so far have not been successful.

Any pointers on where to select default model in the code itself?

Settings.svelte Adjusting export const defaultModel:Model = 'gpt-3.5-turbo' so that it becomes: export const defaultModel:Model = 'gpt-3.5-turbo-16k' -> only changes the highlight, not the actual default.

Webifi commented 1 year ago

For default model, you can simply create a new profile (clone the one you're on), set the model you want, save the profile changes, and click the thumbtack to mark that profile as default. (With profiles, you can set the "default" for anything you want.)

For exporting all markdown, @Niek , does that seem like a good option to have?

PrimalOutshoot commented 1 year ago

For default model, you can simply create a new profile (clone the one you're on), set the model you want, save the profile changes, and click the thumbtack to mark that profile as default,

When you say new profile do you mean create a new profile in my browser? Or are you saying chatgpt webui supports profiles? when you say clone the profile I am on do you mean Copy and paste a folder within the chatgpt webui folder? Or the browser level? Sorry I am a bit confused 🙏

For exporting all markdown, @Niek , does that seem like a good option to have?

🤞🤞🤞 It's definitely been an essential feature I have come to rely on as a power user myself. Exporting individual markdown files when you have 100+ chats vs. remembering to export as you go and having to export each one individually - has been such a lifesaver esp. for heavy users of gpt who go through new chats quickly. Bonus has been I am able to use privategpt and Obsidian/etc to interact with my chatgpt markdown files in bulk with my own makeshift KnowledgeBase.

Very curious - What is the work flow of others that they only export one at a time? Is export a rare thing for most people?

Webifi commented 1 year ago

When you say new profile do you mean create a new profile in my browser? Or are you saying chatgpt webui supports profiles? when you say clone the profile I am on do you mean Copy and paste a folder within the chatgpt webui folder? Or the browser level? Sorry I am a bit confused 🙏

In ChatGPT-web's settings window, there's a select for the profile. There's 2 "static" example profiles to start with, ChatGPT and Marvin. (These can't be modified, but when you save changes you've made to them, they will automatically clone to custom profiles.)

When in a profile, you can save changes to the profile by selecting the "Save" button that will become enabled when there are changes to save. (You can also reset to the last saved version using the reset button.) When you want a specific profile to be used for all new chats, click the blue thumbtack next to the profile selected in the profile select list.

For other profile options, see the "..." menu in the lower right of the chat settings window. There is an option to clone the current profile you're in.

Edit: I should add for clarity: Changes to a profile will not change the settings of existing chats already using settings from a given profile. Each chat stores, or should store, their settings separate from others. The default profile only applies to new chats created since the default was created.

If you want to create a new chat using the current chat's settings, not the default, open the settings window and select "New Chat". (Probably should call it something else, but "New chat from these settings" doesn't fit well on mobile devices.)

Niek commented 1 year ago

Exporting all chats sounds like a good idea, but jszip is a pretty heavy dependency. There might be a better way to download all chats, but I need to think about it some more.

Webifi commented 1 year ago

If zip is just being used to bundle, there are lighter weight zip libraries without compression.

PrimalOutshoot commented 1 year ago

With exporting all files as Zips. Would Pako or filesaver.js be a solution? These are both light-weight libraries that might be less resource intensive than jszip?