Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,21 +15,28 @@ bnb_config = BitsAndBytesConfig(load_in_8bit=True)
|
|
| 15 |
|
| 16 |
|
| 17 |
def convert_to_markdown(input_text):
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
|
| 22 |
-
formatted_output = f"**{sections[0].strip()}**\n"
|
| 23 |
|
| 24 |
-
#
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
formatted_output += f"\n**{header}{content}\n"
|
| 31 |
|
| 32 |
-
#
|
|
|
|
|
|
|
| 33 |
return formatted_output.strip()
|
| 34 |
|
| 35 |
@spaces.GPU
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
def convert_to_markdown(input_text):
|
| 18 |
+
"""Converts bird information text to Markdown format,
|
| 19 |
+
making specific keywords bold and adding headings.
|
| 20 |
+
|
| 21 |
+
Args:
|
| 22 |
+
input_text (str): The input text containing bird information.
|
| 23 |
+
|
| 24 |
+
Returns:
|
| 25 |
+
str: The formatted Markdown text.
|
| 26 |
+
"""
|
| 27 |
|
| 28 |
+
bold_words = ['Look:', 'Cool Fact!:', 'Habitat:', 'Food:', 'Birdie Behaviors:']
|
|
|
|
| 29 |
|
| 30 |
+
# Split into title and content based on the first ":", handling extra whitespace
|
| 31 |
+
title, content = map(str.strip, input_text.split(":", 1))
|
| 32 |
+
|
| 33 |
+
# Bold the keywords
|
| 34 |
+
for word in bold_words:
|
| 35 |
+
content = content.replace(word, f'\n**{word}**\n')
|
|
|
|
| 36 |
|
| 37 |
+
# Construct the Markdown output with headings
|
| 38 |
+
formatted_output = f"** {title} **\n{content}"
|
| 39 |
+
|
| 40 |
return formatted_output.strip()
|
| 41 |
|
| 42 |
@spaces.GPU
|