colin4554 commited on
Commit
23536d8
1 Parent(s): fdea788

update firestore

Browse files
app.py CHANGED
@@ -3,6 +3,8 @@ import os
3
  from openai import AzureOpenAI
4
 
5
  from functions import call_function
 
 
6
 
7
  st.title("SupportFlow Demo")
8
  # when will my order be delivered?, colin.flueck@gmail.com W123123
@@ -72,6 +74,14 @@ functions = [
72
  }
73
  ]
74
 
 
 
 
 
 
 
 
 
75
  client = AzureOpenAI(
76
  api_key=os.environ['OPENAI_API_KEY'],
77
  api_version="2023-07-01-preview",
@@ -139,7 +149,14 @@ if prompt := st.chat_input("How can we help you today?"):
139
 
140
  if function_response["name"] is not None and function_response["name"] == "refer_to_human_agent":
141
  print("connect to human agent")
 
142
  st.info('You will be connected with an agent shortly', icon="ℹ️")
 
 
 
 
 
 
143
  else:
144
  message_placeholder = st.empty()
145
  full_message = ""
 
3
  from openai import AzureOpenAI
4
 
5
  from functions import call_function
6
+ import firebase_admin
7
+ from firebase_admin import credentials, firestore
8
 
9
  st.title("SupportFlow Demo")
10
  # when will my order be delivered?, colin.flueck@gmail.com W123123
 
74
  }
75
  ]
76
 
77
+ cred = credentials.Certificate("supportflow-4851d-firebase-adminsdk-cdrzu-bf620a4b52.json")
78
+ try:
79
+ app = firebase_admin.initialize_app(cred)
80
+ except Exception:
81
+ pass
82
+
83
+ db = firestore.client()
84
+
85
  client = AzureOpenAI(
86
  api_key=os.environ['OPENAI_API_KEY'],
87
  api_version="2023-07-01-preview",
 
149
 
150
  if function_response["name"] is not None and function_response["name"] == "refer_to_human_agent":
151
  print("connect to human agent")
152
+ print(function_response["name"])
153
  st.info('You will be connected with an agent shortly', icon="ℹ️")
154
+
155
+ # Get the document to update
156
+ doc_ref = db.collection('handoffs').document('conversation')
157
+
158
+ # Update the document
159
+ doc_ref.update({'summary': str(function_response["content"]), 'message_history': st.session_state.messages})
160
  else:
161
  message_placeholder = st.empty()
162
  full_message = ""
functions.py CHANGED
@@ -186,4 +186,4 @@ def get_product_listing(sku: str):
186
 
187
 
188
  def refer_to_human_agent(summary: str):
189
- return {"role": "function", "content": summary, "name": "refer_to_human_agent"}
 
186
 
187
 
188
  def refer_to_human_agent(summary: str):
189
+ return summary
requirements.txt CHANGED
@@ -2,4 +2,5 @@ openai==1.3.3
2
  streamlit~=1.28.2
3
  pandas~=2.1.3
4
  requests~=2.31.0
5
- fuzzywuzzy~=0.18.0
 
 
2
  streamlit~=1.28.2
3
  pandas~=2.1.3
4
  requests~=2.31.0
5
+ fuzzywuzzy~=0.18.0
6
+ firebase_admin==5.0.1
supportflow-4851d-firebase-adminsdk-cdrzu-bf620a4b52.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "type": "service_account",
3
+ "project_id": "supportflow-4851d",
4
+ "private_key_id": "bf620a4b5240ab4a898145aeb53735073d8f2020",
5
+ "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDvyurE/WJzsb08\nKTrn/i6688BiIDIqBgN3R71m+Y165M69KoqH/oJLi4PqmbOlv/zLmwjI4vyxUJo3\nKKE2pTETlOIC1hvxbufFnaryWS30f7rooWkxxJr2GmOAxgikp/3LDFjg1mVTaJQG\nTMPeJ9dMPUrGdVg2VWD9Pn0EhWjBt5595Yqz5CBFSFZ39iNWLUHhlblrr4Qc52AG\nxd/B/yso7FvzQcqVMKt6P8TRcGSAvtOr8Juq9d3vTpe3oRKbiJKiJHGDwRJjDvpb\nX5Ri66cfogH91YynwxggRnaKKZXfkhIoJeMRR8QaVJ4OKkRSJ5EGddMWpMf2/wXf\nta7BFndBAgMBAAECggEAL3vxgwpBH3NsK3hnqY6QTuWbbGL/RAqWT53FcBmNTm92\nUAfXUGhSAWcye3et1y3+P4xnEC7AxtUVAMS7LeDG59+E5PZkqKnjXCLleeG2g7Ly\nfoQOGnSaEg92Mkck6YQ5seZzSCy0enCcVWYIqFqf3AFMKCIPEo1ULDneVFGdxbQ2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HB5Q6p7P2K3i8CxKBYM40=\n-----END PRIVATE KEY-----\n",
6
+ "client_email": "firebase-adminsdk-cdrzu@supportflow-4851d.iam.gserviceaccount.com",
7
+ "client_id": "105720102348271033803",
8
+ "auth_uri": "https://accounts.google.com/o/oauth2/auth",
9
+ "token_uri": "https://oauth2.googleapis.com/token",
10
+ "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
11
+ "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-cdrzu%40supportflow-4851d.iam.gserviceaccount.com",
12
+ "universe_domain": "googleapis.com"
13
+ }