Update app.py
Browse files
app.py
CHANGED
@@ -3,29 +3,7 @@ import os
|
|
3 |
import json
|
4 |
import requests
|
5 |
import xml.etree.ElementTree as ET
|
6 |
-
from google.oauth2 import service_account
|
7 |
-
from googleapiclient.discovery import build
|
8 |
-
from googleapiclient.http import MediaFileUpload
|
9 |
|
10 |
-
# Google Drive API ile kimlik doğrulaması yapma
|
11 |
-
SERVICE_ACCOUNT_FILE = 'path/to/your-service-account-file.json'
|
12 |
-
SCOPES = ['https://www.googleapis.com/auth/drive.file']
|
13 |
-
|
14 |
-
credentials = service_account.Credentials.from_service_account_file(
|
15 |
-
SERVICE_ACCOUNT_FILE, scopes=SCOPES)
|
16 |
-
service = build('drive', 'v3', credentials=credentials)
|
17 |
-
|
18 |
-
def save_to_drive(chat_history):
|
19 |
-
# Sohbet geçmişini bir dosyaya kaydetme
|
20 |
-
with open('chat_history.txt', 'w') as f:
|
21 |
-
for message in chat_history:
|
22 |
-
f.write(f"{message['role']}: {message['content']}\n")
|
23 |
-
|
24 |
-
file_metadata = {'name': 'chat_history.txt'}
|
25 |
-
media = MediaFileUpload('chat_history.txt', mimetype='text/plain')
|
26 |
-
file = service.files().create(body=file_metadata, media_body=media, fields='id').execute()
|
27 |
-
|
28 |
-
return f"Sohbet geçmişi Google Drive'a yüklendi. Dosya ID: {file.get('id')}"
|
29 |
|
30 |
# os.getenv("API_URL") + "/generate_stream"
|
31 |
API_URL = "https://api.openai.com/v1/chat/completions"
|
|
|
3 |
import json
|
4 |
import requests
|
5 |
import xml.etree.ElementTree as ET
|
|
|
|
|
|
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
# os.getenv("API_URL") + "/generate_stream"
|
9 |
API_URL = "https://api.openai.com/v1/chat/completions"
|