Skip to content

Commit

Permalink
Fewer global variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
yaph committed Jul 15, 2024
1 parent 3800c1c commit c8a6f59
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions charla/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
Press → to complete an auto suggested prompt.
'''

# Regular expressions
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]:
"""Return available models sorted by size."""
Expand Down Expand Up @@ -88,8 +84,13 @@ def run(argv: argparse.Namespace) -> None:
context: list[int] = [] # Store conversation history to make the model context aware
output = [f'# Chat with: {argv.model}\n'] # List to store output text

# Regex for extracting file names from prompts
extensions = '|'.join(config.text_file_extensions)
re_filename = re.compile(rf'\S+\.(?:{extensions})\b', re.IGNORECASE)

history = Path(argv.prompt_history)
config.mkdir(history.parent, exist_ok=True, parents=True)

session = prompt_session(argv)
print_fmt('Chat with:', HTML(f'<ansigreen>{argv.model}</ansigreen>'), '\n')

Expand Down
1 change: 1 addition & 0 deletions charla/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
'multiline': False
}
path_settings = user_config_path(NAME).joinpath('settings.json')
text_file_extensions = ['htm', 'html', 'md', 'markdown', 'txt']


def load() -> dict:
Expand Down
2 changes: 1 addition & 1 deletion todo.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# TODO

* Load content from local and remote files via keyboard shortcut `c-o` that changes prompt text to `OPEN`.
* Load content from remote files. Should the be a core feature or rather a plugin?

0 comments on commit c8a6f59

Please sign in to comment.