responseapi / app.py
dindizz's picture
Update app.py
ae7e6cc verified
raw
history blame
620 Bytes
import os
import gradio as gr
from openai import OpenAI
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
def fetch_positive_news():
response = client.responses.create(
model="gpt-4o",
input="What was a positive news story that happened today?",
tools=[{"type": "web_search"}]
)
return response.output_text
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"
)
demo.launch()