Skip to content

Commit

Permalink
rm stream speed
Browse files Browse the repository at this point in the history
  • Loading branch information
bramses committed Mar 20, 2023
1 parent d193c06 commit 0e399a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
20 changes: 3 additions & 17 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ interface ChatGPT_MDSettings {
apiKey: string;
defaultChatFrontmatter: string;
stream: boolean;
streamSpeed: number;
chatTemplateFolder: string;
chatFolder: string;
generateAtCursor: boolean;
Expand All @@ -33,7 +32,6 @@ const DEFAULT_SETTINGS: ChatGPT_MDSettings = {
defaultChatFrontmatter:
"---\nsystem_commands: ['I am a helpful assistant.']\ntemperature: 0\ntop_p: 1\nmax_tokens: 512\npresence_penalty: 1\nfrequency_penalty: 1\nstream: true\nstop: null\nn: 1\nmodel: gpt-3.5-turbo\n---",
stream: true,
streamSpeed: 28,
chatTemplateFolder: "ChatGPT_MD/templates",
chatFolder: "ChatGPT_MD/chats",
generateAtCursor: false,
Expand Down Expand Up @@ -365,7 +363,7 @@ export default class ChatGPT_MD extends Plugin {

generateDatePattern(format: string) {
const pattern = format
.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&") // Escape any special characters
.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&") // Escape any special characters
.replace("YYYY", "\\d{4}") // Match exactly four digits for the year
.replace("MM", "\\d{2}") // Match exactly two digits for the month
.replace("DD", "\\d{2}") // Match exactly two digits for the day
Expand Down Expand Up @@ -777,19 +775,7 @@ class ChatGPT_MDSettingsTab extends PluginSettingTab {
})
);

// stream speed slider
new Setting(containerEl)
.setName("Stream Speed")
.setDesc("Stream speed in milliseconds")
.addSlider((slider) =>
slider
.setLimits(20, 50, 1)
.setValue(this.plugin.settings.streamSpeed)
.onChange(async (value) => {
this.plugin.settings.streamSpeed = value;
await this.plugin.saveSettings();
})
);


// folder for chat files
new Setting(containerEl)
Expand Down Expand Up @@ -849,7 +835,7 @@ class ChatGPT_MDSettingsTab extends PluginSettingTab {
// date format for chat files
new Setting(containerEl)
.setName("Date Format")
.setDesc("Date format for chat files")
.setDesc("Date format for chat files. Valid date blocks are: YYYY, MM, DD, hh, mm, ss")
.addText((text) =>
text
.setPlaceholder("YYYYMMDDhhmmss")
Expand Down
3 changes: 3 additions & 0 deletions stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export const streamSSE = async (
editor.setCursor(newCursor);
} else {
source.close();
console.log("[ChatGPT MD] SSE Closed");

// replace the text from initialCursor to fix any formatting issues from streaming
const cursor = editor.getCursor();
Expand Down Expand Up @@ -130,10 +131,12 @@ export const streamSSE = async (
try {
console.log("[ChatGPT MD] SSE Error: ", JSON.parse(e.data));
source.close();
console.log("[ChatGPT MD] SSE Closed");
reject(JSON.parse(e.data));
} catch (err) {
console.log("[ChatGPT MD] Unknown Error: ", e);
source.close();
console.log("[ChatGPT MD] SSE Closed");
reject(e);
}
});
Expand Down

0 comments on commit 0e399a1

Please sign in to comment.