jd_generation / app.py
hitz02's picture
Upload 3 files
98512a4
raw
history blame
1.81 kB
import gradio as gr
from utils import *
def generate_text(llm, api_key, email_features, example_feature_template, example_subj_body_template):
if not llm:
return 'No Model Selected'
elif not api_key:
return 'No API Key given'
else:
fs_prompt = return_template(example_feature_template, example_subj_body_template)
llm_chain = llm_chain_func(fs_prompt, llm, api_key)
return llm_chain.run(email_features)
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
llm = gr.Dropdown(["gpt-3.5-turbo", "google_flan_t5_xxl"], type="value", multiselect=False)
api_key = gr.Text(label="Enter API Key for the selected model")
email_features = gr.TextArea(label="Input Email features", value=input_temp)
example_feature_template = gr.TextArea(label="Example Email - features", value = example_input_feat_temp)
example_subj_body_template = gr.TextArea(label="Example Email - subject and body", value = example_input_subj_body_temp)
with gr.Column():
generated_output = gr.TextArea(label="Generated Text")
# input_dict = {"llm":llm,
# "api_key":api_key,
# "email_features":email_features,
# "example_feature_template":example_feature_template,
# "example_subj_body_template":example_subj_body_template
# }
btn = gr.Button("Generate")
btn.click(generate_text,
inputs=[llm, api_key, email_features, example_feature_template, example_subj_body_template],
outputs=[generated_output])
# gr.Examples(["My name is Clara and I am"], inputs=[seed])
if __name__ == "__main__":
demo.launch(share=True)