yasserrmd commited on
Commit
e06335c
1 Parent(s): 58cf684

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -169,6 +169,18 @@ model = MllamaForConditionalGeneration.from_pretrained(
169
  processor = AutoProcessor.from_pretrained(model_id)
170
 
171
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  def extract_json_from_markdown(markdown_text):
173
  """Extract JSON or code block from markdown text."""
174
  try:
@@ -252,6 +264,8 @@ def diagnose_router(image):
252
  # </ul>
253
  # </div>
254
  # """
 
 
255
  html_output = markdown.markdown(markdown_text)
256
  return html_output
257
 
 
169
  processor = AutoProcessor.from_pretrained(model_id)
170
 
171
 
172
+ def extract_assistant_reply(input_string):
173
+ # Define the tag that indicates the start of the assistant's reply
174
+ start_tag = "<|start_header_id|>assistant<|end_header_id|>"
175
+ # Find the position where the assistant's reply starts
176
+ start_index = input_string.find(start_tag)
177
+ if start_index == -1:
178
+ return "Assistant's reply not found."
179
+ start_index += len(start_tag)
180
+ # Extract everything after the start tag
181
+ assistant_reply = input_string[start_index:].strip()
182
+ return assistant_reply
183
+
184
  def extract_json_from_markdown(markdown_text):
185
  """Extract JSON or code block from markdown text."""
186
  try:
 
264
  # </ul>
265
  # </div>
266
  # """
267
+
268
+ markdown_text=extract_assistant_reply(markdown_text)
269
  html_output = markdown.markdown(markdown_text)
270
  return html_output
271