Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
9c1d271
1
Parent(s):
74995d7
test
Browse files
app.py
CHANGED
@@ -4,26 +4,43 @@ import torch
|
|
4 |
import subprocess
|
5 |
import numpy as np
|
6 |
|
7 |
-
print(torch.cuda.is_available())
|
8 |
-
print(torch.cuda.
|
9 |
-
print(torch.cuda.get_device_name()) # <-- 'A10G' 🤗
|
10 |
|
11 |
-
|
|
|
12 |
def start_ochat_server():
|
13 |
-
|
14 |
-
# Command to start the ochat inference server
|
15 |
command = [
|
16 |
"python", "-m", "ochat.serving.openai_api_server",
|
17 |
"--model", "openchat/openchat_3.5"
|
18 |
]
|
19 |
|
20 |
-
# Start the server
|
21 |
try:
|
22 |
-
# Use subprocess to run the command
|
23 |
subprocess.Popen(command)
|
24 |
return "ochat server started successfully"
|
25 |
except Exception as e:
|
26 |
return f"Failed to start ochat server: {e}"
|
27 |
-
|
28 |
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
import subprocess
|
5 |
import numpy as np
|
6 |
|
7 |
+
print(f"Is CUDA available: {torch.cuda.is_available()}")
|
8 |
+
print(f"CUDA device: {torch.cuda.get_device_name(torch.cuda.current_device())}")
|
|
|
9 |
|
10 |
+
|
11 |
+
# Function to start the ochat server
|
12 |
def start_ochat_server():
|
|
|
|
|
13 |
command = [
|
14 |
"python", "-m", "ochat.serving.openai_api_server",
|
15 |
"--model", "openchat/openchat_3.5"
|
16 |
]
|
17 |
|
18 |
+
# Start the server in a separate process
|
19 |
try:
|
|
|
20 |
subprocess.Popen(command)
|
21 |
return "ochat server started successfully"
|
22 |
except Exception as e:
|
23 |
return f"Failed to start ochat server: {e}"
|
|
|
24 |
|
25 |
+
|
26 |
+
# Function to interact with the chat server
|
27 |
+
@spaces.GPU
|
28 |
+
def chat_with_ochat(message):
|
29 |
+
# Here you would add the code to interact with the ochat server
|
30 |
+
# For simplicity, this is just a placeholder response
|
31 |
+
return "Response from ochat server"
|
32 |
+
|
33 |
+
|
34 |
+
# Start the ochat server
|
35 |
+
start_ochat_server()
|
36 |
+
|
37 |
+
# Create a Gradio Interface
|
38 |
+
iface = gr.Interface(
|
39 |
+
fn=chat_with_ochat,
|
40 |
+
inputs="text",
|
41 |
+
outputs="text",
|
42 |
+
title="ochat Chat Interface",
|
43 |
+
description="Type your message and get a response from the ochat server."
|
44 |
+
)
|
45 |
+
|
46 |
+
iface.launch(share=True)
|