Spaces:
Sleeping
Sleeping
File size: 747 Bytes
23d5121 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
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() |