gusreinaos commited on
Commit
d9d9611
Β·
1 Parent(s): 7c03536

Update requirements

Browse files
Files changed (1) hide show
  1. app.py +12 -13
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)