File size: 1,375 Bytes
ed0dca2 bdf3e70 b1cf10f bdf3e70 ed0dca2 b1cf10f bd3b81a bdf3e70 5d52f32 ed0dca2 1e282db 5d52f32 bd3b81a 0bb2563 ed0dca2 1a77461 ed0dca2 |
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 37 38 39 40 41 42 43 44 45 |
##################################### 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())
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"]
##################################### 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],
outputs=output)
##################################### Launch #######################################
if __name__ == "__main__":
demo.launch() |