File size: 2,034 Bytes
98512a4
 
d622ba6
98512a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2be00d4
 
85db1fa
 
cedf72d
 
 
98512a4
 
 
 
 
8403923
98512a4
 
 
8403923
 
98512a4
 
 
 
919fe04
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
46

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']))