File size: 1,907 Bytes
3807be9
 
 
 
9883ccd
3807be9
 
 
9883ccd
 
01ad2ee
45f28ca
739289f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45f28ca
 
 
01ad2ee
9883ccd
 
 
 
739289f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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'")