File size: 1,089 Bytes
51cca30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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()