Spaces:
Build error
Build error
kwabs22 commited on
Commit ·
49ae654
1
Parent(s): ce41f2c
Testing Stable LM 2 1.6B Zephyr - subprocess issues
Browse files
app.py
CHANGED
|
@@ -22,6 +22,7 @@ def generate_response(user_message):
|
|
| 22 |
return output.decode()
|
| 23 |
"""
|
| 24 |
|
|
|
|
| 25 |
def generate_response(user_message):
|
| 26 |
print("Before request")
|
| 27 |
cmd = [
|
|
@@ -34,7 +35,33 @@ def generate_response(user_message):
|
|
| 34 |
result = subprocess.run(cmd, capture_output=True, text=True)
|
| 35 |
print("After response")
|
| 36 |
return result.stdout
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
iface = gr.Interface(
|
| 40 |
fn=generate_response,
|
|
|
|
| 22 |
return output.decode()
|
| 23 |
"""
|
| 24 |
|
| 25 |
+
"""
|
| 26 |
def generate_response(user_message):
|
| 27 |
print("Before request")
|
| 28 |
cmd = [
|
|
|
|
| 35 |
result = subprocess.run(cmd, capture_output=True, text=True)
|
| 36 |
print("After response")
|
| 37 |
return result.stdout
|
| 38 |
+
"""
|
| 39 |
+
|
| 40 |
+
def generate_response(user_message):
|
| 41 |
+
print("Before request")
|
| 42 |
+
cmd = [
|
| 43 |
+
"/app/llama.cpp/main", # Path to the executable
|
| 44 |
+
"-m", "/app/llama.cpp/models/stablelm-2-zephyr-1_6b-Q4_0.gguf",
|
| 45 |
+
"-p", user_message,
|
| 46 |
+
"-n", "400",
|
| 47 |
+
"-e"
|
| 48 |
+
]
|
| 49 |
+
|
| 50 |
+
# Start the subprocess
|
| 51 |
+
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
| 52 |
+
|
| 53 |
+
# Yield each line of output as it becomes available
|
| 54 |
+
for line in process.stdout:
|
| 55 |
+
yield line
|
| 56 |
+
|
| 57 |
+
# Wait for the subprocess to finish if it hasn't already
|
| 58 |
+
process.wait()
|
| 59 |
|
| 60 |
+
print("After response")
|
| 61 |
+
# Check for any errors
|
| 62 |
+
if process.returncode != 0:
|
| 63 |
+
error_message = process.stderr.read()
|
| 64 |
+
print(f"Error: {error_message}")
|
| 65 |
|
| 66 |
iface = gr.Interface(
|
| 67 |
fn=generate_response,
|