Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,25 @@ import os
|
|
3 |
import json
|
4 |
import requests
|
5 |
import xml.etree.ElementTree as ET
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# os.getenv("API_URL") + "/generate_stream"
|
8 |
API_URL = "https://api.openai.com/v1/chat/completions"
|
|
|
3 |
import json
|
4 |
import requests
|
5 |
import xml.etree.ElementTree as ET
|
6 |
+
from pydrive.auth import GoogleAuth
|
7 |
+
from pydrive.drive import GoogleDrive
|
8 |
+
|
9 |
+
# Google Drive ile kimlik doğrulaması yapma
|
10 |
+
gauth = GoogleAuth()
|
11 |
+
gauth.LocalWebserverAuth()
|
12 |
+
drive = GoogleDrive(gauth)
|
13 |
+
|
14 |
+
def save_to_drive(chat_history):
|
15 |
+
# Sohbet geçmişini bir dosyaya kaydetme
|
16 |
+
with open('chat_history.txt', 'w') as f:
|
17 |
+
for message in chat_history:
|
18 |
+
f.write(f"{message['role']}: {message['content']}\n")
|
19 |
+
|
20 |
+
# Dosyayı Google Drive'a yükleme
|
21 |
+
file = drive.CreateFile({'title': 'chat_history.txt'})
|
22 |
+
file.SetContentFile('chat_history.txt')
|
23 |
+
file.Upload()
|
24 |
+
return "Sohbet geçmişi Google Drive'a yüklendi."
|
25 |
|
26 |
# os.getenv("API_URL") + "/generate_stream"
|
27 |
API_URL = "https://api.openai.com/v1/chat/completions"
|