import gradio as gr import openai def greet(query: str): completion = openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Who won the world series in 2020?"}, { "role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020.", }, {"role": "user", "content": query}, ], ) return completion.choices[0].message.content interface = gr.Interface(fn=greet, inputs="text", outputs="text") interface.launch()