Techperceptech commited on
Commit
5681111
·
verified ·
1 Parent(s): 4716193

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -10
app.py CHANGED
@@ -11,6 +11,10 @@ client = OpenAI(
11
  project=os.getenv('PROJ_KEY')
12
  )
13
 
 
 
 
 
14
  #need to give info on how to convert to CSV
15
  title = "Automated Research Code Tagger"
16
  description = """
@@ -83,20 +87,57 @@ def process_quotes(quotes_file_path, quotes_col_name, tags_string):
83
  quotes_data = quotes_df[quotes_col_name]
84
  quotes_df['Tags'] = quotes_data.apply(tag_quote, args=(tags_list,))
85
  return quotes_df[[quotes_col_name, 'Tags']]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
 
87
- demo = gr.Interface(
88
- fn=process_quotes,
 
89
  inputs=[
90
- gr.File(label="Quotes Excel File"), # File as generated by TFT software
91
- gr.Textbox(label="Name of quotes column"), # use this to identify the col with the quotes
92
- gr.Textbox(label = "List of tags separated by commas")
93
  ],
94
- outputs=gr.Dataframe(headers=["Quote", "Tags"], column_widths=["70%", "30%"], scale=2),
95
- title=title,
96
- description=description
97
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
98
 
99
- demo.launch()
100
 
101
  # For later when I enable usage of own API key
102
  # api_key = gr.Textbox(
 
11
  project=os.getenv('PROJ_KEY')
12
  )
13
 
14
+ # Static Username and Password
15
+ VALID_USERNAME = "tft@perceptech.ai"
16
+ VALID_PASSWORD = "Perceptech@2024!"
17
+
18
  #need to give info on how to convert to CSV
19
  title = "Automated Research Code Tagger"
20
  description = """
 
87
  quotes_data = quotes_df[quotes_col_name]
88
  quotes_df['Tags'] = quotes_data.apply(tag_quote, args=(tags_list,))
89
  return quotes_df[[quotes_col_name, 'Tags']]
90
+
91
+ def authenticate(username, password):
92
+ """Authenticate the user using static username and password"""
93
+ if username == VALID_USERNAME and password == VALID_PASSWORD:
94
+ return True
95
+ else:
96
+ return False
97
+
98
+ def auth_interface(username, password):
99
+ """Handle the authentication and proceed with the main function if valid"""
100
+ if authenticate(username, password):
101
+ return gr.Interface(
102
+ fn=process_quotes,
103
+ inputs=[
104
+ gr.File(label="Quotes Excel File"), # File as generated by TFT software
105
+ gr.Textbox(label="Name of quotes column"), # use this to identify the col with the quotes
106
+ gr.Textbox(label="List of tags separated by commas")
107
+ ],
108
+ outputs=gr.Dataframe(headers=["Quote", "Tags"], column_widths=["70%", "30%"], scale=2),
109
+ title=title,
110
+ description=description
111
+ ).launch()
112
+ else:
113
+ return "Invalid username or password!"
114
 
115
+ # Create the authentication fields before launching the main app
116
+ auth_app = gr.Interface(
117
+ fn=auth_interface,
118
  inputs=[
119
+ gr.Textbox(label="Username", type="text"),
120
+ gr.Textbox(label="Password", type="password")
 
121
  ],
122
+ outputs="text",
123
+ title="Login to Automated Research Code Tagger",
124
+ description="Please enter the correct username and password to access the tool."
125
+ )
126
+
127
+ auth_app.launch()
128
+ # demo = gr.Interface(
129
+ # fn=process_quotes,
130
+ # inputs=[
131
+ # gr.File(label="Quotes Excel File"), # File as generated by TFT software
132
+ # gr.Textbox(label="Name of quotes column"), # use this to identify the col with the quotes
133
+ # gr.Textbox(label = "List of tags separated by commas")
134
+ # ],
135
+ # outputs=gr.Dataframe(headers=["Quote", "Tags"], column_widths=["70%", "30%"], scale=2),
136
+ # title=title,
137
+ # description=description
138
+ # )
139
 
140
+ # demo.launch()
141
 
142
  # For later when I enable usage of own API key
143
  # api_key = gr.Textbox(