import os import openai from openai.error import OpenAIError import datetime import gradio as gr import json from jinja2 import Template import requests def greet(name): return "Hello " + name + "!" def login_auth(username, password): """ airtable_endpoint = f'https://api.airtable.com/v0/{base_id}/{users_table_name}' # Query the 'users' table to check for a match with the provided username and password params = { 'filterByFormula': f'AND(user_name = "{username}", password = "{password}")' } response = requests.get(airtable_endpoint, headers=headers, params=params) if response.status_code == 200: data = response.json() #If the matching user/password record is found: if data.get('records'): user_details = data['records'][0]['fields'] log_login(username) #Set the global logged_in_user variable. This used in the append_to_at_qalog function to track what user asked the question global logged_in_user,user_user_role, user_output_format, user_school user_user_role = user_details.get('user_role') user_output_format = user_details.get('output_format') user_school = user_details.get('school_name', [None])[0] logged_in_user = username """ if username == password: return True print(f"Invalid user/password combination") return False CIMStheme = gr.themes.Soft().set(button_primary_background_fill='#6562F4') with gr.Blocks(CIMStheme) as demo: name = gr.Textbox(label="Name") output = gr.Textbox(label="Output Box") greet_btn = gr.Button("Greet") greet_btn.click(fn=greet, inputs=name, outputs=output, api_name="greet") demo.launch(auth=login_auth,auth_message= "Enter your username and password that you received from CIMS.AI. To request a login, please email 'info@cims.ai'")