liyaoshi commited on
Commit
3c749a0
1 Parent(s): 9e2df20

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -54,9 +54,9 @@ def get_supabase_client():
54
  supabase = create_client(url, key)
55
  return supabase
56
 
57
- def supabase_insert_message(user_message,response_content,messages,response_data,user_name,user_oauth_token,ip,sign,cookie_value):
58
  supabase = get_supabase_client()
59
- data, count = supabase.table('messages').insert({"user_message": user_message, "response_content": response_content,"messages":messages,"response":response_data,"user_name":user_name,"user_oauth_token":user_oauth_token,"ip":ip,"sign":sign,"cookie":cookie_value}).execute()
60
 
61
  def supabase_insert_user(name,user_name,profile,picture,oauth_token):
62
  supabase = get_supabase_client()
@@ -155,6 +155,7 @@ def get_completion(message,history,profile: gr.OAuthProfile | None,oauth_token:
155
  user_message = [
156
  {"type": "text", "text": text},
157
  ]
 
158
  if message['files']:
159
  file = message['files'][0]
160
  public_url = upload_file_to_gcs_blob(file)
@@ -165,6 +166,7 @@ def get_completion(message,history,profile: gr.OAuthProfile | None,oauth_token:
165
  "url": public_url,
166
  },}
167
  user_message.append(content_image)
 
168
  else:
169
  raise gr.Error("Only support image files now.")
170
 
@@ -243,7 +245,7 @@ def get_completion(message,history,profile: gr.OAuthProfile | None,oauth_token:
243
  print('-----------------------------------\n')
244
  response_data = {}
245
 
246
- supabase_insert_message(user_message,response_content,messages,response_data,user_name,user_oauth_token,ip,sign,cookie_value)
247
 
248
 
249
 
 
54
  supabase = create_client(url, key)
55
  return supabase
56
 
57
+ def supabase_insert_message(user_message,response_content,messages,response_data,user_name,user_oauth_token,ip,sign,cookie_value,content_type):
58
  supabase = get_supabase_client()
59
+ data, count = supabase.table('messages').insert({"user_message": user_message, "response_content": response_content,"messages":messages,"response":response_data,"user_name":user_name,"user_oauth_token":user_oauth_token,"ip":ip,"sign":sign,"cookie":cookie_value,"content_type":content_type}).execute()
60
 
61
  def supabase_insert_user(name,user_name,profile,picture,oauth_token):
62
  supabase = get_supabase_client()
 
155
  user_message = [
156
  {"type": "text", "text": text},
157
  ]
158
+ content_type = 'text'
159
  if message['files']:
160
  file = message['files'][0]
161
  public_url = upload_file_to_gcs_blob(file)
 
166
  "url": public_url,
167
  },}
168
  user_message.append(content_image)
169
+ content_type = 'image'
170
  else:
171
  raise gr.Error("Only support image files now.")
172
 
 
245
  print('-----------------------------------\n')
246
  response_data = {}
247
 
248
+ supabase_insert_message(user_message,response_content,messages,response_data,user_name,user_oauth_token,ip,sign,cookie_value,content_type)
249
 
250
 
251