Skip to content

Commit

Permalink
feat(chat): integrate prompt_toolkit for advanced input handling and …
Browse files Browse the repository at this point in the history
…rich for output formatting

- Added prompt_toolkit PromptSession to handle multi-line input, history, and cursor movement.
- Integrated rich for rendering Markdown and colorized output.
- Adjusted input processing to pass user queries to the assistant via create_message.
- Ensured the output is displayed using rich's console.print for proper formatting.
- Included error handling for invalid commands and exceptions during execution.
  • Loading branch information
Estrada Irribarra, Rodrigo Andres committed Oct 23, 2024
1 parent e404549 commit 2b46226
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion storycraftr/agent/iterate.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,19 @@ def insert_new_chapter(
f"The chapter directory '{chapters_dir}' does not exist."
)

# Función para extraer el número del capítulo
def extract_chapter_number(filename):
# Esto supone que los archivos tienen el formato "chapter-<numero>.md"
return int(filename.split("-")[1].split(".")[0])

# Ordenar los archivos por el número del capítulo
files_to_process = sorted(
[
f
for f in os.listdir(chapters_dir)
if f.endswith(".md") and f.startswith("chapter-")
]
],
key=extract_chapter_number,
)

if len(files_to_process) < position or position < 1:
Expand Down

0 comments on commit 2b46226

Please sign in to comment.