From f2e8c0bdd6b988b940364f453ed63ab9828661e4 Mon Sep 17 00:00:00 2001 From: deven367 Date: Wed, 21 Aug 2024 15:18:14 -0400 Subject: [PATCH] docstrings --- ttf/talk.py | 15 +++++++++++++++ ttf/utils.py | 29 +++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/ttf/talk.py b/ttf/talk.py index 7131534..a783d5a 100644 --- a/ttf/talk.py +++ b/ttf/talk.py @@ -5,6 +5,15 @@ def chat_with_pdf(path: str, prompt:str) -> str: + """_summary_ + + Args: + path (str): _description_ + prompt (str): _description_ + + Returns: + str: _description_ + """ reader = PdfReader(path) text = "\n".join([page.extract_text() for page in reader.pages]) @@ -18,6 +27,12 @@ def chat_with_pdf(path: str, prompt:str) -> str: @click.option("--pdf", "-p", type=click.Path(exists=True), required=True) @click.option("--prompt", "-pr", type=str, default="Summarize the following text") def main(pdf, prompt): + """_summary_ + + Args: + pdf (_type_): _description_ + prompt (_type_): _description_ + """ chat_with_pdf(pdf, prompt) if __name__ == "__main__": diff --git a/ttf/utils.py b/ttf/utils.py index 2c015df..9d162c0 100644 --- a/ttf/utils.py +++ b/ttf/utils.py @@ -8,8 +8,18 @@ # Function to send a message to the OpenAI chatbot model and return its response -def send_message(message_log): +def send_message(message_log: list) -> str: + """_summary_ + Args: + message_log (list): _description_ + + Raises: + ValueError: _description_ + + Returns: + str: _description_ + """ try: api_key = os.environ["ANTHROPIC_API_KEY"] except KeyError: @@ -27,7 +37,12 @@ def send_message(message_log): -def chat_with(user_input:str): +def chat_with(user_input:str)-> None: + """_summary_ + + Args: + user_input (str): _description_ + """ # Initialize the conversation history with a message from the chatbot # message_log = [{"role": "system", "content": "You are a helpful assistant."}] message_log = [] @@ -82,6 +97,16 @@ def chat_with(user_input:str): def summarize_pdf_old(client: anthropic.Client, path: str, prompt:str) -> str: + """_summary_ + + Args: + client (anthropic.Client): _description_ + path (str): _description_ + prompt (str): _description_ + + Returns: + str: _description_ + """ reader = PdfReader(path) text = "\n".join([page.extract_text() for page in reader.pages])