Skip to content

Commit

Permalink
allow message with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
RexWzh committed Oct 28, 2023
1 parent 1e2d096 commit 237b9de
Show file tree
Hide file tree
Showing 3 changed files with 9 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,6 +2,6 @@

__author__ = """Rex Wang"""
__email__ = '[email protected]'
__version__ = '0.0.3'
__version__ = '0.0.4'

from .askchat import ask
10 changes: 7 additions & 3 deletions askchat/askchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ def ask():
"""Interact with ChatGPT in terminal via chattool"""
# parse arguments
parser = ArgumentParser()
parser.add_argument('message', type=str, help='User message')
parser.add_argument('message', help='User message', default='', nargs='*')
args = parser.parse_args()
msg = args.message

if isinstance(msg, list):
msg = ' '.join(msg)
assert len(msg.strip()), 'Please specify message'
# call
chat = Chat(msg)
asyncio.run(show_resp(chat))
Expand All @@ -29,7 +31,7 @@ def main():
# parse arguments
parser = ArgumentParser()
## use nargs='?' to make message optional
parser.add_argument('message', help='User message', default='', nargs='?')
parser.add_argument('message', help='User message', default='', nargs='*')
parser.add_argument('-v', '--version', action='version', version=VERSION)
parser.add_argument('--debug', action='store_true', help='Print debug log')
parser.add_argument('--valid-models', action='store_true', help='Print valid models')
Expand All @@ -46,6 +48,8 @@ def main():
return
# get message and model
model, msg = args.model, args.message
if isinstance(msg, list):
msg = ' '.join(msg)
assert len(msg.strip()), 'Please specify message'
# call
chat = Chat(msg, model=model)
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 = '0.0.3'
VERSION = '0.0.4'

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

0 comments on commit 237b9de

Please sign in to comment.