diff --git a/README-en.md b/README-en.md index d090e63..f67f546 100644 --- a/README-en.md +++ b/README-en.md @@ -137,6 +137,7 @@ Auxiliary features, such as generating configuration files, debugging logs, prin | Parameter | Example | Explanation | |--------------------------|----------------------------------|---------------------------------------| | `--generate-config` | `askchat --generate-config` | Generate a configuration file, saved in `~/.askchat/.env` | +| `--print-curl` | `askchat hello --print-curl` | Print the actual request URL | | `--debug` | `askchat --debug` | Print debugging logs | | `--valid-models` | `askchat --valid-models` | Print a list of models containing "gpt" in their names | | `--all-valid-models` | `askchat --all-valid-models` | Print all available models | diff --git a/README.md b/README.md index 407f385..144dc38 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,7 @@ ask hello world | 参数 | 示例 | 解释 | |---------------------------|----------------------|--------------------------------------------| | `--generate-config` | `askchat --generate-config` | 生成配置文件,保存在 `~/.askchat/.env` 中 | +| `--print-url` | `askchat hello --print-url` | 打印实际请求的 URL | | `--debug` | `askchat --debug` | 打印调试日志 | | `--valid-models` | `askchat --valid-models` | 打印包含 "gpt" 名称的模型列表 | | `--all-valid-models` | `askchat --all-valid-models` | 打印所有的模型 | diff --git a/askchat/__init__.py b/askchat/__init__.py index fd4dea4..42f2091 100644 --- a/askchat/__init__.py +++ b/askchat/__init__.py @@ -2,7 +2,7 @@ __author__ = """Rex Wang""" __email__ = '1073853456@qq.com' -__version__ = '1.1.6' +__version__ = '1.2.0' import asyncio from pathlib import Path diff --git a/askchat/cli.py b/askchat/cli.py index fffb8ec..481aa29 100644 --- a/askchat/cli.py +++ b/askchat/cli.py @@ -149,10 +149,11 @@ def cli(): @click.option('--debug', is_flag=True, callback=debug_log_callback, expose_value=False, help='Print debug log') @click.option('--valid-models', is_flag=True, callback=valid_models_callback, expose_value=False, help='Print valid models that contain "gpt" in their names') @click.option('--all-valid-models', is_flag=True, callback=all_valid_models_callback, expose_value=False, help='Print all valid models') +@click.option('--print-curl', is_flag=True, help='Print the curl command for the request') @click.option('-v', '--version', is_flag=True, callback=version_callback, expose_value=False, help='Print the version') @click.option('-o', '--option', multiple=True, type=(str, str), help='Additional options for show_resp in the form of key=value') def main( message, model, base_url, api_base, api_key, use_env - , c, regenerate, p, option): + , c, regenerate, p, option, print_curl): """Interact with ChatGPT in terminal via chattool""" setup() message_text = ' '.join(message).strip() @@ -215,9 +216,15 @@ def main( message, model, base_url, api_base, api_key, use_env option[key] = float(value) else: option = {} - # Add chat responses if option.get('stream') in ['false', 0]: option['stream'] = False + else: + option['stream'] = True + if print_curl: + chat.print_curl(**option) + return + # Add chat responses + if not option['stream']: chat.getresponse(**option) for text in chat.last_message: print(text, end='', flush=True) diff --git a/setup.py b/setup.py index 9c44578..859d6cd 100644 --- a/setup.py +++ b/setup.py @@ -4,12 +4,12 @@ from setuptools import setup, find_packages -VERSION = '1.1.6' +VERSION = '1.2.0' with open('README.md') as readme_file: readme = readme_file.read() -requirements = ['chattool>=3.1.4', "python-dotenv>=0.17.0", 'Click>=8.0'] +requirements = ['chattool>=3.2.0', "python-dotenv>=0.17.0", 'Click>=8.0'] test_requirements = ['pytest>=3']