Appearance
revChatGPT.V1
标准 ChatGPT
日志记录
python
def logger(is_timed: bool)
日志记录装饰器
参数:
is_timed布尔类型 - 是否在退出日志中包含函数运行时间
返回值:
_type_- 装饰函数
Chatbot对象
python
class Chatbot()
ChatGPT 的 Chatbot 对象
__init__
python
@logger(is_timed=True)
def __init__(config: dict[str, str],
conversation_id: str | None = None,
parent_id: str | None = None,
session_client=None,
lazy_loading: bool = False) -> None
初始化一个 Chatbot
参数:
configdict[str, str] - 登录名和代理信息。示例
{
"email"- "OpenAI 账户邮箱","password"- "OpenAI 账户密码","session_token"- "<session_token>""access_token"- "<access_token>""proxy"- "<proxy_url_string>","paid"- True/False #是不是plus帐户}
有关这些的更多详细信息,请访问 https://github.com/acheong08/ChatGPT#configuration
conversation_idstr | None, optional - 要继续 conversation 的 ID。默认为 Noneparent_idstr | None, optional - 要继续的上一条响应消息的 ID。默认为 Nonesession_clienttype, optional - 描述. 默认为 None
错误对象:
Exception- 描述
设置访问令牌
python
@logger(is_timed=False)
def set_access_token(access_token: str) -> None
在请求标头和 self.config 中设置访问令牌,然后将其缓存到文件中。
参数:
access_tokenstr - 访问令牌
询问
python
@logger(is_timed=True)
def ask(prompt: str,
conversation_id: str | None = None,
parent_id: str | None = None,
timeout: float = 360) -> str
给 chatbot 提问题
参数:
promptstr - 问题conversation_idstr | None, optional - UUID 用于继续对话。默认为 Noneparent_idstr | None, optional - 用于继续发送消息的 UUID。默认为 Nonetimeoutfloat, optional - 获取完整响应的超时,单位为秒。默认为 360 秒
错误对象:
Error- 描述Exception- 描述Error- 描述Error- 描述Error- 描述
生成器:
_type_- 描述
获取 conversations
python
@logger(is_timed=True)
def get_conversations(offset: int = 0,
limit: int = 20,
encoding: str | None = None) -> list
获取 conversations
参数:
offset: intlimit: int
获取信息历史
python
@logger(is_timed=True)
def get_msg_history(convo_id: str, encoding: str | None = None) -> list
获取消息的历史记录
参数:
id: conversation 的 UUIDencoding: str
获取标题
python
@logger(is_timed=True)
def gen_title(convo_id: str, message_id: str) -> str
生成 conversation 的标题
修改标题
python
@logger(is_timed=True)
def change_title(convo_id: str, title: str) -> None
修改 conversation 的标题
参数:
id: conversation 的 UUIDtitle: str
删除 conversation
python
@logger(is_timed=True)
def delete_conversation(convo_id: str) -> None
删除 conversation
参数:
id: conversation 的 UUID
清理 conversation
python
@logger(is_timed=True)
def clear_conversations() -> None
删除所有的 conversation
重置 Chatbot
python
@logger(is_timed=False)
def reset_chat() -> None
重置 conversation ID 和父类 ID。
返回值:
None
回滚 conversation
python
@logger(is_timed=False)
def rollback_conversation(num: int = 1) -> None
回滚 conversation
参数:
num: int. 要回滚的消息数
返回值:
None
异步Chatbot对象
python
class AsyncChatbot(Chatbot)
用于 ChatGPT 的异步 Chatbot 对象
询问
python
async def ask(prompt: str,
conversation_id: str | None = None,
parent_id: str | None = None,
timeout: int = 360) -> dict
问 Chatbot 问题
获取 conversation
python
async def get_conversations(offset: int = 0, limit: int = 20) -> list
获取 conversation
参数:
offset: intlimit: int
获取信息历史
python
async def get_msg_history(convo_id: str,
encoding: str | None = "utf-8") -> dict
获取消息的历史
参数:
id: conversation 的 UUID
获取标题
python
async def gen_title(convo_id: str, message_id: str) -> None
生成 conversation 的标题
修改标题
python
async def change_title(convo_id: str, title: str) -> None
修改 conversation 的标题
参数:
convo_id: conversation 的 UUIDtitle: str
删除 conversation
python
async def delete_conversation(convo_id: str) -> None
删除 conversation
参数:
convo_id: conversation 的 UUID
清理 conversation
python
async def clear_conversations() -> None
删除所有的 conversation
配置
python
@logger(is_timed=False)
def configure() -> dict
在以下位置查找配置文件:
主函数
python
@logger(is_timed=False)
def main(config: dict) -> NoReturn
ChatGPT 命令行程序主要功能