fixed some apis and model picker

This commit is contained in:
Patrick_Pluto 2024-10-01 08:18:14 +02:00
parent 238e82bb95
commit 32edaaef42
3 changed files with 11 additions and 2 deletions

View file

@ -1,3 +1,5 @@
from time import sleep
from flask import Flask, request, jsonify
from flask_cors import CORS
import secrets
@ -48,6 +50,7 @@ class API:
thread = threading.Thread(target=self.ai.process_local, args=(ai_model, messages, self, access_token))
thread.start()
thread.join()
sleep(0.5)
return jsonify({'status': 200})
elif model_type == "mistral":
api_key = data.get('api_key')
@ -55,6 +58,7 @@ class API:
args=(ai_model, messages, self, access_token, api_key))
thread.start()
thread.join()
sleep(0.5)
return jsonify({'status': 200})
elif model_type == "openai":
api_key = data.get('api_key')
@ -62,6 +66,7 @@ class API:
args=(ai_model, messages, self, access_token, api_key))
thread.start()
thread.join()
sleep(0.5)
return jsonify({'status': 200})
elif model_type == "anthropic":
api_key = data.get('api_key')
@ -69,6 +74,7 @@ class API:
args=(ai_model, messages, self, access_token, api_key))
thread.start()
thread.join()
sleep(0.5)
return jsonify({'status': 200})
elif model_type == "google":
api_key = data.get('api_key')
@ -76,6 +82,7 @@ class API:
args=(ai_model, messages, self, access_token, api_key))
thread.start()
thread.join()
sleep(0.5)
return jsonify({'status': 200})
return jsonify({'status': 401, 'error': 'Invalid AI model type'})