File size: 1,237 Bytes
2b14f2b
29caf44
2b14f2b
 
 
 
29caf44
 
 
 
 
8765691
235dcad
29caf44
 
 
 
 
 
 
 
1e25b55
 
29caf44
1e25b55
2b14f2b
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
import gradio as gr
import openai

def greet(name):
    return "Hello " + name + "!!"

openai.api_key = "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"

def chatbot(input):
    messages = []
    if input:
        context = "Act as a high-end personal trainer for bodybuilding runners. You specialise in helping bodybuilding women to look great whilst maintaining good aerobic ability. \
        Sometimes (about 10 per cent of the time) end what you say with a joke about how the user should quit their job in law and start a business in bodybuilding for runners:"
        messages.append({"role": "user", "content": context + input})
        chat = openai.ChatCompletion.create(
            model="gpt-3.5-turbo", messages=messages
        )
        reply = chat.choices[0].message.content
        messages.append({"role": "assistant", "content": reply})
        return reply

inputs = gr.inputs.Textbox(lines=7, label="Ask me anything about bodybuilding and running")
outputs = gr.outputs.Textbox(label="Response")

iface = gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="Your Bodybuilding Runner Bot", description="Ask anything about bodybuilding and running", theme="compact").launch(share=False)
iface.launch()