{"id":19442308,"url":"https://github.com/treebeardtech/nbwrite","last_synced_at":"2026-05-08T06:14:05.056Z","repository":{"id":203481946,"uuid":"702909007","full_name":"treebeardtech/nbwrite","owner":"treebeardtech","description":"🤖 generate Python examples using AI","archived":false,"fork":false,"pushed_at":"2023-10-25T10:26:04.000Z","size":324,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-08T03:34:23.481Z","etag":null,"topics":["jupyter","llm","openai","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/nbwrite","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/treebeardtech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.MD","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-10T08:36:30.000Z","updated_at":"2023-10-25T10:23:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"a6f616d0-08ae-40d5-80b9-85d4134422e8","html_url":"https://github.com/treebeardtech/nbwrite","commit_stats":{"total_commits":72,"total_committers":2,"mean_commits":36.0,"dds":0.02777777777777779,"last_synced_commit":"b0c33934bcaa6fc0a0918c3890d5996f44ea8b4a"},"previous_names":["treebeardtech/nbwrite"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treebeardtech%2Fnbwrite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treebeardtech%2Fnbwrite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treebeardtech%2Fnbwrite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treebeardtech%2Fnbwrite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/treebeardtech","download_url":"https://codeload.github.com/treebeardtech/nbwrite/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240626742,"owners_count":19831592,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jupyter","llm","openai","python"],"created_at":"2024-11-10T15:38:55.566Z","updated_at":"2026-05-08T06:14:00.022Z","avatar_url":"https://github.com/treebeardtech.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🤖 nbwrite\n\n**Note: This is an experimental use case for LLMs, the output may at times be unhelpful or inappropriate**\n\nnbwrite is a CLI tool which generates notebook-based Python examples using LLMs\n\nPotential use cases include:\n1. You are writing a Python package and you want to produce executable tutorials for your stakeholders\n2. You are using a Python package and you want to generate a kick-start guide\n3. You want to generate regression tests for a python package\n\n## Features\n\n- Converts a set of steps and a task description into an executable Python notebook\n- Configurable OpenAI API parameters\n- Generate notebooks based on your own code using retrieval augmented generation\n\n## Getting Started\n\n### 1. Install via any Python package manager\n\n```sh\npip install nbwrite\n```\n\n### 2. Setup your OpenAI API Access\n\nYou will need to create an account and potentially buy credits via https://platform.openai.com/\n```sh\nexport OPENAI_API_KEY='sk-xxxx'\n```\n\n### 3. Create a spec file for your generation job\n\ne.g. nbwrite/example1.yaml:\n```yaml\ntask: |\n  Plot the iris dataset using pandas\ngeneration:\n  count: 2\n```\n\n### 4. Generate some notebooks\n\n```sh\nnbwrite ./nbwrite/example1.yaml\n```\n\nYour outputs will be in your current directory\n\n## Guides\n\n### Generate guides for my closed-source code\n\nYou will need to install the 'rag' extra `pip install 'nbwrite[rag]'`\n\nBy default, OpenAI's models can generate docs based on parametric knowledge.\nThis is limited to popular open source libraries.\n\nThe `packages` input in the spec file can be used to reference Python packages in your\ncurrent environment, which will be indexed in a local Vector DB. Code relevant to the\ntask is then stuffed into the prompt.\n\nYou can pass in an arbitrary number of packages, just remember that the code will be\nsent to OpenAI to create embeddings, and this costs money.\n\nexample:\n```yaml\npackages:\n  - my_internal_pkg\n  - another.internal.pkg\n```\n\n### Customise the OpenAI parameters\n\nYou can modify both the system prompt and the llm args to try out different OpenAI models,\ntemperatures, etc. See [Langchain's API ref](https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.BaseOpenAI.html#langchain.llms.openai.BaseOpenAI)\n\nNote! This is a confusing use case -- change it to something relevant to your work.\n\n```yaml\ntask: |\n  Create a hello world notebook 'x.ipynb', use nbmake's NotebookRun class to test it from a Python application\nsteps:\n  - Create a hello world notebook using nbformat\n  - Use nbmake's NotebookRun class to execute it from a Python application\n  - Check the output notebook printed what we were expecting\npackages:\n  - nbmake\n  - nbformat\n  - nbclient\ngeneration:\n  count: 2 # number of notebooks to generate\n  # system_prompt:\n  llm_kwargs:\n    # https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.BaseOpenAI.html#langchain.llms.openai.BaseOpenAI\n    model_name: gpt-3.5-turbo # The API name of the model as per https://platform.openai.com/docs/models\n    temperature: 0.5\n  retriever_kwargs:\n    k: 3\n    search_type: similarity\n```\n\n## FAQs and Troubleshooting\n\n### How much does this cost\n\nIt depends on (a) the model you use and other params such as context length, (b) the number of outputs you generate.\n\nSee OpenAI usage here https://platform.openai.com/account/usage\n\n### Debugging with Phoenix\n\nThis is an Alpha stage product, and we encourage you to investigate and report bugs\n\nYou will need to install the 'tracing' extra `pip install 'nbwrite[tracing]'`\n\nFor any errors occurring during the main generation process, it's possible to view traces\nusing Phoenix.\n\n1. Start Phoenix with this script\n\n    ```sh\n    #! /usr/bin/env python\n\n    import phoenix\n    phoenix.launch_app()\n\n    input(\"Press any key to exit...\")\n    ```\n1. In another termianl, run nbwrite with the following var set: `export NBWRITE_PHOENIX_TRACE=1`\n1. Check the phoenix traces in the dashboard (default http://127.0.0.1:6060/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreebeardtech%2Fnbwrite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftreebeardtech%2Fnbwrite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreebeardtech%2Fnbwrite/lists"}