Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import subprocess
|
| 3 |
+
|
| 4 |
+
# Clone the GitHub repository
|
| 5 |
+
os.system("git clone https://github.com/oobabooga/text-generation-webui.git")
|
| 6 |
+
|
| 7 |
+
# Navigate to the project directory
|
| 8 |
+
os.chdir("text-generation-webui")
|
| 9 |
+
|
| 10 |
+
# Install Node.js dependencies
|
| 11 |
+
os.system("npm install")
|
| 12 |
+
|
| 13 |
+
# Start the Node.js server in the background
|
| 14 |
+
node_process = subprocess.Popen(["npm", "start"])
|
| 15 |
+
|
| 16 |
+
# Wait for the Node.js server to start
|
| 17 |
+
input("Press Enter when the Node.js server is running...")
|
| 18 |
+
|
| 19 |
+
# Activate a virtual environment for Python
|
| 20 |
+
os.system("python3 -m venv venv")
|
| 21 |
+
if os.name == "posix":
|
| 22 |
+
os.system("source venv/bin/activate")
|
| 23 |
+
else:
|
| 24 |
+
os.system("venv\\Scripts\\activate")
|
| 25 |
+
|
| 26 |
+
# Install Gradio
|
| 27 |
+
os.system("pip install gradio")
|
| 28 |
+
|
| 29 |
+
# Modify the original code to integrate with Gradio
|
| 30 |
+
# Example code:
|
| 31 |
import gradio as gr
|
| 32 |
|
| 33 |
+
def generate_text(input_text):
|
| 34 |
+
# Replace this with your text generation logic
|
| 35 |
+
generated_text = "Generated text goes here"
|
| 36 |
+
return generated_text
|
| 37 |
+
|
| 38 |
+
iface = gr.Interface(
|
| 39 |
+
fn=generate_text,
|
| 40 |
+
inputs=gr.Textbox(),
|
| 41 |
+
outputs=gr.Textbox(),
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
# Launch the Gradio interface
|
| 45 |
+
iface.launch()
|
| 46 |
+
|
| 47 |
+
# When you're done, you can manually stop the Node.js server and deactivate the virtual environment.
|