-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docbot)📝: Add a new Jupyter notebook for the docbot functionality
- Create a new Jupyter notebook to integrate various documentation tools. - Set up autoreload for dynamic updates during development. - Implement code cells for handling documentation checks and updates.
- Loading branch information
Showing
1 changed file
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%load_ext autoreload\n", | ||
"%autoreload 2" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from llamabot import SimpleBot, StructuredBot\n", | ||
"import frontmatter\n", | ||
"from pyprojroot import here\n", | ||
"from llamabot.cli.docs import UnifiedDiff, MarkdownSourceFile, documentation_information, ood_checker_sysprompt, DocumentationIssues" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Open up the docs/devcontainer.md file and read YAML header\n", | ||
"markdown_source_path = here() / \"docs\" / \"devcontainer.md\"\n", | ||
"\n", | ||
"src_file = MarkdownSourceFile(markdown_source_path)\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"doc_checker = StructuredBot(system_prompt=ood_checker_sysprompt(), pydantic_model=DocumentationIssues)\n", | ||
"response = doc_checker(documentation_information(src_file, line_numbers=False, issues={}))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"response" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# For each issue in the response, generate a diff hunk against the text file\n", | ||
"from llamabot.cli.docs import docwriter_sysprompt" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"docwriter = SimpleBot(system_prompt=docwriter_sysprompt())\n", | ||
"response = docwriter(documentation_information(src_file, line_numbers=False, issues=response.model_dump()))\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import yaml\n", | ||
"\n", | ||
"with open(markdown_source_path, \"w+\") as f:\n", | ||
" f.write(\"---\\n\")\n", | ||
" # Write the intents to docs\n", | ||
" f.write(yaml.dump(src_file.post.metadata))\n", | ||
" f.write(\"---\\n\")\n", | ||
" f.write(response.content)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "llamabot", | ||
"language": "python", | ||
"name": "llamabot" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |