Skip to content

Commit

Permalink
Merge pull request #151 from eye-on-surveillance/AI/misc-bugs
Browse files Browse the repository at this point in the history
AI/misc-bugs
  • Loading branch information
ayyubibrahimi authored Nov 14, 2023
2 parents e088d23 + 33b7ca7 commit 330f531
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions packages/googlecloud/functions/getanswer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,13 @@
supabase_key = os.environ.get("SUPABASE_SERVICE_KEY_STAGING")
supabase = create_client(supabase_url, supabase_key)

def update_supabase(response, query, response_type):
# Insert data into the Supabase table
result = supabase.table('cards').insert({'title': query, 'card_type': response_type, 'responses': response}).execute()

# Check for errors in the response
if result.status_code != 200: # or another appropriate success code
# Log the error or handle it as per your application logic
logging.error(f"Failed to update Supabase: {result}")
else:
# Handle successful insertion
def update_supabase(supabase, response, query, response_type):
try:
response = supabase.table('cards').insert({'title': query, 'card_type': response_type, 'responses': response}).execute()
logging.info("Data successfully inserted into Supabase")
except Exception as e:
logging.error(f"Failed to update Supabase: {e}")


@functions_framework.http
def getanswer(request):
Expand Down

0 comments on commit 330f531

Please sign in to comment.