Update run.py
Browse files
run.py
CHANGED
@@ -3,7 +3,21 @@ import os
|
|
3 |
import gradio as gr
|
4 |
import json
|
5 |
from huggingface_hub import InferenceClient
|
|
|
|
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
path='/Users/thiloid/Desktop/LSKI/ole_nest/Chatbot/LLM/chromaTS'
|
8 |
if(os.path.exists(path)==False): path="/home/user/app/chromaTS"
|
9 |
|
@@ -75,6 +89,7 @@ def response(
|
|
75 |
output = ""
|
76 |
for response in stream:
|
77 |
output += response.token.text
|
|
|
78 |
yield output
|
79 |
#output=output+"\n\n<br><details open><summary><strong>Sources</strong></summary><br><ul>"+ "".join(["<li>" + s + "</li>" for s in combination])+"</ul></details>"
|
80 |
yield output
|
|
|
3 |
import gradio as gr
|
4 |
import json
|
5 |
from huggingface_hub import InferenceClient
|
6 |
+
import gspread
|
7 |
+
from oauth2client.service_account import ServiceAccountCredentials
|
8 |
|
9 |
+
# Google Sheets setup
|
10 |
+
scope = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/drive"]
|
11 |
+
creds = ServiceAccountCredentials.from_json_keyfile_name('/home/user/app/chromaold/credentials.json', scope)
|
12 |
+
client = gspread.authorize(creds)
|
13 |
+
sheet = client.open("nestolechatbot").sheet1 # Open the sheet
|
14 |
+
|
15 |
+
def save_to_sheet(date,name, message):
|
16 |
+
# Write user input to the Google Sheet
|
17 |
+
sheet.append_row([date,name, message])
|
18 |
+
return f"Thanks {name}, your message has been saved!"
|
19 |
+
|
20 |
+
|
21 |
path='/Users/thiloid/Desktop/LSKI/ole_nest/Chatbot/LLM/chromaTS'
|
22 |
if(os.path.exists(path)==False): path="/home/user/app/chromaTS"
|
23 |
|
|
|
89 |
output = ""
|
90 |
for response in stream:
|
91 |
output += response.token.text
|
92 |
+
save_to_sheet("date",prompt, output)
|
93 |
yield output
|
94 |
#output=output+"\n\n<br><details open><summary><strong>Sources</strong></summary><br><ul>"+ "".join(["<li>" + s + "</li>" for s in combination])+"</ul></details>"
|
95 |
yield output
|