##################################### Imports ###################################### import gradio as gr import json import os ########################### Global objects and functions ########################### def get_json_cfg(): """Retrieve configuration file""" config_path = os.getenv('CONFIG_PATH') with open(config_path, 'r') as file: config = json.load(file) return config #print(get_json_cfg()) dirname = os.getcwd() def greet(model_name, prompt_template, name, dirname): return f"Hello {name}!! Using model: {model_name} with template: {prompt_template} and {dirname}" model_choices = ["gpt2", "bert-base-uncased", "llama3-8b"] ##################################### App UI ####################################### with gr.Blocks() as demo: gr.Markdown("# Instruction Tuning with Unsloth") model_name = gr.Dropdown(label="Model", choices=model_choices, value="gpt2") prompt_template = gr.Textbox(label="Prompt Template", value="Instruction: {0}\nOutput: {1}") name_input = gr.Textbox(label="Your Name") greet_btn = gr.Button("Greet") output = gr.Textbox(label="Output") greet_btn.click(fn=greet, inputs=[model_name, prompt_template, name_input, dirname], outputs=output) ##################################### Launch ####################################### if __name__ == "__main__": demo.launch()