Spaces:
Sleeping
Sleeping
Download app.py from ajoyganguly/Cohort10_PythonBot: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/spaces/ajoyganguly/Cohort10_PythonBot/resolve/main/app.py
- Command line
-
hf download hf://spaces/ajoyganguly/Cohort10_PythonBot/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ajoyganguly/Cohort10_PythonBot/resolve/main/app.py
1 kB
| 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) |