Skip to content

Commit

Permalink
add interactive mode
Browse files Browse the repository at this point in the history
  • Loading branch information
RexWzh committed Aug 10, 2024
1 parent c3f35aa commit 7b8c9d8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion askchat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = """Rex Wang"""
__email__ = '[email protected]'
__version__ = '1.2.1'
__version__ = '1.2.2'

import asyncio
from pathlib import Path
Expand Down
11 changes: 8 additions & 3 deletions askchat/askenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,19 @@ def list():
@click.option('-b', '--base-url', default=None, help='Base URL of the API (without suffix `/v1`)')
@click.option('--api-base', default=None, help='Base URL of the API (with suffix `/v1`)')
@click.option('-m', '--model', default=None, help='Model name')
def new(name, api_key, base_url, api_base, model):
@click.option('--interactive', '-i', is_flag=True, default=False, help='Enable interactive mode for inputting options')
def new(name, api_key, base_url, api_base, model, interactive):
"""Create a new environment configuration."""
config_path = ENV_PATH / f'{name}.env'
if config_path.exists():
click.echo(f"Warning: Overwriting existing environment '{name}'.")
click.confirm("Do you want to continue?", abort=True)
else:
click.echo(f"Environment '{name}' created.")
if interactive:
api_key = click.prompt('API key', default=api_key, hide_input=True)
base_url = click.prompt('Base URL of the API (without suffix `/v1`)', default=base_url)
default_api_base = f"{base_url}/v1" if base_url else api_base
api_base = click.prompt('Base URL of the API (with suffix `/v1`)', default=default_api_base)
model = click.prompt('Default model name', default=model)
write_config(config_path, api_key, model, base_url, api_base, overwrite=True)

@cli.command()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from setuptools import setup, find_packages

VERSION = '1.2.1'
VERSION = '1.2.2'

with open('README.md') as readme_file:
readme = readme_file.read()
Expand Down

0 comments on commit 7b8c9d8

Please sign in to comment.