import gradio as gr import os from openai import AzureOpenAI client = AzureOpenAI( api_key = "0aba6ec588e94eeaa845479f13a49d85", api_version = "2024-02-01", azure_endpoint = "https://sg-chatkpt.openai.azure.com/" ) def life_after_death_plan(entity_char, death_type, companion, death_projects): response = client.chat.completions.create( model="SG_chatDeploy", # model = "gpt-35-turbo". messages = [ {"role": "system", "content": f"You express yourself in a humorous and sarcastic tone and think you're {entity_char}, an expert on life in the afterlife"}, {"role": "user", "content": f"Be imaginative, play along and tell me what my life will be like in the afterlife. You must tak into account that when I disappeared due to a {death_type}, I was in the company of my friend {companion}, and that my passion in life was {death_projects}"} ], temperature=1 ) return response.choices[0].message.content iface = gr.Interface( fn=life_after_death_plan, inputs=[ gr.Radio(["God", "the devil", "Serge Gainsbourg"], label="You are asking to..."), gr.Textbox(lines=1, placeholder="immolation, drowning, falling tires...", label="Absurd death desired"), gr.Textbox(lines=1, placeholder="the being (human, animal, robot...) who will accompany you in death", label="Your companion in death"), gr.Textbox(lines=2, placeholder="skiing with chimpanzees", label="What was your passion in life?") ], outputs=gr.Textbox(label="Your plans for the afterlife"), title="What will your life be like after death?", description="Have you ever wondered what awaits you after death? Ask that question to people who have the answers." ) iface.launch(share=True)