Skip to content

Commit

Permalink
Minor code tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
fingerthief committed Mar 9, 2024
1 parent 5ee2007 commit b76e02f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions js/app-view-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,15 +421,14 @@ export function AppViewModel() {

async function fetchGPTResponseStream(conversation, attitude, model) {
const gptMessagesOnly = filterGPTMessages(conversation);
const storedApiKey = getStoredApiKey();
saveAttitude(attitude);

try {
const response = await fetch("https://api.openai.com/v1/chat/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${storedApiKey || 'Missing API Key'}`
"Authorization": `Bearer ${localStorage.getItem("gptKey") || 'Missing API Key'}`,
},
body: JSON.stringify({
model: model,
Expand Down Expand Up @@ -619,10 +618,13 @@ async function retryFetchGPTResponseStream(conversation, attitude, model, retryC

self.isPalmEnabled(false);
self.isClaudeEnabled(false);

addMessage("user", messageText);

if (!messageText || messageText === "" || self.isLoading() || self.isGeneratingImage()) {
return;
}


if (messageText.toLowerCase().startsWith("image::")) {
await sendImagePrompt(messageText);
Expand Down Expand Up @@ -720,7 +722,7 @@ async function retryFetchGPTResponseStream(conversation, attitude, model, retryC
}

async function sendGPTMessage(messageText) {
addMessage("user", messageText);
// addMessage("user", messageText);
self.scrollToBottom();
self.userInput('');
userInput.value = '';
Expand Down

0 comments on commit b76e02f

Please sign in to comment.