Spaces:
Runtime error
Runtime error
Update app.py
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950import osimport openaiimport gradio as grfrom dotenv import load_dotenvload_dotenv()key = os.getenv("OPENAI_API_KEY")if not key:raise ValueError()openai.api_key = keydef tutor(input):if not input.strip():return "Valid only"response = openai.ChatCompletion.create(model= "gpt-4o-mini",messages =[{"role" : "system","content" : "You are a PhD level Python Professor who answers questions about Python even a middle schooler can understand.""WHen answering, you give atleast two code examples along with it. Showing the output with the code is a must. you should tell the Exceptions and errors that may occur ""while coding pertaining to the question. "}{"role" : "user","content" : input}],temperature = 0.03,max_tokens=2000,top_p=0.1,frequency_penalty=0.1,presence_penalty=0.95)return response ["choice"][0]["message"]["content"]chatbot_ui = gr.Interface(fn = tutor,inputs= gr.Textbox(lines=3, placeholder = "Ask"),outputs= gr.Textbox(),title="Python Tutor Bot",description ="Ask away")if __name__ == "__main__":chatbot_ui.launch(share=True)
app.py+50