Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -5,10 +5,10 @@ from transformers import GemmaTokenizer, AutoModelForCausalLM
|
|
5 |
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
|
6 |
from threading import Thread
|
7 |
|
8 |
-
|
9 |
# Set an environment variable
|
10 |
HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
11 |
|
|
|
12 |
DESCRIPTION = '''
|
13 |
<div>
|
14 |
<h1 style="text-align: center;">Meta Llama3 8B</h1>
|
@@ -25,21 +25,6 @@ LICENSE = """
|
|
25 |
Built with Meta Llama 3
|
26 |
"""
|
27 |
|
28 |
-
PLACEHOLDER1 = """
|
29 |
-
<div style="opacity: 0.65;">
|
30 |
-
<img src="https://ysharma-dummy-chat-app.hf.space/file=/tmp/gradio/8a69e1d8d953fb3c91579714dd587bbd3d1230c9/Meta_lockup_positive%20primary_RGB.png" style="width:45%;">
|
31 |
-
<br><b>Meta Llama3-8B Chatbot</b>
|
32 |
-
</div>
|
33 |
-
"""
|
34 |
-
|
35 |
-
PLACEHOLDER2 = """
|
36 |
-
<div style="padding: 30px; text-align: center; display: flex; flex-direction: column; align-items: center;">
|
37 |
-
<img src="https://ysharma-dummy-chat-app.hf.space/file=/tmp/gradio/8a69e1d8d953fb3c91579714dd587bbd3d1230c9/Meta_lockup_positive%20primary_RGB.png" style="width: 80%; max-width: 450px; height: auto; opacity: 0.55; margin-bottom: 10px; border-radius: 10px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);">
|
38 |
-
<h1 style="font-size: 28px; margin-bottom: 2px; color: #000; opacity: 0.55;">Meta llama3</h1>
|
39 |
-
<p style="font-size: 18px; margin-bottom: 2px; color: #000; opacity: 0.65;">Ask me anything...</p>
|
40 |
-
</div>
|
41 |
-
"""
|
42 |
-
|
43 |
PLACEHOLDER = """
|
44 |
<div style="padding: 30px; text-align: center; display: flex; flex-direction: column; align-items: center;">
|
45 |
<img src="https://ysharma-dummy-chat-app.hf.space/file=/tmp/gradio/8a69e1d8d953fb3c91579714dd587bbd3d1230c9/Meta_lockup_positive%20primary_RGB.png" style="width: 80%; max-width: 550px; height: auto; opacity: 0.55; ">
|
@@ -89,7 +74,6 @@ def chat_llama3_8b(message: str,
|
|
89 |
conversation.append({"role": "user", "content": message})
|
90 |
|
91 |
input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt").to(model.device)
|
92 |
-
#input_ids = tokenizer.encode(message, return_tensors="pt").to(model.device)
|
93 |
|
94 |
streamer = TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
|
95 |
|
@@ -115,7 +99,7 @@ def chat_llama3_8b(message: str,
|
|
115 |
|
116 |
|
117 |
# Gradio block
|
118 |
-
chatbot=gr.Chatbot(height=500, placeholder=PLACEHOLDER)
|
119 |
|
120 |
with gr.Blocks(fill_height=True, css=css) as demo:
|
121 |
|
|
|
5 |
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
|
6 |
from threading import Thread
|
7 |
|
|
|
8 |
# Set an environment variable
|
9 |
HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
10 |
|
11 |
+
|
12 |
DESCRIPTION = '''
|
13 |
<div>
|
14 |
<h1 style="text-align: center;">Meta Llama3 8B</h1>
|
|
|
25 |
Built with Meta Llama 3
|
26 |
"""
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
PLACEHOLDER = """
|
29 |
<div style="padding: 30px; text-align: center; display: flex; flex-direction: column; align-items: center;">
|
30 |
<img src="https://ysharma-dummy-chat-app.hf.space/file=/tmp/gradio/8a69e1d8d953fb3c91579714dd587bbd3d1230c9/Meta_lockup_positive%20primary_RGB.png" style="width: 80%; max-width: 550px; height: auto; opacity: 0.55; ">
|
|
|
74 |
conversation.append({"role": "user", "content": message})
|
75 |
|
76 |
input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt").to(model.device)
|
|
|
77 |
|
78 |
streamer = TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
|
79 |
|
|
|
99 |
|
100 |
|
101 |
# Gradio block
|
102 |
+
chatbot=gr.Chatbot(height=500, placeholder=PLACEHOLDER, label='Gradio ChatInterface')
|
103 |
|
104 |
with gr.Blocks(fill_height=True, css=css) as demo:
|
105 |
|