Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,19 +2,16 @@ import os
|
|
| 2 |
import gradio as gr
|
| 3 |
from openai import OpenAI
|
| 4 |
|
| 5 |
-
|
| 6 |
-
openai = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
| 7 |
|
| 8 |
-
# Function to fetch positive news using the Responses API
|
| 9 |
def fetch_positive_news():
|
| 10 |
-
response =
|
| 11 |
model="gpt-4o",
|
| 12 |
input="What was a positive news story that happened today?",
|
| 13 |
tools=[{"type": "web_search"}]
|
| 14 |
)
|
| 15 |
return response.output_text
|
| 16 |
|
| 17 |
-
# Gradio Interface
|
| 18 |
demo = gr.Interface(
|
| 19 |
fn=fetch_positive_news,
|
| 20 |
inputs=None,
|
|
@@ -24,5 +21,4 @@ demo = gr.Interface(
|
|
| 24 |
allow_flagging="never"
|
| 25 |
)
|
| 26 |
|
| 27 |
-
|
| 28 |
-
demo.launch()
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
from openai import OpenAI
|
| 4 |
|
| 5 |
+
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
|
|
|
| 6 |
|
|
|
|
| 7 |
def fetch_positive_news():
|
| 8 |
+
response = client.responses.create(
|
| 9 |
model="gpt-4o",
|
| 10 |
input="What was a positive news story that happened today?",
|
| 11 |
tools=[{"type": "web_search"}]
|
| 12 |
)
|
| 13 |
return response.output_text
|
| 14 |
|
|
|
|
| 15 |
demo = gr.Interface(
|
| 16 |
fn=fetch_positive_news,
|
| 17 |
inputs=None,
|
|
|
|
| 21 |
allow_flagging="never"
|
| 22 |
)
|
| 23 |
|
| 24 |
+
demo.launch()
|
|
|