jd_generation / app.py
hitz02's picture
Update app.py
919fe04
import gradio as gr
import os
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, info="Select model here")
api_key = gr.Text(label="Enter API Key for the selected model",
info="Generate key for google FLAN model from - https://huggingface.co/docs/hub/security-tokens\
for GPT - https://platform.openai.com/account/api-keys")
email_features = gr.TextArea(label="Input Email features", value=input_temp, info = "Change the email features here")
example_feature_template = gr.TextArea(label="Example Email - features", value = example_input_feat_temp, info = "Use this template example or change as per your need")
example_subj_body_template = gr.TextArea(label="Example Email - subject and body", value = example_input_subj_body_temp, info = "Use this template example or change as per your need")
with gr.Column():
generated_output = gr.TextArea(label="Generated Text")
btn = gr.Button("Generate")
btn.click(generate_text,
inputs=[llm, api_key, email_features, example_feature_template, example_subj_body_template],
outputs=[generated_output],
api_name='jd_gen')
# gr.Examples(["My name is Clara and I am"], inputs=[seed])
if __name__ == "__main__":
demo.launch()#auth=(os.environ['username'], os.environ['password']))