Spaces:
Sleeping
Sleeping
import os | |
import gradio as gr | |
import openai | |
# Set your API key | |
openai.api_key = os.getenv("OPENAI_API_KEY") | |
def fetch_positive_news(): | |
response = openai.ChatCompletion.create( | |
model="gpt-4o", | |
messages=[ | |
{"role": "user", "content": "What was a news story related to AI & ML that happened today?"} | |
], | |
tools=[{"type": "web_search"}], | |
tool_choice="auto" | |
) | |
return response.choices[0].message.content | |
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 GPT-4o with web search.", | |
allow_flagging="never" | |
) | |
demo.launch() | |