Skip to content

Commit

Permalink
docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
deven367 committed Aug 21, 2024
1 parent d804808 commit f2e8c0b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
15 changes: 15 additions & 0 deletions ttf/talk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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__":
Expand Down
29 changes: 27 additions & 2 deletions ttf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 = []
Expand Down Expand Up @@ -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])

Expand Down

0 comments on commit f2e8c0b

Please sign in to comment.