File size: 1,407 Bytes
a5381f1 0c9de8c a5381f1 229269d dbaf271 229269d dbaf271 229269d 833784b 229269d 0c9de8c 229269d 367db14 f4b0a62 229269d |
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 |
import gradio as gr
import metadata_transformer
def greet(name):
return "Hello " + name + "!!"
def create_input_components():
"""
Creates and returns input components for Gradio interface.
"""
# A text area for users to input or paste the schema file.
schema_input = gr.TextArea(label="Schema File", placeholder="Paste your schema here...")
# A text input for users to provide the schema target.
target_input = gr.Textbox(label="Schema Target", placeholder="Enter your schema target...")
file_input = """{}""".format(schema_input)
return [file_input, target_input]
def create_output_component():
"""
Creates and returns output component for Gradio interface.
"""
# A text area to display the transformed schema output.
transformed_schema_output = gr.Textbox(label="Transformed Schema", readonly=True)
return transformed_schema_output
# Prepare the UI components.
inputs = create_input_components()
output = create_output_component()
# Define the Gradio interface.
interface = gr.Interface(
fn=metadata_transformer.translate, # This function will handle the logic and transformations.
inputs=inputs,
outputs="text",
# live=True,
title="Schema Transformer with Llama2",
description="Paste your schema, specify the target, and get the transformed schema."
)
# Launch the Gradio web interface.
interface.launch() |