Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import requests | |
| WEBHOOK_URL = "https://pinkonixx.app.n8n.cloud/webhook-test/ai-analyst" | |
| def ask_ai(question): | |
| try: | |
| response = requests.post( | |
| WEBHOOK_URL, | |
| json={"question": question}, | |
| timeout=30 | |
| ) | |
| response.raise_for_status() | |
| data = response.json() | |
| return data.get("answer", "No answer returned.") | |
| except Exception as e: | |
| return f"Error: {e}" | |
| demo = gr.Interface( | |
| fn=ask_ai, | |
| inputs=gr.Textbox(label="Ask a question about book sales"), | |
| outputs=gr.Textbox(label="Answer"), | |
| title="Fatima Aaouaj - Book Sales AI Analyst" | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() |