nknakum16 commited on
Commit
7bbd6ee
·
verified ·
1 Parent(s): cf1baab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py CHANGED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+
4
+ API_URL = "https://cd0a86f6-abd1-45b3-be2a-387efe756d2f-00-dullvvlg7n75.pike.replit.dev/mychat.php"
5
+
6
+
7
+ def chat_with_shakti(message):
8
+ try:
9
+ response = requests.post(API_URL, json={"message": message})
10
+ data = response.json()
11
+ if 'content' in data:
12
+ return data['content']
13
+ elif 'response' in data:
14
+ return data['response']
15
+ elif 'error' in data:
16
+ return f"Error: {data['error']}"
17
+ else:
18
+ return "Unexpected response from Shakti."
19
+ except Exception as e:
20
+ return f"Exception: {str(e)}"
21
+
22
+
23
+ iface = gr.Interface(
24
+ fn=chat_with_shakti,
25
+ inputs=gr.Textbox(lines=2, placeholder="Ask Shakti something..."),
26
+ outputs="text",
27
+ title="Shakti Chatbot",
28
+ description="A powerful AI assistant called Shakti. Enter your message below."
29
+ )
30
+
31
+ iface.launch()