Compare commits

..

No commits in common. "9bbe2a0a152898b3fb4aef0c08129892b97c231b" and "8ec93d4f1c940b45cdca25c33acf14a3d9d5581f" have entirely different histories.

2 changed files with 22 additions and 21 deletions

View file

@ -12,11 +12,9 @@ import PrivacySettings from './PrivacySettings';
import FontSizeSetting from './FontSize'; import FontSizeSetting from './FontSize';
import OpenSourceModeToggle from './OpenSourceToggle'; import OpenSourceModeToggle from './OpenSourceToggle';
import { import {
changeHistory,
changeSettings, changeSettings,
createAccount, createAccount,
deleteAccount, deleteAccount,
getHistory,
} from '../../backend/database'; } from '../../backend/database';
import ThemeDropdown from './DropDownTheme'; import ThemeDropdown from './DropDownTheme';
@ -374,11 +372,7 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
localStorage.setItem("currentEmail", useEmail) localStorage.setItem("currentEmail", useEmail)
alert('Account successfully changed!') alert('Account successfully changed!')
window.location.reload() window.location.reload()
} else {
alert("failed to send settings")
} }
} else {
alert("failed to create account")
} }
} }
}; };
@ -630,7 +624,6 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
onClick={handleLogout} // Function to call on click onClick={handleLogout} // Function to call on click
className="update-credentials-button" // Custom styling class className="update-credentials-button" // Custom styling class
/> />
<p>WARNING: Will delete your chat history.</p>
<ButtonSetting <ButtonSetting
label="Update Credentials" // Button label label="Update Credentials" // Button label
onClick={handleUpdateCredentials} // Function to call on click onClick={handleUpdateCredentials} // Function to call on click

View file

@ -20,29 +20,34 @@ class AI:
for chunk in stream: for chunk in stream:
with return_class.ai_response_lock: with return_class.ai_response_lock:
return_class.ai_response[access_token] += chunk["message"]["content"] return_class.ai_response[access_token] += chunk['message']['content']
@staticmethod @staticmethod
def process_mistralai(model, messages, return_class, access_token, api_key): def process_mistralai(model, messages, return_class, access_token, api_key):
client = Mistral(api_key=api_key) client = Mistral(api_key=api_key)
stream_response = client.chat.stream(model=model, messages=messages) stream_response = client.chat.stream(
model=model,
messages=messages
)
with return_class.ai_response_lock: with return_class.ai_response_lock:
return_class.ai_response[access_token] = "" return_class.ai_response[access_token] = ""
for chunk in stream_response: for chunk in stream_response:
with return_class.ai_response_lock: with return_class.ai_response_lock:
return_class.ai_response[access_token] += chunk.data.choices[ return_class.ai_response[access_token] += chunk.data.choices[0].delta.content
0
].delta.content
@staticmethod @staticmethod
def process_openai(model, messages, return_class, access_token, api_key): def process_openai(model, messages, return_class, access_token, api_key):
client = OpenAI(api_key=api_key) client = OpenAI(api_key=api_key)
stream_response = client.chat.completions.create( stream_response = client.chat.completions.create(
model=model, messages=messages, stream=True model=model,
messages=messages,
stream=True
) )
with return_class.ai_response_lock: with return_class.ai_response_lock:
@ -54,6 +59,7 @@ class AI:
@staticmethod @staticmethod
def process_anthropic(model, messages, return_class, access_token, api_key): def process_anthropic(model, messages, return_class, access_token, api_key):
client = anthropic.Anthropic(api_key=api_key) client = anthropic.Anthropic(api_key=api_key)
with return_class.ai_response_lock: with return_class.ai_response_lock:
@ -70,15 +76,16 @@ class AI:
@staticmethod @staticmethod
def process_google(model, messages, return_class, access_token, api_key): def process_google(model, messages, return_class, access_token, api_key):
message = messages[-1]["content"]
message = messages[-1]['content']
messages.pop() messages.pop()
for msg in messages: for msg in messages:
msg["parts"] = msg.pop()["content"] msg['parts'] = msg.pop('content')
for msg in messages: for msg in messages:
if msg["role"] == "assistant": if msg['role'] == 'assistant':
msg["role"] = "model" msg['role'] = 'model'
genai.configure(api_key=api_key) genai.configure(api_key=api_key)
@ -86,6 +93,7 @@ class AI:
chat = model.start_chat( chat = model.start_chat(
history=messages, history=messages,
) )
response = chat.send_message(message, stream=True) response = chat.send_message(message, stream=True)