Skip to content

Commit

Permalink
Catch FileNotFoundError
Browse files Browse the repository at this point in the history
  • Loading branch information
yaph committed Jul 14, 2024
1 parent e722f26 commit 3800c1c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions charla/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
'''

# Regular expressions
extensions = '|'.join(['htm', 'html', 'md', 'markdown', 'txt'])
supported_extensions = ['htm', 'html', 'md', 'markdown', 'txt']
extensions = '|'.join(supported_extensions)
re_filename = re.compile(rf'\S+\.(?:{extensions})\b', re.IGNORECASE)

def available_models() -> None | list[str]:
Expand Down Expand Up @@ -112,8 +113,9 @@ def run(argv: argparse.Namespace) -> None:
user_input = user_input.replace(filename, Path(filename).read_text())
session.message = t_prompt_ml if session.multiline else t_prompt
session.completer = None
except Exception as err:
except FileNotFoundError as err:
print(err)
continue

print(f'\n{t_response}\n')
context = generate(argv.model, user_input, context, output, system=system_prompt)
Expand Down

0 comments on commit 3800c1c

Please sign in to comment.