mild changes to the ais and added models to models.tsx

This commit is contained in:
Patrick_Pluto 2024-09-30 11:30:30 +02:00
parent a23257be7f
commit d83aeb2c74
3 changed files with 21 additions and 7 deletions

View file

@ -80,11 +80,6 @@ class AI:
message = messages[-1]['content']
messages.pop()
system = None
if messages and messages[0]['role'] == 'system':
system = messages[0]['content']
messages.pop(0)
for msg in messages:
msg['parts'] = msg.pop('content')
@ -97,8 +92,8 @@ class AI:
model = genai.GenerativeModel(model)
chat = model.start_chat(
system_instruction=system,
history=messages
history=messages,
)
response = chat.send_message(message, stream=True)

View file

@ -70,6 +70,13 @@ class API:
thread.start()
thread.join()
return jsonify({'status': 200})
elif model_type == "google":
api_key = data.get('api_key')
thread = threading.Thread(target=self.ai.process_google,
args=(ai_model, messages, self, access_token, api_key))
thread.start()
thread.join()
return jsonify({'status': 200})
return jsonify({'status': 401, 'error': 'Invalid AI model type'})