Adityadn commited on
Commit
d0ba97f
1 Parent(s): 218c09c

Create kb.py

Browse files
Files changed (1) hide show
  1. kb.py +67 -0
kb.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ print("Wait..")
2
+
3
+ def test():
4
+ import gradio as gr
5
+
6
+ def analyze_text(text):
7
+ # Lakukan analisis atau pemrosesan teks di sini
8
+ result = f"Anda memasukkan teks: {text}"
9
+ return result
10
+
11
+ iface = gr.Interface(
12
+ fn=analyze_text,
13
+ inputs=gr.Textbox(), # Menggunakan input textbox
14
+ outputs="text" # Menetapkan output ke tipe teks
15
+ )
16
+
17
+ iface.launch()
18
+
19
+ def process():
20
+ import subprocess
21
+
22
+ # def uninstall_and_install_gradio(version):
23
+ # # Uninstall current Gradio
24
+ # uninstall_command = ["pip", "uninstall", "gradio", "-y"]
25
+ # subprocess.run(uninstall_command)
26
+
27
+ # # Install specific version of Gradio
28
+ # install_command = ["pip", "install", f"gradio=={version}"]
29
+ # subprocess.run(install_command)
30
+
31
+ # # Gantilah "3.41.2" dengan versi Gradio yang diinginkan
32
+ # desired_version = "3.41.2"
33
+
34
+ # # Periksa versi Gradio yang terinstal
35
+ # current_version_command = ["pip", "show", "gradio"]
36
+ # result = subprocess.run(current_version_command, capture_output=True, text=True)
37
+ # current_version = None
38
+
39
+ # if "Version" in result.stdout:
40
+ # current_version = result.stdout.split("Version:")[1].strip()
41
+
42
+ # # Cek dan lakukan uninstall dan install jika versi tidak sesuai
43
+ # if current_version != desired_version:
44
+ # uninstall_and_install_gradio(desired_version)
45
+ # print(f"Gradio has been updated to version {desired_version}")
46
+ # else:
47
+ # print(f"Gradio is already at version {desired_version}")
48
+
49
+ python_script = "entry_with_update.py"
50
+
51
+ # Argument yang ingin Anda tambahkan
52
+ # additional_arguments = ["--in-browser", "--all-in-fp32", "--directml", "--debug-mode", "--multi-user", "--always-cpu", "--is-windows-embedded-python"]
53
+ additional_arguments = ["--disable-in-browser", "--attention-split", "--always-cpu"]
54
+
55
+ # Gabungkan semua argumen
56
+ PIP = ["pip", "install", "-r", "requirements_versions.txt"]
57
+ command = ["python", python_script] + additional_arguments
58
+
59
+ # Jalankan skrip menggunakan subprocess
60
+ subprocess.run(PIP)
61
+ print("Installing..")
62
+
63
+ subprocess.run(command)# Menjalankan file batch
64
+ print("Running..")
65
+ # subprocess.run([batch_file_path], shell=True)
66
+
67
+ process()