Spaces:
Runtime error
Runtime error
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 | |
def chatbot(input): | |
messages = [ | |
{'role':'system', 'content':'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.'}] | |
if input: | |
messages.append({"role": "user", "content": 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() | |