|
import gradio as gr
|
|
import subprocess
|
|
import os
|
|
|
|
def run_command(command, check=True):
|
|
"""Run a shell command and handle output/errors."""
|
|
try:
|
|
subprocess.run(command, shell=True, check=check)
|
|
print("Done!")
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"Error running command: {command}\n{e}")
|
|
exit(1)
|
|
|
|
run_command("python setup_llama.py")
|
|
|
|
def check_function():
|
|
if os.path.exists("Llama-3.1-8B-Lexi-Uncensored_V2_Q4.gguf"):
|
|
return True
|
|
else:
|
|
print("Llama-3.1-8B-Lexi-Uncensored_V2_Q4.gguf not found. Please run setup_llama.py first.")
|
|
return False
|
|
|
|
def button_click(input_text):
|
|
if check_function():
|
|
return f"Function succeeded! Your input: {input_text}"
|
|
else:
|
|
return "Function failed. Please try again."
|
|
|
|
with gr.Blocks() as demo:
|
|
text_input = gr.Textbox(label="Enter some text")
|
|
button = gr.Button("Run Function")
|
|
output = gr.Textbox(label="Result")
|
|
|
|
button.click(fn=button_click, inputs=text_input, outputs=output)
|
|
|
|
demo.launch() |