Skip to content
This repository was archived by the owner on Aug 10, 2023. It is now read-only.
Antonio Cheong edited this page Feb 24, 2023 · 26 revisions

revChatGPT.V1

Standard ChatGPT

logger

def logger(is_timed)

Logger decorator

Error Objects

class Error(Exception)

Base class for exceptions in this module.

Chatbot Objects

class Chatbot()

Chatbot class for ChatGPT

ask

@logger(is_timed=True)
def ask(prompt, conversation_id=None, parent_id=None, timeout=360)

Ask a question to the chatbot

Arguments:

  • prompt: String
  • conversation_id: UUID
  • parent_id: UUID
  • gen_title: Boolean

get_conversations

@logger(is_timed=True)
def get_conversations(offset=0, limit=20)

Get conversations

Arguments:

  • offset: Integer
  • limit: Integer

get_msg_history

@logger(is_timed=True)
def get_msg_history(convo_id, encoding=None)

Get message history

Arguments:

  • id: UUID of conversation
  • encoding: String

gen_title

@logger(is_timed=True)
def gen_title(convo_id, message_id)

Generate title for conversation

change_title

@logger(is_timed=True)
def change_title(convo_id, title)

Change title of conversation

Arguments:

  • id: UUID of conversation
  • title: String

delete_conversation

@logger(is_timed=True)
def delete_conversation(convo_id)

Delete conversation

Arguments:

  • id: UUID of conversation

clear_conversations

@logger(is_timed=True)
def clear_conversations()

Delete all conversations

reset_chat

@logger(is_timed=False)
def reset_chat() -> None

Reset the conversation ID and parent ID.

Returns:

None

rollback_conversation

@logger
def rollback_conversation(num=1) -> None

Rollback the conversation.

Arguments:

  • num: The number of messages to rollback

Returns:

None

AsyncChatbot Objects

class AsyncChatbot(Chatbot)

Async Chatbot class for ChatGPT

ask

async def ask(prompt, conversation_id=None, parent_id=None, timeout=360)

Ask a question to the chatbot

get_conversations

async def get_conversations(offset=0, limit=20)

Get conversations

Arguments:

  • offset: Integer
  • limit: Integer

get_msg_history

async def get_msg_history(convo_id, encoding="utf-8")

Get message history

Arguments:

  • id: UUID of conversation

gen_title

async def gen_title(convo_id, message_id)

Generate title for conversation

change_title

async def change_title(convo_id, title)

Change title of conversation

Arguments:

  • convo_id: UUID of conversation
  • title: String

delete_conversation

async def delete_conversation(convo_id)

Delete conversation

Arguments:

  • convo_id: UUID of conversation

clear_conversations

async def clear_conversations()

Delete all conversations

get_input

@logger(is_timed=False)
def get_input(prompt)

Multiline input function.

configure

@logger(is_timed=False)
def configure()

Looks for a config file in the following locations:

main

@logger(is_timed=False)
async def main(config: dict)

Main function for the chatGPT program.

Clone this wiki locally