Skip to content

Commit

Permalink
Add text formatting and fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
sacheex committed Jun 17, 2024
1 parent a3013db commit d2efd28
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gemini.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def get_response(prompt):
generation_config = genai.types.GenerationConfig(
candidate_count = 1,
temperature = 0.5
)
),
stream=True
)
for chunk in response:
Expand All @@ -80,10 +80,10 @@ def to_display(text):
Returns:
str: The formatted text ready for display.
"""
text = text.replace('**', '')
text = text.replace('*', '\n •')

text = text.replace("##", "")

# Add ANCI styles to the output
text = re.sub(r'\*\*(.*?)\*\*', r'\033[1m\1\033[0m', text, flags=re.DOTALL)
text = re.sub(r'\*(.*?)\*', r'\033[3m\1\033[0m', text, flags=re.DOTALL)
text = re.sub(r'^( \*.*)$', r'\n\1', text, flags=re.MULTILINE)
Expand Down

0 comments on commit d2efd28

Please sign in to comment.