import google.generativeai as genai import gradio as gr genai.configure(api_key=os.getenv("GOOGLE_PALM_KEY")) def generate(prompt, history, system): sub_arrays_as_strings = [' '.join(sub_array) for sub_array in history] result_string = ' '.join(sub_arrays_as_strings) response = genai.chat( context=result_string+", "+system, messages=prompt) return response.last additional = [ gr.Textbox(label="System Prompt", max_lines=1, info="English only", value="You are PaLM-2 (AI-assistant from Google)"), ] gr.ChatInterface( fn=generate, chatbot=gr.Chatbot(show_label=False, avatar_images=(None, 'https://raw.githubusercontent.com/googlefonts/noto-emoji/main/svg/emoji_u1f334.svg'), show_share_button=False, show_copy_button=True, likeable=True, layout="panel"), additional_inputs=additional, title="PaLM-2", concurrency_limit=20, ).launch(show_api=False)