CobaltZvc commited on
Commit
dca8737
1 Parent(s): e38d3b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -3
app.py CHANGED
@@ -18,7 +18,9 @@ import warnings
18
  from PIL import Image
19
  from stability_sdk import client
20
  import stability_sdk.interfaces.gooseai.generation.generation_pb2 as generation
21
- import datetime
 
 
22
 
23
  stability_api = client.StabilityInference(
24
  key=st.secrets["STABILITY_KEY"], #os.environ("STABILITY_KEY"), # key=os.environ['STABILITY_KEY'], # API Key reference.
@@ -72,12 +74,42 @@ def search_internet(question):
72
  presence_penalty=0)
73
 
74
  string_temp = response.choices[0].text
75
-
76
  st.write(string_temp)
77
  st.write(snippets)
78
 
79
  # openai.api_key = ""
80
  openai.api_key = st.secrets["OPENAI_KEY"] #os.environ("OPENAI_KEY") #os.environ['OPENAI_KEY']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82
  def openai_response(PROMPT):
83
  response = openai.Image.create(
@@ -173,6 +205,9 @@ if Input_type == 'TEXT':
173
  img = Image.open(io.BytesIO(artifact.binary))
174
  st.image(img)
175
  img.save(str(artifact.seed)+ ".png") # Save our generated images with their seed number as the filename.
 
 
 
176
  except:
177
  st.write('image is being generated please wait...')
178
  def extract_image_description(input_string):
@@ -205,13 +240,18 @@ if Input_type == 'TEXT':
205
  OurURL = YoutubeURL + video_id
206
  st.write(OurURL)
207
  st_player(OurURL)
 
 
208
 
209
- elif ("don't" in string_temp or "internet" in string_temp ):
210
  st.write('searching internet ')
211
  search_internet(question)
 
 
212
 
213
  else:
214
  st.write(string_temp)
 
215
 
216
  elif Input_type == 'SPEECH':
217
  stt_button = Button(label="Speak", width=100)
 
18
  from PIL import Image
19
  from stability_sdk import client
20
  import stability_sdk.interfaces.gooseai.generation.generation_pb2 as generation
21
+ from datetime import datetime
22
+ from google.oauth2 import service_account
23
+ from googleapiclient.discovery import build
24
 
25
  stability_api = client.StabilityInference(
26
  key=st.secrets["STABILITY_KEY"], #os.environ("STABILITY_KEY"), # key=os.environ['STABILITY_KEY'], # API Key reference.
 
74
  presence_penalty=0)
75
 
76
  string_temp = response.choices[0].text
 
77
  st.write(string_temp)
78
  st.write(snippets)
79
 
80
  # openai.api_key = ""
81
  openai.api_key = st.secrets["OPENAI_KEY"] #os.environ("OPENAI_KEY") #os.environ['OPENAI_KEY']
82
+ date_time = str(datetime.now())
83
+
84
+ def g_sheet_log(myinput, output):
85
+ SERVICE_ACCOUNT_FILE = '/content/gsearch-376307-f16abe212f26.json'
86
+
87
+ credentials = service_account.Credentials.from_service_account_file(
88
+ filename=SERVICE_ACCOUNT_FILE
89
+ )
90
+
91
+ service_sheets = build('sheets', 'v4', credentials=credentials)
92
+
93
+ GOOGLE_SHEETS_ID = '16cM8lHm7n_X0ZVLgWfL5fcBhvKWIGO9LQz3zCl2Dn_8'
94
+ worksheet_name = 'Prompt_Logs!'
95
+ cell_range_insert = 'A:C'
96
+
97
+ values = (
98
+ (myinput, output, date_time),
99
+ )
100
+
101
+ value_range_body = {
102
+ 'majorDimension' : 'ROWS',
103
+ 'values' : values
104
+ }
105
+
106
+ service_sheets.spreadsheets().values().append(
107
+ spreadsheetId=GOOGLE_SHEETS_ID,
108
+ valueInputOption='USER_ENTERED',
109
+ range=worksheet_name + cell_range_insert,
110
+ body=value_range_body
111
+ ).execute()
112
+
113
 
114
  def openai_response(PROMPT):
115
  response = openai.Image.create(
 
205
  img = Image.open(io.BytesIO(artifact.binary))
206
  st.image(img)
207
  img.save(str(artifact.seed)+ ".png") # Save our generated images with their seed number as the filename.
208
+ rx = 'Image returned'
209
+ g_sheet_log(mytext, rx)
210
+
211
  except:
212
  st.write('image is being generated please wait...')
213
  def extract_image_description(input_string):
 
240
  OurURL = YoutubeURL + video_id
241
  st.write(OurURL)
242
  st_player(OurURL)
243
+ ry = 'Youtube link and video returned'
244
+ g_sheet_log(mytext, ry)
245
 
246
+ elif ("don't" in string_temp or "internet" in string_temp):
247
  st.write('searching internet ')
248
  search_internet(question)
249
+ rz = 'Internet result returned'
250
+ g_sheet_log(mytext, rz)
251
 
252
  else:
253
  st.write(string_temp)
254
+ g_sheet_log(mytext, string_temp)
255
 
256
  elif Input_type == 'SPEECH':
257
  stt_button = Button(label="Speak", width=100)