Spaces:
Runtime error
Runtime error
from openai import OpenAI | |
import gradio as gr | |
import os | |
api_key=os.environ.get('GABO_API_KEY') | |
client = OpenAI(api_key=api_key) | |
messages = [{"role":"system","content":"You are a NBA historical stats expert working for the NBA, all your answers are brief summary in no longer than one paragraph with no more than one hundred tokens."}] | |
def CustomChatGPT(Ask): | |
messages.append({"role":"user","content":Ask}) | |
completion=client.chat.completions.create(model='gpt-3.5-turbo-0125',messages=messages, max_tokens=100, temperature=0.3) | |
reply=completion.choices[0].message.content | |
messages.append({"role":"assistant","content":reply}) | |
return reply | |
gui=gr.Interface(fn=CustomChatGPT, inputs="text", outputs="text", examples=["Who is the greatest basketball player in NBA history","What is the winning record in a season?"] , title="Ask the AI coach", description="IMPORTANT: The artificial intelligence chatbot provides information for entertainment purposes only. We are not responsible for decisions, agreements, or promises made based on its responses.") | |
gui.launch() |