from utils import my_key import gradio import google.generativeai as palm import os def gimi(user, history): palm.configure(api_key = my_key) defaults = { 'model': 'models/text-bison-001', 'temperature': 0.7, 'candidate_count': 1, 'top_k': 40, 'top_p': 0.95, 'max_output_tokens': 1024, 'stop_sequences': [], 'safety_settings': [ {"category": "HARM_CATEGORY_DEROGATORY", "threshold": 4}, {"category": "HARM_CATEGORY_TOXICITY", "threshold": 4}, {"category": "HARM_CATEGORY_VIOLENCE", "threshold": 4}, {"category": "HARM_CATEGORY_SEXUAL", "threshold": 4}, {"category": "HARM_CATEGORY_MEDICAL", "threshold": 4}, {"category": "HARM_CATEGORY_DANGEROUS", "threshold": 4}, ], } prompt = f"""{user}""" response = palm.generate_text( **defaults, prompt=prompt ) gen_response=(response.result) return gen_response demo = gradio.ChatInterface(gimi) demo.launch(share=True)