Spaces:
Build error
Build error
gusreinaos
commited on
Commit
Β·
d9d9611
1
Parent(s):
7c03536
Update requirements
Browse files
app.py
CHANGED
|
@@ -27,14 +27,14 @@ print("β
Model loaded!")
|
|
| 27 |
|
| 28 |
def chat(message, history):
|
| 29 |
prompt = "<|begin_of_text|>"
|
| 30 |
-
|
| 31 |
for user_msg, bot_msg in history:
|
| 32 |
prompt += f"<|start_header_id|>user<|end_header_id|>\n\n{user_msg}<|eot_id|>"
|
| 33 |
prompt += f"<|start_header_id|>assistant<|end_header_id|>\n\n{bot_msg}<|eot_id|>"
|
| 34 |
-
|
| 35 |
prompt += f"<|start_header_id|>user<|end_header_id|>\n\n{message}<|eot_id|>"
|
| 36 |
prompt += "<|start_header_id|>assistant<|end_header_id|>\n\n"
|
| 37 |
-
|
| 38 |
response = llm(
|
| 39 |
prompt,
|
| 40 |
max_tokens=512,
|
|
@@ -43,7 +43,7 @@ def chat(message, history):
|
|
| 43 |
stop=["<|eot_id|>", "<|start_header_id|>"],
|
| 44 |
echo=False
|
| 45 |
)
|
| 46 |
-
|
| 47 |
return response['choices'][0]['text'].strip()
|
| 48 |
|
| 49 |
# Ultra-modern CSS
|
|
@@ -138,14 +138,14 @@ with gr.Blocks(
|
|
| 138 |
css=custom_css,
|
| 139 |
title="π¦ Llama 3.2 AI"
|
| 140 |
) as demo:
|
| 141 |
-
|
| 142 |
gr.Markdown(
|
| 143 |
"""
|
| 144 |
# π¦ Llama Chat AI Assistant (TEST)
|
| 145 |
### β‘ Testing deployment with pre-trained model
|
| 146 |
"""
|
| 147 |
)
|
| 148 |
-
|
| 149 |
chatbot = gr.Chatbot(
|
| 150 |
elem_id="chatbot",
|
| 151 |
bubble_full_width=False,
|
|
@@ -155,9 +155,8 @@ with gr.Blocks(
|
|
| 155 |
),
|
| 156 |
height=650,
|
| 157 |
show_copy_button=True,
|
| 158 |
-
likeable=True
|
| 159 |
)
|
| 160 |
-
|
| 161 |
with gr.Row():
|
| 162 |
msg = gr.Textbox(
|
| 163 |
placeholder="β¨ Ask me anything...",
|
|
@@ -166,7 +165,7 @@ with gr.Blocks(
|
|
| 166 |
container=False
|
| 167 |
)
|
| 168 |
submit = gr.Button("Send π", scale=1, variant="primary", size="lg")
|
| 169 |
-
|
| 170 |
gr.Examples(
|
| 171 |
examples=[
|
| 172 |
"π What is the capital of France?",
|
|
@@ -179,7 +178,7 @@ with gr.Blocks(
|
|
| 179 |
inputs=msg,
|
| 180 |
label="π‘ Quick Start:"
|
| 181 |
)
|
| 182 |
-
|
| 183 |
with gr.Accordion("βΉοΈ Model Information", open=False):
|
| 184 |
gr.Markdown(
|
| 185 |
"""
|
|
@@ -189,9 +188,9 @@ with gr.Blocks(
|
|
| 189 |
- π Note: This is a test deployment. Will be replaced with fine-tuned model.
|
| 190 |
"""
|
| 191 |
)
|
| 192 |
-
|
| 193 |
clear = gr.ClearButton([msg, chatbot], value="ποΈ New Chat")
|
| 194 |
-
|
| 195 |
submit.click(chat, [msg, chatbot], [chatbot])
|
| 196 |
submit.click(lambda: "", None, msg)
|
| 197 |
msg.submit(chat, [msg, chatbot], [chatbot])
|
|
@@ -199,4 +198,4 @@ with gr.Blocks(
|
|
| 199 |
|
| 200 |
if __name__ == "__main__":
|
| 201 |
demo.queue()
|
| 202 |
-
demo.launch(share=False)
|
|
|
|
| 27 |
|
| 28 |
def chat(message, history):
|
| 29 |
prompt = "<|begin_of_text|>"
|
| 30 |
+
|
| 31 |
for user_msg, bot_msg in history:
|
| 32 |
prompt += f"<|start_header_id|>user<|end_header_id|>\n\n{user_msg}<|eot_id|>"
|
| 33 |
prompt += f"<|start_header_id|>assistant<|end_header_id|>\n\n{bot_msg}<|eot_id|>"
|
| 34 |
+
|
| 35 |
prompt += f"<|start_header_id|>user<|end_header_id|>\n\n{message}<|eot_id|>"
|
| 36 |
prompt += "<|start_header_id|>assistant<|end_header_id|>\n\n"
|
| 37 |
+
|
| 38 |
response = llm(
|
| 39 |
prompt,
|
| 40 |
max_tokens=512,
|
|
|
|
| 43 |
stop=["<|eot_id|>", "<|start_header_id|>"],
|
| 44 |
echo=False
|
| 45 |
)
|
| 46 |
+
|
| 47 |
return response['choices'][0]['text'].strip()
|
| 48 |
|
| 49 |
# Ultra-modern CSS
|
|
|
|
| 138 |
css=custom_css,
|
| 139 |
title="π¦ Llama 3.2 AI"
|
| 140 |
) as demo:
|
| 141 |
+
|
| 142 |
gr.Markdown(
|
| 143 |
"""
|
| 144 |
# π¦ Llama Chat AI Assistant (TEST)
|
| 145 |
### β‘ Testing deployment with pre-trained model
|
| 146 |
"""
|
| 147 |
)
|
| 148 |
+
|
| 149 |
chatbot = gr.Chatbot(
|
| 150 |
elem_id="chatbot",
|
| 151 |
bubble_full_width=False,
|
|
|
|
| 155 |
),
|
| 156 |
height=650,
|
| 157 |
show_copy_button=True,
|
|
|
|
| 158 |
)
|
| 159 |
+
|
| 160 |
with gr.Row():
|
| 161 |
msg = gr.Textbox(
|
| 162 |
placeholder="β¨ Ask me anything...",
|
|
|
|
| 165 |
container=False
|
| 166 |
)
|
| 167 |
submit = gr.Button("Send π", scale=1, variant="primary", size="lg")
|
| 168 |
+
|
| 169 |
gr.Examples(
|
| 170 |
examples=[
|
| 171 |
"π What is the capital of France?",
|
|
|
|
| 178 |
inputs=msg,
|
| 179 |
label="π‘ Quick Start:"
|
| 180 |
)
|
| 181 |
+
|
| 182 |
with gr.Accordion("βΉοΈ Model Information", open=False):
|
| 183 |
gr.Markdown(
|
| 184 |
"""
|
|
|
|
| 188 |
- π Note: This is a test deployment. Will be replaced with fine-tuned model.
|
| 189 |
"""
|
| 190 |
)
|
| 191 |
+
|
| 192 |
clear = gr.ClearButton([msg, chatbot], value="ποΈ New Chat")
|
| 193 |
+
|
| 194 |
submit.click(chat, [msg, chatbot], [chatbot])
|
| 195 |
submit.click(lambda: "", None, msg)
|
| 196 |
msg.submit(chat, [msg, chatbot], [chatbot])
|
|
|
|
| 198 |
|
| 199 |
if __name__ == "__main__":
|
| 200 |
demo.queue()
|
| 201 |
+
demo.launch(share=False)
|