File size: 1,063 Bytes
ec9a5b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
import gradio as gr
from openai import OpenAI

# Load API key from Hugging Face Secrets
# (set OPENAI_API_KEY in your Space settings)
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])

# Function to ask the app
def ask_app(question):
    try:
        response = client.responses.create(
            prompt={
                "id": "pmpt_69f610df1d70819683a15d371bd47ca00b92de12291fced1",
                "version": "1"
            },
            input=question,
            reasoning={"summary": "auto"}
        )
        return response.output_text
    except Exception as e:
        return f"Error: {str(e)}"

# Gradio interface
demo = gr.Interface(
    fn=ask_app,
    inputs=gr.Textbox(
        lines=3,
        placeholder="Type your question here...",
        label="Your Question"
    ),
    outputs=gr.Textbox(
        lines=10,
        label="Answer"
    ),
    title="DDS Cohort 10 2nd App Python Research Bot",
    description="Ask a question and get answers from your saved prompt + vector store."
)

# Launch app
demo.launch(share=True)