Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,14 @@
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
from llama_cpp import Llama
|
|
|
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
os.environ["HF_HOME"] = "/tmp/hf_cache"
|
| 6 |
|
| 7 |
model = Llama.from_pretrained(
|
|
@@ -28,4 +35,8 @@ def chat(message, history):
|
|
| 28 |
output += delta
|
| 29 |
yield output
|
| 30 |
|
| 31 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
from llama_cpp import Llama
|
| 4 |
+
import psutil
|
| 5 |
|
| 6 |
+
def get_stats():
|
| 7 |
+
process = psutil.Process(os.getpid())
|
| 8 |
+
ram = process.memory_info().rss / 1024 ** 3
|
| 9 |
+
disk = psutil.disk_usage('/').used / 1024 ** 3
|
| 10 |
+
cpu = psutil.cpu_percent(interval=1)
|
| 11 |
+
return f"RAM: {ram:.2f} GB | Disk: {disk:.2f} GB | CPU: {cpu:.1f}%"
|
| 12 |
os.environ["HF_HOME"] = "/tmp/hf_cache"
|
| 13 |
|
| 14 |
model = Llama.from_pretrained(
|
|
|
|
| 35 |
output += delta
|
| 36 |
yield output
|
| 37 |
|
| 38 |
+
with gr.Blocks() as demo:
|
| 39 |
+
stats = gr.Textbox(label="System Stats", value=get_stats, every=5)
|
| 40 |
+
gr.ChatInterface(chat)
|
| 41 |
+
|
| 42 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|