Spaces:
Sleeping
Sleeping
| import os | |
| from openai import OpenAI | |
| import gradio as gr | |
| # Create OpenAI client | |
| client = OpenAI() | |
| # Function to ask the app | |
| def ask_app(question): | |
| try: | |
| response = client.responses.create( | |
| prompt={ | |
| #change this id | |
| "id": "pmpt_69f6088a6d108197a2f121d4e4f3d5530621b9befb1a72f2", | |
| "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 Bot", | |
| description="Ask a question and get answers from your saved prompt + vector store." | |
| ) | |
| demo.launch(share=True) |