very good documentation #27

Merged
Patrick_Pluto merged 2 commits from React-Group/interstellar_ai:main into main 2024-09-30 09:38:46 +02:00
5 changed files with 40 additions and 19 deletions

View file

@ -0,0 +1,20 @@
import { Settings } from 'electron'
import React from 'react'
type Message = {
role: string
content: string
}
type Chat = {
name: string
messages: Message[]
}
type Data = {
chats: Chat[]
settings: Settings[]
}

View file

@ -1,13 +0,0 @@
import React from 'react'
type Chat = {
name:string
messages:string[]
}
type History = {
chats:Chat[]
}

View file

@ -1,16 +1,29 @@
import axios from "axios"; import axios from "axios";
/*
This is the guide on how to user this function:
data should be the json containing everything relevant, the json can contain the following keys:
action -> contains the action you want to do, there are: create_account, change_password, get_data, change_data, check_credentials, delete_account
username -> contains the current username, required for create_account, but can be omitted in favor of email in other requests. Preffered over email authentication.
email -> contains the current email, required for create_account, but just like the username, it can be ommitted, in favor of the other, sending both is possible too.
password -> contains the password, required for all requests.
new_password -> in the case you are changing your password, you will need to use this in addition to password, to specify the new password.
data -> data contains all the data you want to store, you have to always give the entire data, because the data you give here overwrites the data in the database, so if you only give the chat history for example, all settings will be deleted, and if you only give settings, all chat histories will get deleted.
if all went well, you will get the status 200 in response.data.status
to check if the request was accepted or declined, check response.data.response, it will be either true or false depending on if it worked, or not.
*/
const sendToDatabase = (data: any) => { const sendToDatabase = (data: any) => {
axios.post("http://localhost:5000/interstellar_ai/db", data) axios.post("http://localhost:5000/interstellar_ai/db", data)
.then(response => { .then(response => {
const status = response.data.status const status = response.data.status
console.log(status);
postMessage({ status }) postMessage({ status })
console.log('message posted');
}) })
.catch(error => { .catch(error => {
console.log("Error calling Database:", error)
postMessage({ status: 500 }) postMessage({ status: 500 })
}) })
} }

View file

@ -94,6 +94,8 @@ class API:
return jsonify({'status': 200, 'response': self.db.change_data(data)}) return jsonify({'status': 200, 'response': self.db.change_data(data)})
elif action == "check_credentials": elif action == "check_credentials":
return jsonify({'status': 200, 'response': self.db.check_credentials(data)}) return jsonify({'status': 200, 'response': self.db.check_credentials(data)})
elif action == "delete_account":
return jsonify({'status': 200, 'response': self.db.delete_user(data)})
return jsonify({'status': 401, 'response': "Invalid action"}) return jsonify({'status': 401, 'response': "Invalid action"})

View file

@ -1,5 +1,4 @@
import io import io
import numpy as np
from faster_whisper import WhisperModel from faster_whisper import WhisperModel
from pydub import AudioSegment from pydub import AudioSegment
@ -19,7 +18,7 @@ class VoiceRecognition:
print("audio to wav failed") print("audio to wav failed")
model_size = "base" model_size = "base"
model = WhisperModel(model_size, device="cpu", compute_type="int8") model = WhisperModel(model_size, device="cpu", compute_type=" ")
segments, _ = model.transcribe(wav_io) segments, _ = model.transcribe(wav_io)
transcription = "" transcription = ""