ReddyYesh commited on
Commit
d8a4f79
·
verified ·
1 Parent(s): 029ee28

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -0
app.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ import json
4
+
5
+ # Replace with your Dialogflow endpoint
6
+ DIALOGFLOW_ENDPOINT = 'https://your-dialogflow-endpoint'
7
+
8
+ def send_to_dialogflow(query_text):
9
+ headers = {
10
+ 'Authorization': 'Bearer your-dialogflow-api-key',
11
+ 'Content-Type': 'application/json'
12
+ }
13
+
14
+ data = {
15
+ "queryInput": {
16
+ "text": {
17
+ "text": query_text,
18
+ "languageCode": "en"
19
+ }
20
+ }
21
+ }
22
+
23
+ response = requests.post(DIALOGFLOW_ENDPOINT, headers=headers, data=json.dumps(data))
24
+ return response.json()
25
+
26
+ def get_match_details(query_text):
27
+ # Dummy function for demonstration
28
+ return f"Details for the query: {query_text}"
29
+
30
+ st.title("Match Details Query Interface")
31
+
32
+ query_text = st.text_input("Enter your query:")
33
+
34
+ if st.button("Send"):
35
+ if query_text:
36
+ dialogflow_response = send_to_dialogflow(query_text)
37
+
38
+ intent_name = dialogflow_response['queryResult']['intent']['displayName']
39
+ fulfillment_text = dialogflow_response['queryResult']['fulfillmentText']
40
+
41
+ if intent_name == 'GetMatchDetails':
42
+ response_text = get_match_details(query_text)
43
+ else:
44
+ response_text = f"Unhandled intent: {intent_name}"
45
+
46
+ st.write(response_text)
47
+ else:
48
+ st.error("Please enter a query.")