|
|
|
import gradio as gr |
|
import json |
|
import os |
|
|
|
|
|
|
|
|
|
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()) |
|
|
|
|
|
def greet(model_name, prompt_template, name): |
|
return f"Hello {name}!! Using model: {model_name} with template: {prompt_template}" |
|
|
|
model_choices = ["gpt2", "bert-base-uncased", "llama3-8b"] |
|
|
|
|
|
|
|
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], |
|
outputs=output) |
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
demo.launch() |