File size: 742 Bytes
23d5121
 
2cdae63
23d5121
2cdae63
 
23d5121
 
2cdae63
23d5121
2cdae63
a091a8b
2cdae63
 
 
23d5121
2cdae63
23d5121
 
 
 
 
 
2cdae63
23d5121
 
 
ae7e6cc
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
29
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()