Spaces:
Running
on
Zero
Running
on
Zero
macadeliccc
commited on
Commit
•
9568922
1
Parent(s):
40457c5
test
Browse files
app.py
CHANGED
@@ -9,8 +9,8 @@ import json
|
|
9 |
import asyncio
|
10 |
|
11 |
# Function to start the ochat server
|
12 |
-
@
|
13 |
-
|
14 |
print(f"Is CUDA available: {torch.cuda.is_available()}")
|
15 |
print(f"CUDA device: {torch.cuda.get_device_name(torch.cuda.current_device())}")
|
16 |
|
@@ -19,27 +19,15 @@ async def start_ochat_server():
|
|
19 |
"--model", "openchat/openchat_3.5"
|
20 |
]
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
if not await is_server_running():
|
32 |
-
try:
|
33 |
-
# Start the server in a separate process
|
34 |
-
subprocess.Popen(command)
|
35 |
-
print("ochat server started successfully.")
|
36 |
-
except Exception as e:
|
37 |
-
print(f"Failed to start ochat server: {e}")
|
38 |
-
|
39 |
-
await asyncio.sleep(60) # Wait for 60 seconds before checking again
|
40 |
-
|
41 |
-
# Start the server
|
42 |
-
asyncio.run(start_ochat_server())
|
43 |
|
44 |
# Function to send a message to the ochat server and get a response
|
45 |
async def chat_with_ochat(message):
|
|
|
9 |
import asyncio
|
10 |
|
11 |
# Function to start the ochat server
|
12 |
+
@spaces.GPU
|
13 |
+
def start_ochat_server():
|
14 |
print(f"Is CUDA available: {torch.cuda.is_available()}")
|
15 |
print(f"CUDA device: {torch.cuda.get_device_name(torch.cuda.current_device())}")
|
16 |
|
|
|
19 |
"--model", "openchat/openchat_3.5"
|
20 |
]
|
21 |
|
22 |
+
# Start the server in a separate process
|
23 |
+
try:
|
24 |
+
subprocess.Popen(command)
|
25 |
+
return "ochat server started successfully"
|
26 |
+
except Exception as e:
|
27 |
+
return f"Failed to start ochat server: {e}"
|
28 |
+
|
29 |
+
|
30 |
+
start_ochat_server()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
# Function to send a message to the ochat server and get a response
|
33 |
async def chat_with_ochat(message):
|