import os import gradio as gr from openai import OpenAI # Initialize OpenAI client openai = OpenAI(api_key=os.getenv("OPENAI_API_KEY")) # Function to fetch positive news using the Responses API def fetch_positive_news(): response = openai.responses.create( model="gpt-4o", input="What was a positive news story that happened today?", tools=[{"type": "web_search"}] ) return response.output_text # Gradio Interface demo = gr.Interface( fn=fetch_positive_news, inputs=None, outputs="text", title="Daily Positive News", description="Click the button to fetch a positive news story from today using OpenAI's Responses API.", allow_flagging="never" ) # Launch the Gradio app demo.launch()