import os import gradio as gr import google.generativeai as palm palm.configure(api_key=os.environ.get("palm_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()