Skip to content

Instantly share code, notes, and snippets.

@idvorkin
Created March 24, 2024 15:33
Show Gist options
  • Save idvorkin/7f457ef75330f5faee8c9a82a3d0d820 to your computer and use it in GitHub Desktop.
Save idvorkin/7f457ef75330f5faee8c9a82a3d0d820 to your computer and use it in GitHub Desktop.

Changes to idvorkin/nlp Between [2024-03-25] and [3 days ago]

Changes in idvorkin/nlp

  • (#changespy)
  • (#play_langchainpy)
  • (#openai_wrapperpy)
  • (#setuppy)

changes.py

  • +291, -0, * 0:
  • (https://github.com/idvorkin/nlp/blob/303d7c58265b647dead79ccdbaeafd0cab58d1a0/changes.py)
  • Creation of a new Python script to handle Git diffs and summarize changes using OpenAI.
  • Major functionalities include:
    • Asynchronous retrieval of file diffs from Git using specified commit ranges.
    • Summarization of changes in files between two commits.
    • Filtering out specific files (e.g., Jupyter notebooks and back-links.json).
    • Environment setup for OpenAI API key from a secrets file.
    • Generation of prompts for OpenAI to summarize and rank changes based on impact.
    • Command-line interface implementation using Typer for user interaction.
  • Functions to interact with Git:
    • Retrieval of repository path from Git remote URL.
    • Fetching first and last commit hashes within a specified date range.
    • Obtaining a list of changed files between two commits.
  • Utilities for handling dates and generating summaries:
    • Function to calculate tomorrow's date.
    • Prompt generation for summarizing and reordering file changes.
  • Logging and debugging setup with Loguru and PuDB.

play_langchain.py

  • +5, -129, * 0:
  • (https://github.com/idvorkin/nlp/blob/303d7c58265b647dead79ccdbaeafd0cab58d1a0/play_langchain.py)
  • Removed imports of subprocess, langchain_core.messages.human.HumanMessage, langchain.agents.AgentType, langchain.agents.initialize_agent, langchain.agents.load_tools, and replaced langchain_openai.ChatOpenAI with langchain_openai.chat_models.ChatOpenAI and added import of langchain_google_genai.ChatGoogleGenerativeAI.
  • Deleted financial_agent command along with its implementation.
  • Removed the instantiation and usage of ChatOpenAI for chat and chat_model.
  • Deleted changes command and its comprehensive implementation involving git revision specification and file change summaries.
  • Replaced financial_agent command with tell_me_a_joke command that uses ChatGoogleGenerativeAI for generating jokes about software engineers based on a specified count.

openai_wrapper.py

  • +11, -0, * 2
  • (https://github.com/idvorkin/nlp/blob/303d7c58265b647dead79ccdbaeafd0cab58d1a0/openai_wrapper.py)
  • Added a new utility function tracer_project_name to determine the project name based on the caller's file and function.
    • This involves using the inspect module to get the caller's frame and function along with the Path module to extract the filename.
  • Minor refactoring in ask_gpt_n function:
    • Changed loop variable x to _ in list comprehension for response_contents.
    • Added type: Ignore comment to the call to client.chat.completions.create and its messages argument to presumably ignore type checking for these lines.

setup.py

Unranked diff report

changes.py

  • +291, -0, * 0:
  • (https://github.com/idvorkin/nlp/blob/303d7c58265b647dead79ccdbaeafd0cab58d1a0/changes.py)
  • Creation of a new Python script to handle Git diffs and summarize changes using OpenAI.
  • Major functionalities include:
    • Asynchronous retrieval of file diffs from Git using specified commit ranges.
    • Summarization of changes in files between two commits.
    • Filtering out specific files (e.g., Jupyter notebooks and back-links.json).
    • Environment setup for OpenAI API key from a secrets file.
    • Generation of prompts for OpenAI to summarize and rank changes based on impact.
    • Command-line interface implementation using Typer for user interaction.
  • Functions to interact with Git:
    • Retrieval of repository path from Git remote URL.
    • Fetching first and last commit hashes within a specified date range.
    • Obtaining a list of changed files between two commits.
  • Utilities for handling dates and generating summaries:
    • Function to calculate tomorrow's date.
    • Prompt generation for summarizing and reordering file changes.
  • Logging and debugging setup with Loguru and PuDB.---

play_langchain.py

  • +5, -129, * 0:
  • (https://github.com/idvorkin/nlp/blob/303d7c58265b647dead79ccdbaeafd0cab58d1a0/play_langchain.py)
  • Removed imports of subprocess, langchain_core.messages.human.HumanMessage, langchain.agents.AgentType, langchain.agents.initialize_agent, langchain.agents.load_tools, and replaced langchain_openai.ChatOpenAI with langchain_openai.chat_models.ChatOpenAI and added import of langchain_google_genai.ChatGoogleGenerativeAI.
  • Deleted financial_agent command along with its implementation.
  • Removed the instantiation and usage of ChatOpenAI for chat and chat_model.
  • Deleted changes command and its comprehensive implementation involving git revision specification and file change summaries.
  • Replaced financial_agent command with tell_me_a_joke command that uses ChatGoogleGenerativeAI for generating jokes about software engineers based on a specified count.---

openai_wrapper.py

  • +11, -0, * 2
  • (https://github.com/idvorkin/nlp/blob/303d7c58265b647dead79ccdbaeafd0cab58d1a0/openai_wrapper.py)
  • Added a new utility function tracer_project_name to determine the project name based on the caller's file and function.
    • This involves using the inspect module to get the caller's frame and function along with the Path module to extract the filename.
  • Minor refactoring in ask_gpt_n function:
    • Changed loop variable x to _ in list comprehension for response_contents.
    • Added type: Ignore comment to the call to client.chat.completions.create and its messages argument to presumably ignore type checking for these lines.---

setup.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment