diff --git a/README.md b/README.md index a7ef6da..6e5b99d 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ # Openai API call [![PyPI version](https://img.shields.io/pypi/v/openai_api_call.svg)](https://pypi.python.org/pypi/openai_api_call) -[![Tests](https://github.com/RexWzh/openai_api_call/actions/workflows/test.yml/badge.svg)](https://github.com/RexWzh/openai_api_call/actions/workflows/test.yml/) +[![Tests](https://github.com/cubenlp/openai_api_call/actions/workflows/test.yml/badge.svg)](https://github.com/cubenlp/openai_api_call/actions/workflows/test.yml/) [![Documentation Status](https://img.shields.io/badge/docs-github_pages-blue.svg)](https://apicall.wzhecnu.cn) -[![Coverage](https://codecov.io/gh/RexWzh/openai_api_call/branch/master/graph/badge.svg)](https://codecov.io/gh/RexWzh/openai_api_call.jl) +[![Coverage](https://codecov.io/gh/cubenlp/openai_api_call/branch/master/graph/badge.svg)](https://codecov.io/gh/cubenlp/openai_api_call.jl) A simple wrapper for OpenAI API, which can be used to send requests and get responses. diff --git a/README_zh_CN.md b/README_zh_CN.md index ccc2380..f048eed 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -1,10 +1,10 @@ # OpenAI API [![PyPI version](https://img.shields.io/pypi/v/openai_api_call.svg)](https://pypi.python.org/pypi/openai_api_call) -[![Tests](https://github.com/RexWzh/openai_api_call/actions/workflows/test.yml/badge.svg)](https://github.com/RexWzh/openai_api_call/actions/workflows/test.yml/) +[![Tests](https://github.com/cubenlp/openai_api_call/actions/workflows/test.yml/badge.svg)](https://github.com/cubenlp/openai_api_call/actions/workflows/test.yml/) [![Documentation Status](https://img.shields.io/badge/docs-github_pages-blue.svg)](https://apicall.wzhecnu.cn) OpenAI API 的简单封装,用于发送 prompt 并返回 response。 @@ -154,4 +154,4 @@ chat.show_usage_status() - 版本 `0.2.0` 改用 `Chat` 类型作为中心交互对象 - 版本 `0.3.0` 开始不依赖模块 `openai.py` ,而是直接使用 `requests` 发送请求 - 支持对每个 `Chat` 使用不同 API 密钥 - - 支持使用代理链接 + - 支持使用代理链接 \ No newline at end of file diff --git a/docs/installation.rst b/docs/installation.rst index 073f401..17fe821 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -32,13 +32,13 @@ You can either clone the public repository: .. code-block:: console - $ git clone git://github.com/RexWzh/openai_api_call + $ git clone git://github.com/cubenlp/openai_api_call Or download the `tarball`_: .. code-block:: console - $ curl -OJL https://github.com/RexWzh/openai_api_call/tarball/master + $ curl -OJL https://github.com/cubenlp/openai_api_call/tarball/master Once you have a copy of the source, you can install it with: @@ -47,5 +47,5 @@ Once you have a copy of the source, you can install it with: $ python setup.py install -.. _Github repo: https://github.com/RexWzh/openai_api_call -.. _tarball: https://github.com/RexWzh/openai_api_call/tarball/master +.. _Github repo: https://github.com/cubenlp/openai_api_call +.. _tarball: https://github.com/cubenlp/openai_api_call/tarball/master diff --git a/openai_api_call/__init__.py b/openai_api_call/__init__.py index eb3a0ec..b8b44c4 100644 --- a/openai_api_call/__init__.py +++ b/openai_api_call/__init__.py @@ -2,7 +2,7 @@ __author__ = """Rex Wang""" __email__ = '1073853456@qq.com' -__version__ = '0.3.10' +__version__ = '0.4.0' import os from .chattool import Chat, Resp, chat_completion, usage_status diff --git a/openai_api_call/chattool.py b/openai_api_call/chattool.py index 4890c86..8f49317 100644 --- a/openai_api_call/chattool.py +++ b/openai_api_call/chattool.py @@ -16,12 +16,12 @@ class Chat(): def __init__( self , msg:Union[List[Dict], None, str]=None , api_key:Union[None, str]=None) -> None: - """Chat object - + """Initialize the chat log + Args: msg (Union[List[Dict], None, str], optional): chat log. Defaults to None. api_key (Union[None, str], optional): API key. Defaults to None. - + Raises: ValueError: msg should be a list of dict, a string or None """ @@ -144,10 +144,13 @@ def show_usage_status(self, thismonth:bool=True, recent:int=10, duration:int=99) if thismonth: duration = datetime.datetime.now().day - 1 storage, usage, rem, recent_usage = self.get_usage_status(recent=recent, duration=duration) - print(f"Total account: {storage:.4f}$") - print(f"Total usage(the last {len(recent_usage)} days): {usage:.4f}$") + print(f"Amount: {storage:.4f}$") if thismonth: - print(f"Total remaining(this month): {rem:.4f}$") + print(f"Usage(this month): {usage:.4f}$") + print(f"Remaining(this month): {rem:.4f}$") + if len(recent_usage) > 0: + usage = sum(recent_usage.values()) + print(f"Usage(the last {len(recent_usage)} days): {usage:.4f}$") for date, cost in recent_usage.items(): print(f"{date}: {cost:.4f}$") diff --git a/setup.py b/setup.py index e84b48a..a3687d5 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with open('README.md') as readme_file: readme = readme_file.read() -VERSION = '0.3.10' +VERSION = '0.4.0' requirements = ['Click>=7.0', 'requests>=2.20'] @@ -42,7 +42,7 @@ packages=find_packages(include=['openai_api_call', 'openai_api_call.*']), test_suite='tests', tests_require=test_requirements, - url='https://github.com/RexWzh/openai_api_call', + url='https://github.com/cubenlp/openai_api_call', version=VERSION, zip_safe=False, )