ashutoshzade commited on
Commit
67f6272
·
verified ·
1 Parent(s): 1adc8be

Added correct authentication

Browse files
Files changed (1) hide show
  1. app.py +24 -2
app.py CHANGED
@@ -6,8 +6,30 @@ For more information on `huggingface_hub` Inference API support, please check th
6
  """
7
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
 
 
 
 
 
 
 
 
9
 
10
- def respond(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  message,
12
  history: list[tuple[str, str]],
13
  system_message,
@@ -43,7 +65,7 @@ def respond(
43
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
44
  """
45
  demo = gr.ChatInterface(
46
- respond,
47
  additional_inputs=[
48
  gr.Textbox(value="You are an expert in generating job descriptions.", label="System message"),
49
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
 
6
  """
7
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
 
9
+ def login_screen():
10
+ username = gr.Textbox("Username: ").value
11
+ password = gr.Textbox("Password: ", type="password").value
12
+ if username == "admin" and password == "pass1234":
13
+ return None # Login successful, no output
14
+ else:
15
+ return "Incorrect credentials. Please try again."
16
 
17
+ def chat(message):
18
+ if not hasattr(chat, 'authorized'):
19
+ chat.authorized = None # Flag for login status
20
+
21
+ if chat.authorized is None:
22
+ response = login_screen()
23
+ if response is None:
24
+ chat.authorized = True
25
+ return "Welcome! How can I help you generate a job description?"
26
+ else:
27
+ return response
28
+ else:
29
+ # Call the actual job description generation function
30
+ return generate_job_description(message, max_tokens, temperature, top_p)
31
+
32
+ def generate_job_description(
33
  message,
34
  history: list[tuple[str, str]],
35
  system_message,
 
65
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
66
  """
67
  demo = gr.ChatInterface(
68
+ chat,
69
  additional_inputs=[
70
  gr.Textbox(value="You are an expert in generating job descriptions.", label="System message"),
71
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),