Spaces:
Runtime error
Runtime error
File size: 1,084 Bytes
fefd935 716319a fefd935 716319a fefd935 e3e8cfd fefd935 1bd5b44 f83f240 fefd935 818ef66 fefd935 9877be6 fefd935 e9febe7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
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() |