Update app.py
Browse files
app.py
CHANGED
|
@@ -26,9 +26,9 @@ retriever = vectorstore.as_retriever()
|
|
| 26 |
# 2. Load Model & Tokenizer in 4-bit
|
| 27 |
# ==========================================
|
| 28 |
print("Loading Model...")
|
| 29 |
-
model_id = "anirudh248/llama3-upf-generator"
|
| 30 |
|
| 31 |
-
# Load in 4-bit to fit
|
| 32 |
bnb_config = BitsAndBytesConfig(
|
| 33 |
load_in_4bit=True,
|
| 34 |
bnb_4bit_compute_dtype=torch.float16
|
|
@@ -92,10 +92,11 @@ def user_interaction(user_message, history):
|
|
| 92 |
history.append({"role": "assistant", "content": response})
|
| 93 |
return history, ""
|
| 94 |
|
| 95 |
-
with gr.Blocks(
|
| 96 |
gr.Markdown("# ⚡ UPF Code Generator with Llama 3 & RAG")
|
| 97 |
|
| 98 |
-
|
|
|
|
| 99 |
|
| 100 |
with gr.Row():
|
| 101 |
user_input = gr.Textbox(show_label=False, placeholder="Enter power intent...", lines=3)
|
|
@@ -105,4 +106,4 @@ with gr.Blocks(theme=gr.themes.Soft()) as interface:
|
|
| 105 |
send_button.click(fn=user_interaction, inputs=[user_input, chatbot], outputs=[chatbot, user_input])
|
| 106 |
user_input.submit(fn=user_interaction, inputs=[user_input, chatbot], outputs=[chatbot, user_input])
|
| 107 |
|
| 108 |
-
interface.launch()
|
|
|
|
| 26 |
# 2. Load Model & Tokenizer in 4-bit
|
| 27 |
# ==========================================
|
| 28 |
print("Loading Model...")
|
| 29 |
+
model_id = "anirudh248/llama3-upf-generator"
|
| 30 |
|
| 31 |
+
# Load in 4-bit to fit inside a T4 GPU Space
|
| 32 |
bnb_config = BitsAndBytesConfig(
|
| 33 |
load_in_4bit=True,
|
| 34 |
bnb_4bit_compute_dtype=torch.float16
|
|
|
|
| 92 |
history.append({"role": "assistant", "content": response})
|
| 93 |
return history, ""
|
| 94 |
|
| 95 |
+
with gr.Blocks() as interface:
|
| 96 |
gr.Markdown("# ⚡ UPF Code Generator with Llama 3 & RAG")
|
| 97 |
|
| 98 |
+
# Removed `type="messages"` parameter to fix TypeError
|
| 99 |
+
chatbot = gr.Chatbot(label="Chat History", elem_id="chatbot")
|
| 100 |
|
| 101 |
with gr.Row():
|
| 102 |
user_input = gr.Textbox(show_label=False, placeholder="Enter power intent...", lines=3)
|
|
|
|
| 106 |
send_button.click(fn=user_interaction, inputs=[user_input, chatbot], outputs=[chatbot, user_input])
|
| 107 |
user_input.submit(fn=user_interaction, inputs=[user_input, chatbot], outputs=[chatbot, user_input])
|
| 108 |
|
| 109 |
+
interface.launch(theme=gr.themes.Soft())
|