File size: 1,537 Bytes
4bce749
ada463d
90c554e
ada463d
90c554e
 
 
 
 
 
 
 
 
ada463d
9dde370
90c554e
9dde370
9d03f80
9dde370
 
 
90c554e
 
 
 
 
 
ada463d
 
90c554e
ada463d
9dde370
 
 
 
 
ada463d
 
90c554e
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
import os
import gradio as gr
import google.generativeai as palm

palm.configure(api_key=os.environ["YOUR_API_KEY"])

defaults = {
  'model': 'models/chat-bison-001',
  'temperature': 0.25,
  'candidate_count': 1,
  'top_k': 40,
  'top_p': 0.95,
}

def get_recommendation(prompt, recommendation_type):
    context = ""
    if recommendation_type == "Letter of Recommendation":
        context = f"Write a formal Letter of Recommendation with a header and signature for a job addressed to hiring manager for a candidate who is male/he named Ziga who is a recruiting professional without mention of time worked together and follow this instructions: {prompt}"
    else:
        context = f"Write a Recommendation for LinkedIn for a candidate who is male/he named Ziga who is a recruiting professional without mention of time worked together and follow this instructions: {prompt}"
    
    messages = [context]
    response = palm.chat(
        **defaults,
        context=context,
        examples=[],
        messages=messages
    )

    return response.last

inputs = [
    gr.inputs.Radio(choices=["Letter of Recommendation", "LinkedIn Recommendation"], label="Recommendation Type"),
    gr.inputs.Textbox(lines=7, label="Description")
]

outputs = gr.outputs.Textbox(label="Reply")

gr.Interface(fn=get_recommendation, inputs=inputs, outputs=outputs, title="Recommendation Generator", description="Describe what you enjoyed and observed while working with Ziga. Choose the type of recommendation you want.", theme="compact").launch()