CoolFace
Apppublic

GaboDataScientist/ASK_THE_NBA_AI_ORACLE

sourceHugging Faceotherupdated 2y agoView on Hugging Face
0likes
app.py19 linesDownload Raw Back to root
1from openai import OpenAI2import gradio as gr3import os4 5api_key=os.environ.get('GABO_API_KEY')6client = OpenAI(api_key=api_key)7 8messages = [{"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."}]9 10def CustomChatGPT(Ask):11    messages.append({"role":"user","content":Ask})12    completion=client.chat.completions.create(model='gpt-3.5-turbo-0125',messages=messages, max_tokens=100, temperature=0.3)13    reply=completion.choices[0].message.content14    messages.append({"role":"assistant","content":reply})15    return reply16 17gui=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.")18 19gui.launch()