Delete app.py
Browse files
app.py
DELETED
|
@@ -1,50 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import requests
|
| 3 |
-
import uuid
|
| 4 |
-
|
| 5 |
-
# Langflow API details
|
| 6 |
-
URL = "https://aws-us-east-2.langflow.datastax.com/lf/b2ab904a-f8b6-4852-8986-7a35157bbcea/api/v1/run/820d2db4-35df-4206-9f1b-32facd9da870"
|
| 7 |
-
|
| 8 |
-
HEADERS = {
|
| 9 |
-
"X-DataStax-Current-Org": "9e18b96d-ab61-447d-b25b-0e0a4e0812bd",
|
| 10 |
-
"Authorization": "Bearer AstraCS:seCzCQDJWdRXzTSeoHyMJvFB:515563191b0ebed2cc20468c31ac42a2b44d6e5550121b4588d2fbf0df332e47",
|
| 11 |
-
"Content-Type": "application/json",
|
| 12 |
-
"Accept": "application/json",
|
| 13 |
-
}
|
| 14 |
-
|
| 15 |
-
def ask_dpdp(question):
|
| 16 |
-
payload = {
|
| 17 |
-
"input_type": "chat",
|
| 18 |
-
"output_type": "chat",
|
| 19 |
-
"input_value": question,
|
| 20 |
-
"session_id": str(uuid.uuid4())
|
| 21 |
-
}
|
| 22 |
-
|
| 23 |
-
try:
|
| 24 |
-
response = requests.post(URL, json=payload, headers=HEADERS)
|
| 25 |
-
response.raise_for_status()
|
| 26 |
-
data = response.json()
|
| 27 |
-
|
| 28 |
-
# Safe extraction of answer
|
| 29 |
-
return data.get("outputs", [{}])[0].get("outputs", [{}])[0].get("results", {}).get("message", {}).get("text", "No response received")
|
| 30 |
-
|
| 31 |
-
except Exception as e:
|
| 32 |
-
return f"Error: {str(e)}"
|
| 33 |
-
|
| 34 |
-
# Gradio UI
|
| 35 |
-
interface = gr.Interface(
|
| 36 |
-
fn=ask_dpdp,
|
| 37 |
-
inputs=gr.Textbox(
|
| 38 |
-
lines=2,
|
| 39 |
-
placeholder="Ask anything about DPDP Act..."
|
| 40 |
-
),
|
| 41 |
-
outputs=gr.Textbox(
|
| 42 |
-
lines=8,
|
| 43 |
-
label="Answer"
|
| 44 |
-
),
|
| 45 |
-
title="📜 DPDP Act Awareness Assistant",
|
| 46 |
-
description="Ask questions related to India's Digital Personal Data Protection (DPDP) Act."
|
| 47 |
-
)
|
| 48 |
-
|
| 49 |
-
# Launch with public URL
|
| 50 |
-
interface.launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|