File size: 1,761 Bytes
6767da3
06259f3
 
6767da3
06259f3
7985f00
06259f3
c42b9d4
06259f3
6767da3
06259f3
 
 
 
9efc2ac
 
6f3b618
06259f3
 
 
 
 
 
 
 
9efc2ac
 
 
 
06259f3
9efc2ac
 
 
06259f3
 
7985f00
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
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)