Spaces:
Sleeping
Sleeping
Delete anjibot_logging.py
Browse files- anjibot_logging.py +0 -41
anjibot_logging.py
DELETED
@@ -1,41 +0,0 @@
|
|
1 |
-
# Required imports
|
2 |
-
import streamlit as st
|
3 |
-
from google.oauth2 import service_account
|
4 |
-
from googleapiclient.discovery import build
|
5 |
-
|
6 |
-
# streamlit secrets
|
7 |
-
secrets = st.secrets["google"]
|
8 |
-
creds_info = {
|
9 |
-
"type": secrets["type"],
|
10 |
-
"project_id": secrets["project_id"],
|
11 |
-
"private_key_id": secrets["private_key_id"],
|
12 |
-
"private_key": secrets["private_key"].replace('\\n', '\n'),
|
13 |
-
"client_email": secrets["client_email"],
|
14 |
-
"client_id": secrets["client_id"],
|
15 |
-
"auth_uri": secrets["auth_uri"],
|
16 |
-
"token_uri": secrets["token_uri"],
|
17 |
-
"auth_provider_x509_cert_url": secrets["auth_provider_x509_cert_url"],
|
18 |
-
"client_x509_cert_url": secrets["client_x509_cert_url"]
|
19 |
-
}
|
20 |
-
|
21 |
-
# Create credentials and build the service for spreadsheet login
|
22 |
-
creds = service_account.Credentials.from_service_account_info(creds_info, scopes=['https://www.googleapis.com/auth/spreadsheets'])
|
23 |
-
service = build('sheets', 'v4', credentials=creds)
|
24 |
-
|
25 |
-
# The ID and range of the spreadsheet.
|
26 |
-
SPREADSHEET_ID = st.secrets["app"]["SPREADSHEET_ID"]
|
27 |
-
RANGE_NAME = 'Sheet1!A1'
|
28 |
-
|
29 |
-
def append_to_sheet(user_query, bot_response):
|
30 |
-
values = [
|
31 |
-
[user_query, bot_response]
|
32 |
-
]
|
33 |
-
body = {
|
34 |
-
'values': values
|
35 |
-
}
|
36 |
-
result = service.spreadsheets().values().append(
|
37 |
-
spreadsheetId=SPREADSHEET_ID,
|
38 |
-
range=RANGE_NAME,
|
39 |
-
valueInputOption='RAW',
|
40 |
-
body=body
|
41 |
-
).execute()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|