Spaces:
Sleeping
Sleeping
update
Browse files
app.py
CHANGED
@@ -6,14 +6,17 @@ from peft import PeftModel, PeftConfig
|
|
6 |
|
7 |
# Hugging Face login
|
8 |
token = os.environ.get("token")
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
11 |
|
12 |
# Model and tokenizer setup
|
13 |
MODEL_NAME = "google/flan-t5-base"
|
14 |
-
tokenizer = T5Tokenizer.from_pretrained(MODEL_NAME,
|
15 |
config = PeftConfig.from_pretrained("Komal-patra/results")
|
16 |
-
base_model = AutoModelForSeq2SeqLM.from_pretrained(
|
17 |
model = PeftModel.from_pretrained(base_model, "Komal-patra/results")
|
18 |
|
19 |
# Text generation function
|
@@ -50,6 +53,14 @@ span.md.svelte-8tpqd2.chatbot.prose p {
|
|
50 |
.gradio-container {
|
51 |
background: #1c1c1c; /* Dark background */
|
52 |
color: white; /* Light text color */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
}
|
54 |
/* RED (Hex: #DB1616) for action buttons and links only */
|
55 |
.clear-btn {
|
@@ -94,9 +105,11 @@ with gr.Blocks(css=custom_css) as demo:
|
|
94 |
submit_button = gr.Button("Submit", elem_classes="submit-btn")
|
95 |
clear = gr.Button("Clear", elem_classes="clear-btn")
|
96 |
|
|
|
97 |
def user(user_message, history):
|
98 |
return "", history + [[user_message, None]]
|
99 |
|
|
|
100 |
def bot(history):
|
101 |
if len(history) == 1: # Check if it's the first interaction
|
102 |
bot_message = "Hi there! How can I help you today?"
|
@@ -116,4 +129,4 @@ with gr.Blocks(css=custom_css) as demo:
|
|
116 |
)
|
117 |
clear.click(lambda: None, None, chatbot, queue=False)
|
118 |
|
119 |
-
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"
|
17 |
+
tokenizer = T5Tokenizer.from_pretrained(MODEL_NAME, use_auth_token=token)
|
18 |
config = PeftConfig.from_pretrained("Komal-patra/results")
|
19 |
+
base_model = AutoModelForSeq2SeqLM.from_pretrained(MODEL_NAME)
|
20 |
model = PeftModel.from_pretrained(base_model, "Komal-patra/results")
|
21 |
|
22 |
# Text generation function
|
|
|
53 |
.gradio-container {
|
54 |
background: #1c1c1c; /* Dark background */
|
55 |
color: white; /* Light text color */
|
56 |
+
height: 100vh; /* Full viewport height */
|
57 |
+
display: flex;
|
58 |
+
flex-direction: column;
|
59 |
+
}
|
60 |
+
/* Chatbot messages container */
|
61 |
+
.svelte-1s78gfg {
|
62 |
+
flex-grow: 1; /* Allow it to grow and take available space */
|
63 |
+
overflow-y: auto; /* Enable vertical scrolling */
|
64 |
}
|
65 |
/* RED (Hex: #DB1616) for action buttons and links only */
|
66 |
.clear-btn {
|
|
|
105 |
submit_button = gr.Button("Submit", elem_classes="submit-btn")
|
106 |
clear = gr.Button("Clear", elem_classes="clear-btn")
|
107 |
|
108 |
+
# Function to handle user input
|
109 |
def user(user_message, history):
|
110 |
return "", history + [[user_message, None]]
|
111 |
|
112 |
+
# Function to handle bot response
|
113 |
def bot(history):
|
114 |
if len(history) == 1: # Check if it's the first interaction
|
115 |
bot_message = "Hi there! How can I help you today?"
|
|
|
129 |
)
|
130 |
clear.click(lambda: None, None, chatbot, queue=False)
|
131 |
|
132 |
+
demo.launch(share=True)
|