thanhnt-cf commited on
Commit
7865490
·
1 Parent(s): ebe82af

add authentication for gradio

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -5,8 +5,13 @@ from llm_api.exceptions import RefusalError
5
  # from llm_api.langchain_api import extract_info, follow_structure
6
  from llm_api.native_api import extract_info, follow_structure
7
  from openai import BadRequestError
 
8
 
9
 
 
 
 
 
10
  load_dotenv('.env', override=True)
11
  garment_categories = ['Auto', 'Upper Garment', 'Lower Garment', 'Hat', 'Luggage', 'Handbag', 'Makeup', 'Chair', 'Carpet', 'Watch', 'Cookware', 'Tableware', 'Sleepware', 'BathroomItem']
12
  schema_categories = ['Auto', 'UpperGarmentProperties', 'LowerGarmentProperties', 'HatProperties', 'LuggageProperties', 'HandbagProperties', 'MakeupProperties', 'ChairProperties', 'CarpetProperties', 'WatchProperties', 'CookwareProperties', 'TablewareProperties', 'SleepwareProperties', 'BathroomItemProperties']
@@ -113,9 +118,11 @@ with gr.Blocks(title='Internal Demo for Attribution') as demo:
113
  structured_schema = gr.TextArea(label='Structured Schema', placeholder='Schema', visible=True, value=schema_structured_text, interactive=True)
114
 
115
  button_extract.click(extract_free_fn, [gallery, category,provider, free_schema], [status_free_text, free_attributes, probs_text])
116
- button_follow.click(follow_schema_fn, [free_attributes, category, provider, probs_text, structured_schema], [status_structured_text, schema_attributes])
 
 
117
 
118
  # demo.launch(server_name="0.0.0.0", server_port=7688, share=False, ssl_verify=True, ssl_certfile=None, ssl_keyfile=None, auth=None)
119
  # demo.launch(server_name="0.0.0.0", server_port=7860, share=False, ssl_verify=False, ssl_certfile="server.crt", ssl_keyfile="server.key", auth=None)
120
- demo.launch()
121
 
 
5
  # from llm_api.langchain_api import extract_info, follow_structure
6
  from llm_api.native_api import extract_info, follow_structure
7
  from openai import BadRequestError
8
+ import os
9
 
10
 
11
+ # Load environment variables
12
+ attr_user = os.getenv('ATTR_USER')
13
+ attr_pass = os.getenv('ATTR_PASS')
14
+
15
  load_dotenv('.env', override=True)
16
  garment_categories = ['Auto', 'Upper Garment', 'Lower Garment', 'Hat', 'Luggage', 'Handbag', 'Makeup', 'Chair', 'Carpet', 'Watch', 'Cookware', 'Tableware', 'Sleepware', 'BathroomItem']
17
  schema_categories = ['Auto', 'UpperGarmentProperties', 'LowerGarmentProperties', 'HatProperties', 'LuggageProperties', 'HandbagProperties', 'MakeupProperties', 'ChairProperties', 'CarpetProperties', 'WatchProperties', 'CookwareProperties', 'TablewareProperties', 'SleepwareProperties', 'BathroomItemProperties']
 
118
  structured_schema = gr.TextArea(label='Structured Schema', placeholder='Schema', visible=True, value=schema_structured_text, interactive=True)
119
 
120
  button_extract.click(extract_free_fn, [gallery, category,provider, free_schema], [status_free_text, free_attributes, probs_text])
121
+ button_follow.click(follow_schema_fn, [free_attributes, provider, probs_text, structured_schema], [status_structured_text, schema_attributes])
122
+
123
+ auth = (attr_user, attr_pass)
124
 
125
  # demo.launch(server_name="0.0.0.0", server_port=7688, share=False, ssl_verify=True, ssl_certfile=None, ssl_keyfile=None, auth=None)
126
  # demo.launch(server_name="0.0.0.0", server_port=7860, share=False, ssl_verify=False, ssl_certfile="server.crt", ssl_keyfile="server.key", auth=None)
127
+ demo.launch(auth=auth)
128