-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
32 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,17 +2,36 @@ | |
|
||
__author__ = """Rex Wang""" | ||
__email__ = '[email protected]' | ||
__version__ = '1.1.0' | ||
__version__ = '1.1.1' | ||
|
||
import asyncio | ||
from pathlib import Path | ||
import click | ||
|
||
# Main environment file | ||
CONFIG_PATH = Path.home() / ".askchat" | ||
CONFIG_FILE = CONFIG_PATH / ".env" | ||
MAIN_ENV_PATH = Path.home() / '.askchat' / '.env' | ||
ENV_PATH = Path.home() / '.askchat' / 'envs' | ||
|
||
# Autocompletion | ||
# environment name completion | ||
class EnvNameCompletionType(click.ParamType): | ||
name = "envname" | ||
def shell_complete(self, ctx, param, incomplete): | ||
return [ | ||
click.shell_completion.CompletionItem(path.stem) for path in ENV_PATH.glob(f"{incomplete}*.env") | ||
] | ||
# chat file completion | ||
class ChatFileCompletionType(click.ParamType): | ||
name = "chatfile" | ||
def shell_complete(self, ctx, param, incomplete): | ||
return [ | ||
click.shell_completion.CompletionItem(path.stem) for path in CONFIG_PATH.glob(f"{incomplete}*.json") | ||
if not path.name.startswith("_") | ||
] | ||
|
||
# common functions | ||
async def show_resp(chat): | ||
msg = '' | ||
async for char in chat.async_stream_responses(textonly=True): | ||
|
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