Skip to content

Commit ba18e9a

Browse files
committed
Enhanced chat output with bold formatting and fixed token count calculation in prompt builders: Co-authored-by: MindFlow <mf@mindflo.ai>
1 parent d13c1cb commit ba18e9a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

mindflow/cli/commands/chat.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def chat(prompt_args: Tuple[str], skip_index: bool):
2626

2727
from typing import List
2828
from result import Ok
29+
from termcolor import colored
2930

3031
from mindflow.core.commands.chat import run_chat
3132
from mindflow.core.commands.index import run_index
@@ -34,15 +35,15 @@ def chat(prompt_args: Tuple[str], skip_index: bool):
3435
from mindflow.core.types.store_traits.json import save_json_store
3536

3637
async def stream_chat(settings: Settings, prompt: str):
37-
print("\nGPT:")
38+
click.echo(colored("\nGPT:", attrs=["bold"]))
3839
async for char_stream_chunk in run_chat(settings, [], prompt):
3940
if isinstance(char_stream_chunk, Ok):
4041
click.echo(char_stream_chunk.value, nl=False)
4142
else:
4243
click.echo(char_stream_chunk.value)
4344

4445
async def stream_query(settings: Settings, file_paths: List[str], prompt: str):
45-
print("\nGPT:")
46+
click.echo(colored("\nGPT:", attrs=["bold"]))
4647
async for char_stream_chunk in run_query(settings, file_paths, prompt):
4748
if isinstance(char_stream_chunk, Ok):
4849
click.echo(char_stream_chunk.value, nl=False)

mindflow/core/prompt_builders.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ def prune_messages_to_fit_context_window(
5555
for i in range(0, len(messages)):
5656
if (
5757
get_token_count_of_text_for_model(
58-
configured_model.tokenizer, json.dumps(messages[i : len(messages) - 1])
58+
configured_model.tokenizer, json.dumps(messages[i : len(messages)])
5959
)
6060
< configured_model.model.hard_token_limit - 1500
6161
):
62-
return messages[i : len(messages) - 1]
62+
return messages[i : len(messages)]
6363
return []

0 commit comments

Comments
 (0)