Functions | Variables
gpt_generate Namespace Reference

Functions

def generate_ipynb (str file_path, openai_client)
 
def is_url_valid (url)
 
def save_ipynb (str text, str file_path)
 

Variables

string _asst_id = "asst_na7wYBtXyGU0x5t2RdcnpxzP"
 
string _gtsam_gh_base = "https://raw.githubusercontent.com/borglab/gtsam/refs/heads/develop/"
 
string _output_folder = "output"
 
string _request_text = "Document the file found at {}."
 
 args = parser.parse_args()
 
 client = OpenAI()
 
 help
 
 nargs
 
 parser
 

Detailed Description

GTSAM Copyright 2010-2025, Georgia Tech Research Corporation,
Atlanta, Georgia 30332-0415
All Rights Reserved

See LICENSE for the license information

Author: Porter Zach

This script generates interactive Python notebooks (.ipynb) that document GTSAM 
header files. Since inserting the text of the file directly into the prompt
might be too many tokens, it retrieves the header file content from the GTSAM 
GitHub repository. It then sends it to OpenAI's API for processing, and saves 
the generated documentation as a Jupyter notebook.

Functions:
    is_url_valid(url: str) -> bool:
        Verifies that the supplied URL does not return a 404.

    save_ipynb(text: str, file_path: str) -> str:
        Saves the provided text to a single Markdown cell in a new .ipynb file.

    generate_ipynb(file_path: str, openai_client):
        Generates an interactive Python notebook for the given GTSAM header file 
        by sending a request to OpenAI's API and saving the response.

Usage:
    Run the script with paths to GTSAM header files as arguments. For example:
        python gpt_generate.py gtsam/geometry/Pose3.h

Function Documentation

◆ generate_ipynb()

def gpt_generate.generate_ipynb ( str  file_path,
  openai_client 
)
Generate an interactive Python notebook for the given GTSAM header file.

Args:
    file_path (str): The fully-qualified path from the root of the gtsam 
        repository to the header file that will be documented.
    openai_client (openai.OpenAI): The OpenAI client to use.

Definition at line 72 of file gpt_generate.py.

◆ is_url_valid()

def gpt_generate.is_url_valid (   url)
Verify that the supplied URL does not return a 404.

Definition at line 45 of file gpt_generate.py.

◆ save_ipynb()

def gpt_generate.save_ipynb ( str  text,
str  file_path 
)
Save text to a single Markdown cell in a new .ipynb file.

Definition at line 54 of file gpt_generate.py.

Variable Documentation

◆ _asst_id

string gpt_generate._asst_id = "asst_na7wYBtXyGU0x5t2RdcnpxzP"
private

Definition at line 41 of file gpt_generate.py.

◆ _gtsam_gh_base

string gpt_generate._gtsam_gh_base = "https://raw.githubusercontent.com/borglab/gtsam/refs/heads/develop/"
private

Definition at line 40 of file gpt_generate.py.

◆ _output_folder

string gpt_generate._output_folder = "output"
private

Definition at line 39 of file gpt_generate.py.

◆ _request_text

string gpt_generate._request_text = "Document the file found at {}."
private

Definition at line 42 of file gpt_generate.py.

◆ args

gpt_generate.args = parser.parse_args()

Definition at line 132 of file gpt_generate.py.

◆ client

gpt_generate.client = OpenAI()

Definition at line 135 of file gpt_generate.py.

◆ help

gpt_generate.help

Definition at line 129 of file gpt_generate.py.

◆ nargs

gpt_generate.nargs

Definition at line 128 of file gpt_generate.py.

◆ parser

gpt_generate.parser
Initial value:
1 = argparse.ArgumentParser(
2  prog="gpt_generate",
3  description=
4  "Generates .ipynb documentation files given paths to GTSAM header files."
5  )

Definition at line 121 of file gpt_generate.py.



gtsam
Author(s):
autogenerated on Wed May 28 2025 03:14:02