Thiloid commited on
Commit
d6d6731
·
verified ·
1 Parent(s): f76517a

Update run.py

Browse files
Files changed (1) hide show
  1. run.py +3 -14
run.py CHANGED
@@ -8,17 +8,6 @@ from oauth2client.service_account import ServiceAccountCredentials
8
  from datetime import datetime
9
  from google.oauth2 import service_account
10
 
11
- import socket
12
-
13
- def get_local_ip(request: gr.Request):
14
- """Get the local IP address."""
15
- client_ip = request.client.host
16
- local_ip = socket.gethostbyname(socket.gethostbyname(""))
17
- x_forwarded_for = request.headers.get('x-forwarded-for')
18
- print("client_ip", client_ip, text)
19
- print("x_forwarded_for", x_forwarded_for)
20
- return local_ip
21
- val=get_local_ip()
22
  # Google Sheets setup
23
  scope = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/drive"]
24
  key1 = os.getenv("key1")
@@ -70,9 +59,9 @@ creds = service_account.Credentials.from_service_account_info(json_data, scopes=
70
  client = gspread.authorize(creds)
71
  sheet = client.open("nestolechatbot").sheet1 # Open the sheet
72
 
73
- def save_to_sheet(date,name, message,val):
74
  # Write user input to the Google Sheet
75
- sheet.append_row([date,name, message,val])
76
  return f"Thanks {name}, your message has been saved!"
77
 
78
 
@@ -179,7 +168,7 @@ def response(
179
  #output=output+"\n\n<br><details open><summary><strong>Sources</strong></summary><br><ul>"+ "".join(["<li>" + s + "</li>" for s in combination])+"</ul></details>"
180
  # Get current date and time
181
  now = str(datetime.now())
182
- save_to_sheet(now,prompt, output, val)
183
  yield output
184
 
185
  gr.ChatInterface(response, chatbot=gr.Chatbot(value=[[None,"Herzlich willkommen! Ich bin Chätti ein KI-basiertes Studienassistenzsystem, das für jede Anfrage die am besten Studieninformationen empfiehlt.<br>Erzähle mir, was du gerne tust!"]],render_markdown=True),title="German Studyhelper Chätti").queue().launch(share=True) #False, server_name="0.0.0.0", server_port=7864)
 
8
  from datetime import datetime
9
  from google.oauth2 import service_account
10
 
 
 
 
 
 
 
 
 
 
 
 
11
  # Google Sheets setup
12
  scope = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/drive"]
13
  key1 = os.getenv("key1")
 
59
  client = gspread.authorize(creds)
60
  sheet = client.open("nestolechatbot").sheet1 # Open the sheet
61
 
62
+ def save_to_sheet(date,name, message):
63
  # Write user input to the Google Sheet
64
+ sheet.append_row([date,name, message])
65
  return f"Thanks {name}, your message has been saved!"
66
 
67
 
 
168
  #output=output+"\n\n<br><details open><summary><strong>Sources</strong></summary><br><ul>"+ "".join(["<li>" + s + "</li>" for s in combination])+"</ul></details>"
169
  # Get current date and time
170
  now = str(datetime.now())
171
+ save_to_sheet(now,prompt, output)
172
  yield output
173
 
174
  gr.ChatInterface(response, chatbot=gr.Chatbot(value=[[None,"Herzlich willkommen! Ich bin Chätti ein KI-basiertes Studienassistenzsystem, das für jede Anfrage die am besten Studieninformationen empfiehlt.<br>Erzähle mir, was du gerne tust!"]],render_markdown=True),title="German Studyhelper Chätti").queue().launch(share=True) #False, server_name="0.0.0.0", server_port=7864)