Spaces:
Running
Running
carbonnnnn
commited on
Commit
•
4e9b3f7
1
Parent(s):
7117f9e
update app
Browse files
README.md
CHANGED
@@ -5,6 +5,6 @@ colorFrom: red
|
|
5 |
colorTo: indigo
|
6 |
sdk: gradio
|
7 |
sdk_version: 4.42.0
|
8 |
-
app_file:
|
9 |
pinned: false
|
10 |
---
|
|
|
5 |
colorTo: indigo
|
6 |
sdk: gradio
|
7 |
sdk_version: 4.42.0
|
8 |
+
app_file: app_drive.py
|
9 |
pinned: false
|
10 |
---
|
driveapi/__pycache__/drive.cpython-310.pyc
CHANGED
Binary files a/driveapi/__pycache__/drive.cpython-310.pyc and b/driveapi/__pycache__/drive.cpython-310.pyc differ
|
|
driveapi/__pycache__/drive_database.cpython-310.pyc
ADDED
Binary file (982 Bytes). View file
|
|
driveapi/drive.py
CHANGED
@@ -16,12 +16,16 @@ service = build('drive', 'v3', credentials=credentials)
|
|
16 |
|
17 |
logs_id = os.environ.get('LOGS_ID')
|
18 |
|
19 |
-
# Save Logs
|
20 |
def upload_chat_to_drive(chat_history, file_name):
|
21 |
# Convert chat history to CSV
|
22 |
csv_output = io.StringIO()
|
23 |
-
writer = csv.writer(csv_output)
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
25 |
csv_output.seek(0)
|
26 |
|
27 |
# File metadata
|
@@ -31,11 +35,16 @@ def upload_chat_to_drive(chat_history, file_name):
|
|
31 |
'parents': [logs_id]
|
32 |
}
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
39 |
## Read PDF files
|
40 |
def download_file(file_id):
|
41 |
service = build('drive', 'v3', credentials=credentials)
|
|
|
16 |
|
17 |
logs_id = os.environ.get('LOGS_ID')
|
18 |
|
|
|
19 |
def upload_chat_to_drive(chat_history, file_name):
|
20 |
# Convert chat history to CSV
|
21 |
csv_output = io.StringIO()
|
22 |
+
writer = csv.writer(csv_output, quoting=csv.QUOTE_ALL)
|
23 |
+
|
24 |
+
for row in chat_history:
|
25 |
+
# Ensure all items in the row are strings and handle potential encoding issues
|
26 |
+
encoded_row = [str(item).encode('utf-8', errors='replace').decode('utf-8') for item in row]
|
27 |
+
writer.writerow(encoded_row)
|
28 |
+
|
29 |
csv_output.seek(0)
|
30 |
|
31 |
# File metadata
|
|
|
35 |
'parents': [logs_id]
|
36 |
}
|
37 |
|
38 |
+
try:
|
39 |
+
# Upload file
|
40 |
+
media = MediaIoBaseUpload(csv_output, mimetype='text/csv', resumable=True)
|
41 |
+
file = service.files().create(body=file_metadata, media_body=media, fields='id').execute()
|
42 |
+
print(f'File ID: {file.get("id")}')
|
43 |
+
return file.get('id')
|
44 |
+
except Exception as e:
|
45 |
+
print(f"An error occurred while uploading to Google Drive: {e}")
|
46 |
+
return None
|
47 |
+
|
48 |
## Read PDF files
|
49 |
def download_file(file_id):
|
50 |
service = build('drive', 'v3', credentials=credentials)
|
lc_base/__pycache__/dnd_database.cpython-310.pyc
CHANGED
Binary files a/lc_base/__pycache__/dnd_database.cpython-310.pyc and b/lc_base/__pycache__/dnd_database.cpython-310.pyc differ
|
|
requirements.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
faiss-gpu==1.7.2
|
2 |
-
gradio==4.
|
3 |
pycryptodome==3.20.0
|
4 |
tiktoken==0.5.1
|
5 |
PyPDF2==3.0.1
|
|
|
1 |
faiss-gpu==1.7.2
|
2 |
+
gradio==4.43.0
|
3 |
pycryptodome==3.20.0
|
4 |
tiktoken==0.5.1
|
5 |
PyPDF2==3.0.1
|