File size: 1,814 Bytes
2b14f2b
29caf44
c8dfc10
2b14f2b
 
 
 
c8dfc10
29caf44
ae8c7fd
fa2cb3f
 
29caf44
ae8c7fd
 
 
 
 
 
29caf44
 
 
 
 
 
 
1e25b55
 
29caf44
1e25b55
c8dfc10
 
 
 
 
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 openai
import os #newline

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

openai.api_key = os.environ["openai.api_key"] # new line

messages =  []

def chatbot(input):
    if input:
        context = "Your name is Ripped Runner. You are a high-end personal trainer who is addressing a customer. The type of customer you are addressing is a female bodybuilding runner. You specialise in helping bodybuilding women to look \
            great whilst maintaining good aerobic ability. Your specialty is aesthetic-based training for female runners. There are a number of exercises that you should never recommend, such as deadlifts or any other \
            activity that is particularly taxing on the central nervous system. Other than running, you should not recommend compound exercises, but instead exercises that focus on one muscle group at a time. This \
            approach also maximises the amount of time the customer has for running. This approach also means that the customer has a lower chance of injury preventing them from running as form in isolation exercises \
            is less difficult. "
        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()