Komal-patra commited on
Commit
bd4819a
1 Parent(s): d4dcc09
Files changed (1) hide show
  1. app.py +14 -12
app.py CHANGED
@@ -6,9 +6,11 @@ from peft import PeftModel, PeftConfig
6
 
7
  # Hugging Face login
8
  token = os.environ.get("token")
9
- login(token)
10
- print("login is succesful")
11
- max_length=512
 
 
12
 
13
  # Model and tokenizer setup
14
  MODEL_NAME = "google/flan-t5-base"
@@ -18,7 +20,7 @@ base_model = AutoModelForSeq2SeqLM.from_pretrained(MODEL_NAME)
18
  model = PeftModel.from_pretrained(base_model, "Komal-patra/results")
19
 
20
  # Text generation function
21
- def generate_text(prompt, max_length=512):
22
  inputs = tokenizer(prompt, return_tensors="pt")
23
  outputs = model.generate(
24
  input_ids=inputs["input_ids"],
@@ -30,20 +32,20 @@ def generate_text(prompt, max_length=512):
30
  return generated_text
31
 
32
  # Custom CSS for the UI
33
- background_image_path = 'https://www.shlegal-technology.com/sites/default/files/insight/ExploringTheLegislativeBackgroundBANNER.jpg'
34
  custom_css = f"""
35
  .message.pending {{
36
- background: #A8C4D6;
37
  }}
38
  /* Response message */
39
  .message.bot.svelte-1s78gfg.message-bubble-border {{
40
- border-color: #266B99;
41
- background-color: rgba(255, 255, 255, 0.7); /* Make the message box slightly transparent */
42
  }}
43
  /* User message */
44
  .message.user.svelte-1s78gfg.message-bubble-border {{
45
- background: #9DDDF9;
46
- border-color: #9DDDF9;
47
  }}
48
  /* For both user and response message as per the document */
49
  span.md.svelte-8tpqd2.chatbot.prose p {{
@@ -51,12 +53,12 @@ span.md.svelte-8tpqd2.chatbot.prose p {{
51
  }}
52
  /* Chatbot container */
53
  .gradio-container {{
54
- background: #1c1c1c; /* Dark background */
55
  color: white; /* Light text color */
56
  background-image: url('{background_image_path}'); /* Add background image */
57
  background-size: cover; /* Cover the entire container */
58
  background-position: center; /* Center the image */
59
  background-repeat: no-repeat; /* Do not repeat the image */
 
60
  }}
61
  /* RED (Hex: #DB1616) for action buttons and links only */
62
  .clear-btn {{
@@ -124,4 +126,4 @@ with gr.Blocks(css=custom_css) as demo:
124
  )
125
  clear.click(lambda: None, None, chatbot, queue=False)
126
 
127
- demo.launch()
 
6
 
7
  # Hugging Face login
8
  token = os.environ.get("token")
9
+ if token:
10
+ login(token)
11
+ print("Login is successful")
12
+ else:
13
+ print("Token not found. Please set your token in the environment variables.")
14
 
15
  # Model and tokenizer setup
16
  MODEL_NAME = "google/flan-t5-base"
 
20
  model = PeftModel.from_pretrained(base_model, "Komal-patra/results")
21
 
22
  # Text generation function
23
+ def generate_text(prompt, max_length=150):
24
  inputs = tokenizer(prompt, return_tensors="pt")
25
  outputs = model.generate(
26
  input_ids=inputs["input_ids"],
 
32
  return generated_text
33
 
34
  # Custom CSS for the UI
35
+ background_image_path = '/mnt/data/image.png'
36
  custom_css = f"""
37
  .message.pending {{
38
+ background: rgba(168, 196, 214, 0.5);
39
  }}
40
  /* Response message */
41
  .message.bot.svelte-1s78gfg.message-bubble-border {{
42
+ border-color: rgba(38, 107, 153, 0.5);
43
+ background: rgba(255, 255, 255, 0.1);
44
  }}
45
  /* User message */
46
  .message.user.svelte-1s78gfg.message-bubble-border {{
47
+ background: rgba(157, 221, 249, 0.5);
48
+ border-color: rgba(157, 221, 249, 0.5);
49
  }}
50
  /* For both user and response message as per the document */
51
  span.md.svelte-8tpqd2.chatbot.prose p {{
 
53
  }}
54
  /* Chatbot container */
55
  .gradio-container {{
 
56
  color: white; /* Light text color */
57
  background-image: url('{background_image_path}'); /* Add background image */
58
  background-size: cover; /* Cover the entire container */
59
  background-position: center; /* Center the image */
60
  background-repeat: no-repeat; /* Do not repeat the image */
61
+ background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent dark background */
62
  }}
63
  /* RED (Hex: #DB1616) for action buttons and links only */
64
  .clear-btn {{
 
126
  )
127
  clear.click(lambda: None, None, chatbot, queue=False)
128
 
129
+ demo.launch()