-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from juftin/elia-external-install
✨ installable elia
- Loading branch information
Showing
10 changed files
with
153 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
""" | ||
Elia CLI | ||
""" | ||
|
||
import pathlib | ||
|
||
import click | ||
|
||
from elia_chat.app import app | ||
from elia_chat.database.create_database import create_database | ||
from elia_chat.database.import_chatgpt import import_chatgpt_data | ||
from elia_chat.database.models import sqlite_file_name | ||
|
||
|
||
@click.group(invoke_without_command=True) | ||
@click.pass_context | ||
def cli(context: click.Context) -> None: | ||
""" | ||
Elia: A terminal ChatGPT client built with Textual | ||
""" | ||
# Run the app if no subcommand is provided | ||
if context.invoked_subcommand is None: | ||
# Create the database if it doesn't exist | ||
if sqlite_file_name.exists() is False: | ||
create_database() | ||
app.run() | ||
|
||
|
||
@cli.command() | ||
def reset() -> None: | ||
""" | ||
Reset the database | ||
This command will delete the database file and recreate it. | ||
Previously saved conversations and data will be lost. | ||
""" | ||
sqlite_file_name.unlink(missing_ok=True) | ||
create_database() | ||
click.echo(f"♻️ Database reset @ {sqlite_file_name}") | ||
|
||
|
||
@cli.command("import") | ||
@click.argument( | ||
"file", | ||
type=click.Path( | ||
exists=True, dir_okay=False, path_type=pathlib.Path, resolve_path=True | ||
), | ||
) | ||
def import_file_to_db(file) -> None: | ||
""" | ||
Import ChatGPT Conversations | ||
This command will import the ChatGPT conversations from a local | ||
JSON file into the database. | ||
""" | ||
import_chatgpt_data(file=file) | ||
click.echo(f"✅ ChatGPT data imported into database {file}") | ||
|
||
|
||
if __name__ == "__main__": | ||
cli() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,5 @@ def on_mount(self) -> None: | |
|
||
app = Elia() | ||
|
||
|
||
def run(): | ||
app.run() | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters