INNER CODE UNIT · TypeScript

start

eugeneyan/obsidian-copilot · plugin/main.ts:84

				start = end + 1;

				try {
					const messageWithoutPrefix = message.replace('data: ', '');
					const json = JSON.parse(messageWithoutPrefix);

					let lastToken = '';

					if (json.choices && json.choices.length > 0 && json.choices[0].delta && json.choices[0].delta.content) {
						let token = json.choices[0].delta.content;

						// If token is a space, append it to last token
						if (token === ' ') {
							lastToken += token;
							token = lastToken;
						} else {
							// Save the last non-space token
							lastToken = token;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…