Skip to content

Commit 172bd5c

Browse files
committed
Implement markdown support for AI responses. Resolves #13
This commit introduces markdown support for the AI responses in the `aicodebot` CLI. The `rich.markdown` module is imported and used to print the AI responses in markdown format. This change affects the `alignment`, `debug`, `fun_fact`, and `review` commands. Additionally, the prompts for these commands have been updated to instruct the AI to respond in markdown format. This enhancement improves the readability and formatting of the AI responses, making them more user-friendly.
1 parent 2b6e400 commit 172bd5c

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

aicodebot/cli.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from openai.api_resources import engine
99
from pathlib import Path
1010
from rich.console import Console
11+
from rich.markdown import Markdown
1112
from rich.style import Style
1213
import click, datetime, openai, os, random, subprocess, sys, tempfile, webbrowser
1314

@@ -61,7 +62,7 @@ def alignment(verbose):
6162

6263
with console.status("Generating an inspirational message", spinner=DEFAULT_SPINNER):
6364
response = chain.run({})
64-
console.print(response, style=bot_style)
65+
console.print(Markdown(response), style=bot_style)
6566

6667

6768
@cli.command()
@@ -174,7 +175,7 @@ def debug(command, verbose):
174175

175176
with console.status("Debugging", spinner=DEFAULT_SPINNER):
176177
response = chat_chain.run(error_output)
177-
console.print(response, style=bot_style)
178+
console.print(Markdown(response), style=bot_style)
178179

179180
sys.exit(process.returncode)
180181

@@ -199,7 +200,7 @@ def fun_fact(verbose):
199200
# Select a random year so that we get a different answer each time
200201
year = random.randint(1942, datetime.datetime.utcnow().year)
201202
response = chat_chain.run(f"programming and artificial intelligence in the year {year}")
202-
console.print(response, style=bot_style)
203+
console.print(Markdown(response), style=bot_style)
203204

204205

205206
@cli.command
@@ -232,7 +233,7 @@ def review(commit, verbose):
232233

233234
with console.status("Reviewing code", spinner=DEFAULT_SPINNER):
234235
response = chain.run(diff_context)
235-
console.print(response, style=bot_style)
236+
console.print(Markdown(response), style=bot_style)
236237

237238

238239
@cli.command

aicodebot/prompts/alignment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ template: |
1515
1616
Be verbose, about 2 paragraphs, and provide actionable steps for software engineers
1717
to make AI more aligned with humanity.
18+
19+
Respond in markdown format.

aicodebot/prompts/debug.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ template: |
1313
END OUTPUT
1414
1515
Help me understand what happened and how might I be able to fix it
16+
17+
Respond in markdown format.

aicodebot/prompts/fun_fact.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ template: |
77
You love emojis.
88
99
Tell me a fun fact.
10+
11+
Respond in markdown format.

aicodebot/prompts/review.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,5 @@ template: |
2929
The main focus is to tell me how I could make the code better.
3030
3131
If the changes look good overall and don't require any feedback, then just respond with "LGTM" (looks good to me).
32+
33+
Respond in markdown format.

0 commit comments

Comments
 (0)