forked from React-Group/interstellar_ai
very good documentation
This commit is contained in:
parent
b3c03149fe
commit
cb6298476a
5 changed files with 40 additions and 19 deletions
20
app/backend/ProcessMemory.ts
Normal file
20
app/backend/ProcessMemory.ts
Normal 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[]
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
import React from 'react'
|
||||
|
||||
type Chat = {
|
||||
name:string
|
||||
messages:string[]
|
||||
}
|
||||
|
||||
type History = {
|
||||
chats:Chat[]
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,16 +1,29 @@
|
|||
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) => {
|
||||
axios.post("http://localhost:5000/interstellar_ai/db", data)
|
||||
.then(response => {
|
||||
const status = response.data.status
|
||||
console.log(status);
|
||||
postMessage({ status })
|
||||
console.log('message posted');
|
||||
|
||||
})
|
||||
.catch(error => {
|
||||
console.log("Error calling Database:", error)
|
||||
postMessage({ status: 500 })
|
||||
})
|
||||
}
|
|
@ -94,6 +94,8 @@ class API:
|
|||
return jsonify({'status': 200, 'response': self.db.change_data(data)})
|
||||
elif action == "check_credentials":
|
||||
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"})
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import io
|
||||
import numpy as np
|
||||
from faster_whisper import WhisperModel
|
||||
from pydub import AudioSegment
|
||||
|
||||
|
@ -19,7 +18,7 @@ class VoiceRecognition:
|
|||
print("audio to wav failed")
|
||||
|
||||
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)
|
||||
transcription = ""
|
||||
|
|
Loading…
Reference in a new issue