DylanWolf commited on
Commit
e456e4b
·
1 Parent(s): 82c61de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -64
app.py CHANGED
@@ -1,70 +1,9 @@
1
- import os
2
- import subprocess
3
- import platform
4
 
5
- # Function to install Node.js and npm if not found
6
- def install_nodejs_npm():
7
- system = platform.system().lower()
8
- if system == "linux":
9
- os.system("sudo apt update")
10
- os.system("sudo apt install -y nodejs npm")
11
- elif system == "darwin":
12
- os.system("brew install node")
13
- elif system == "windows":
14
- # You can provide instructions for Windows users to install Node.js manually
15
- print("Please install Node.js and npm manually for Windows.")
16
- else:
17
- print("Unsupported operating system. Please install Node.js and npm manually for your system.")
18
-
19
- # Check if Node.js and npm are installed
20
- try:
21
- subprocess.check_call(["node", "-v"])
22
- subprocess.check_call(["npm", "-v"])
23
- except FileNotFoundError:
24
- print("Node.js or npm not found. Installing Node.js and npm...")
25
- install_nodejs_npm()
26
-
27
- # Clone the GitHub repository
28
  os.system("git clone https://github.com/oobabooga/text-generation-webui.git")
29
 
30
- # Navigate to the project directory
31
  os.chdir("text-generation-webui")
32
 
33
- # Install Node.js dependencies
34
- os.system("npm install")
35
-
36
- # Start the Node.js server in the background
37
- node_process = subprocess.Popen(["npm", "start"])
38
-
39
- # Wait for the Node.js server to start
40
- input("Press Enter when the Node.js server is running...")
41
-
42
- # Activate a virtual environment for Python
43
- os.system("python3 -m venv venv")
44
- if os.name == "posix":
45
- os.system("source venv/bin/activate")
46
- else:
47
- os.system("venv\\Scripts\\activate")
48
-
49
- # Install Gradio
50
- os.system("pip install gradio")
51
-
52
- # Modify the original code to integrate with Gradio
53
- # Example code:
54
- import gradio as gr
55
-
56
- def generate_text(input_text):
57
- # Replace this with your text generation logic
58
- generated_text = "Generated text goes here"
59
- return generated_text
60
-
61
- iface = gr.Interface(
62
- fn=generate_text,
63
- inputs=gr.Textbox(),
64
- outputs=gr.Textbox(),
65
- )
66
-
67
- # Launch the Gradio interface
68
- iface.launch()
69
 
70
- # When you're done, you can manually stop the Node.js server and deactivate the virtual environment.
 
1
+ import os
 
 
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  os.system("git clone https://github.com/oobabooga/text-generation-webui.git")
4
 
 
5
  os.chdir("text-generation-webui")
6
 
7
+ os.system("pip install -r requirements.txt")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
+ os.system("./start_linux.sh")