Added get available space

This commit is contained in:
Saifeddine ALOUI 2023-05-28 08:47:57 +02:00
parent f4e177e948
commit e97e6ca3a8
6 changed files with 35 additions and 1 deletions

5
.gitignore vendored
View File

@ -177,4 +177,7 @@ outputs
# ignore installation files
.installed
test.http
test.http
shared/*
!shared/.keep

1
api/langchain.py Normal file
View File

@ -0,0 +1 @@
# TODO : implement

13
app.py
View File

@ -44,6 +44,8 @@ from gevent.pywsgi import WSGIServer
import requests
from concurrent.futures import ThreadPoolExecutor, as_completed
import logging
import psutil
log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)
@ -82,6 +84,11 @@ class Gpt4AllWebUI(GPT4AllAPI):
# =========================================================================================
self.add_endpoint(
"/get_available_space", "get_available_space", self.get_available_space, methods=["GET"]
)
self.add_endpoint(
"/list_bindings", "list_bindings", self.list_bindings, methods=["GET"]
)
@ -461,6 +468,12 @@ class Gpt4AllWebUI(GPT4AllAPI):
print("Set config results:")
print(result)
return jsonify(result)
def get_available_space(self):
current_drive = Path.cwd().anchor
disk_usage = psutil.disk_usage(current_drive)
available_space = disk_usage.free
return jsonify({"available_space":available_space})
def list_bindings(self):
bindings_dir = Path('./bindings') # replace with the actual path to the models folder

View File

@ -240,6 +240,21 @@ This Flask server provides various endpoints to manage and interact with the cha
- "/help": GET request endpoint to display the help page.
- "/get_all_personalities": GET request endpoint to get all personalities array
- "/get_personality": GET request endpoint to get speciffic data based on request
- "/get_available_space": GET request endpoint to retrieve the available space in the current folder's drive.
Method: GET
Description: Retrieves the available space in bytes for the current folder's drive.
Response:
Content-Type: application/json
Body: JSON object with a single entry 'available_space' containing the available space in bytes.
Example Response:
json
Copy code
{
"available_space": 1234567890
}
Example Usage:
Request: GET /disk_space
Response: 200 OK
## TODO Endpoints:

View File

@ -1,4 +1,5 @@
tqdm
psutil
flask
flask_socketio
pytest
@ -7,3 +8,4 @@ markdown
gevent
gevent-websocket
pyaipersonality>=0.0.14
langchain

0
shared/.keep Normal file
View File