added test vars to check the page in a browser
This commit is contained in:
parent
918425cebe
commit
84a18f873b
3 changed files with 47 additions and 9 deletions
|
|
@ -37,9 +37,25 @@ messageInput.setMessagesArea(messagesArea);
|
|||
// Data received from the user
|
||||
let promptData = null;
|
||||
|
||||
// ============================== TESTING
|
||||
// let browser = {
|
||||
// i18n: {
|
||||
// getMessage: async function(key) {
|
||||
// return key;
|
||||
// }
|
||||
// },
|
||||
// storage: {
|
||||
// sync: {
|
||||
// get: async function(key) {
|
||||
// return 'apitest';
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ============================== TESTING - END
|
||||
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
//let prefs_api_key = await browser.storage.sync.get({api_key_chatgpt: ''});
|
||||
let prefs_api_key = '' // only for testing
|
||||
let prefs_api_key = await browser.storage.sync.get({api_key_chatgpt: ''});
|
||||
// const openaiApiKey = params.get('openapi-key');
|
||||
//console.log(">>>>>>>>>>> api_key_chatgpt: " + prefs_api_key.api_key_chatgpt);
|
||||
worker.postMessage({ type: 'init', api_key_chatgpt: prefs_api_key.api_key_chatgpt });
|
||||
|
|
|
|||
|
|
@ -200,6 +200,27 @@ class MessagesArea extends HTMLElement {
|
|||
}
|
||||
|
||||
addActionButtons(promptData = null) {
|
||||
// ============================== TESTING
|
||||
// promptData = {
|
||||
// action: "1",
|
||||
// tabId: 1,
|
||||
// mailMessageId: 1
|
||||
// }
|
||||
// let browser = {
|
||||
// i18n: {
|
||||
// getMessage: async function(key) {
|
||||
// return key;
|
||||
// }
|
||||
// },
|
||||
// storage: {
|
||||
// sync: {
|
||||
// get: async function(key) {
|
||||
// return 'apitest';
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ============================== TESTING - END
|
||||
if(promptData == null) { return; }
|
||||
const actionButtons = document.createElement('div');
|
||||
actionButtons.classList.add('action-buttons');
|
||||
|
|
|
|||
|
|
@ -48,21 +48,22 @@ let assistantResponseAccumulator = '';
|
|||
self.onmessage = async function(event) {
|
||||
if (event.data.type === 'init') {
|
||||
api_key_chatgpt = event.data.api_key_chatgpt;
|
||||
//console.log(">>>>>>>>>>> api_key_chatgpt: " + api_key_chatgpt);
|
||||
openai = new OpenAI(api_key_chatgpt, true);
|
||||
} else if (event.data.type === 'chatMessage') {
|
||||
conversationHistory.push({ role: 'user', content: event.data.message });
|
||||
|
||||
|
||||
// ============================== TESTING
|
||||
// Simulate sending the message to an HTTP endpoint
|
||||
await mockDelay(1000); // Wait for 1 second
|
||||
// // Simulate sending the message to an HTTP endpoint
|
||||
// await mockDelay(1000); // Wait for 1 second
|
||||
|
||||
// Notify that the chat message was sent
|
||||
postMessage({ type: 'messageSent' });
|
||||
// // Notify that the chat message was sent
|
||||
// postMessage({ type: 'messageSent' });
|
||||
|
||||
// Start processing tokens
|
||||
await processMockTokens();
|
||||
return;
|
||||
// // Start processing tokens
|
||||
// await processMockTokens();
|
||||
// return;
|
||||
// ============================== TESTING - END
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue