Skip to content

Commit

Permalink
docs: more use of rubric::, use sphinxcontrib.asciinema to embed player
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Oct 10, 2024
1 parent 5c827eb commit fdfc658
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 82 deletions.
5 changes: 2 additions & 3 deletions docs/automation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ We will be using shell scripts, cron jobs, and other tools to automate the workf

.. note::

This is a work in progress. We intend to make gptme more powerful for automations, see `issue #1 <https://github.com/ErikBjare/gptme/issues/143>`_ for more details on this plan.
This is a work in progress. We intend to make gptme more powerful for automations, see `issue #143 <https://github.com/ErikBjare/gptme/issues/143>`_ for more details on this plan.



Example: Implement feature
--------------------------
.. rubric:: Example: Implement feature

This example demonstrates how to implement a feature in a codebase using gptme, making sure the code is correct before creating a pull request.

Expand Down
3 changes: 1 addition & 2 deletions docs/automation/example_activity_summary.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Example: Daily Activity Summary
-------------------------------
.. rubric:: Example: Daily Activity Summary

Here's an example of how to use gptme to generate a daily summary based on ActivityWatch data using a shell script:

Expand Down
4 changes: 1 addition & 3 deletions docs/automation/example_code_review.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Example: Automated Code Review
------------------------------
.. rubric:: Example: Automated Code Review

This example demonstrates a simple and composable approach to automated code review using gptme and shell scripting.

Expand All @@ -8,7 +7,6 @@ This example demonstrates a simple and composable approach to automated code rev
.. code-block:: bash
#!/bin/bash
# Usage: ./review_pr.sh <repo> <pr_number>
repo=$1
Expand Down
16 changes: 0 additions & 16 deletions docs/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,14 @@ gptme provides the following commands:

This is the full CLI reference. For a more concise version, run ``gptme --help``.

.. rubric:: gptme

You can skip confirmation prompts and run in non-interactive mode to terminate when all prompts have been completed:

.. code-block:: bash
gptme --non-interactive --no-confirm 'create a snake game using curses in snake.py, dont run it' '-' 'make the snake green and the apple red'
This should make it first write snake.py, then make the change in a following prompt.

The '-' is special "multiprompt" syntax that tells the assistant to wait for the assistant to finish work on the next prompt (run until no more tool calls) before continuing.

.. click:: gptme.cli:main
:prog: gptme
:nested: full

.. rubric:: gptme-server

.. click:: gptme.server:main
:prog: gptme-server
:nested: full

.. rubric:: gptme-eval

.. click:: gptme.eval:main
:prog: gptme-eval
:nested: full
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def setup(app):
"sphinx.ext.autosectionlabel",
"sphinx_click",
"sphinxcontrib.programoutput",
"sphinxcontrib.asciinema",
]


Expand Down
74 changes: 29 additions & 45 deletions docs/demos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,80 +10,64 @@ Demos
:local:
:backlinks: none

Snake with curses
-----------------

Generate a snake game that runs in the terminal using curses, and then modify it to add color.

.. raw:: html
.. rubric:: Snake with curses

<a href="https://asciinema.org/a/621992">
<img src="https://github.com/ErikBjare/gptme/assets/1405370/72ac819c-b633-495e-b20e-2e40753ec376" width="600" />
</a>
Generate a snake game that runs in the terminal using curses, and then modify it to add color.

.. asciinema:: 621992
:autoplay: true

Steps

- Create a snake game with curses to snake.py
- Running fails, ask gptme to fix a bug
- Game runs
- Ask gptme to add color
- Minor struggles
- Finished game with green snake and red apple pie!
#. Create a snake game with curses to snake.py
#. Running fails, ask gptme to fix a bug
#. Game runs
#. Ask gptme to add color
#. Minor struggles
#. Finished game with green snake and red apple pie!

Mandelbrot with curses
----------------------
.. rubric:: Mandelbrot with curses

Generate a program that renders mandelbrot with curses, and then modify it to add color.

.. raw:: html

<a href="https://asciinema.org/a/621991">
<img src="https://github.com/ErikBjare/gptme/assets/1405370/570860ac-80bd-4b21-b8d1-da187d7c1a95" width="600" />
</a>
.. asciinema:: 621991
:autoplay: true

Steps

- Render mandelbrot with curses to mandelbrot_curses.py
- Program runs
- Add color
#. Render mandelbrot with curses to mandelbrot_curses.py
#. Program runs
#. Add color


Fibonacci (old)
---------------
.. rubric:: Fibonacci

An old demo showing off basic code execution and shell interaction.

.. raw:: html

<a href="https://asciinema.org/a/606375">
<img src="https://github.com/ErikBjare/gptme/assets/1405370/5dda4240-bb7d-4cfa-8dd1-cd1218ccf571" width="600" />
</a>
.. asciinema:: 606375
:autoplay: true

Steps

- Create a new dir 'gptme-test-fib' and git init
- Write a fib function to fib.py, commit
- Create a public repo and push to GitHub
#. Create a new dir 'gptme-test-fib' and git init
#. Write a fib function to fib.py, commit
#. Create a public repo and push to GitHub

Answer question from URL
------------------------

Showing off basic URL loading from the prompt, and answering questions based on the content.
.. rubric:: Answer question from URL

.. raw:: html
Showing off basic URL loading from the prompt, and answering questions based on the content.

<a href="https://asciinema.org/a/621997">
<img src="https://github.com/ErikBjare/gptme/assets/1405370/bae45488-f4ed-409c-a656-0c5218877de2" />
</a>
.. asciinema:: 621997
:autoplay: true

Steps

- Ask who the CEO of Superuser Labs is, passing website URL
- gptme browses the website, and answers correctly
#. Ask who the CEO of Superuser Labs is, passing website URL
#. gptme browses the website, and answers correctly


Edit history with /edit
-----------------------
.. rubric:: Edit history with /edit

TODO
28 changes: 16 additions & 12 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ A list of things you can do with gptme.

To see example output without running the commands yourself, check out the :doc:`demos`.


.. code-block:: bash
gptme 'write a web app to particles.html which shows off an impressive and colorful particle effect using three.js'
Expand All @@ -25,19 +24,28 @@ To see example output without running the commands yourself, check out the :doc:
# it can read files using tools, if contents not provided in prompt
gptme 'suggest improvements to my vimrc'
Do you have a cool example? Share it with us in the `Discussions <https://github.com/ErikBjare/gptme/discussions>`_!


Commit Message Generator
------------------------
.. rubric:: Skip confirmation and run in non-interactive mode

You can skip confirmation prompts and run in non-interactive mode to terminate when all prompts have been completed.

This should make it first write snake.py, then make the change in a following prompt:

.. code-block:: bash
gptme --non-interactive --no-confirm 'create a snake game using curses in snake.py, dont run it' '-' 'make the snake green and the apple red'
The '-' is special "multiprompt" syntax that tells the assistant to wait for the assistant to finish work on the next prompt (run until no more tool calls) before continuing. For more such non-interactive examples, see :doc:`automation`.


.. rubric:: Generate Commit Messages

Generate meaningful commit messages based on your git diff:

.. code-block:: bash
#!/bin/bash
# Usage: git-commit-auto
msg_file=$(mktemp)
git diff --cached | gptme --non-interactive "Write a concise, meaningful commit message for this diff to `$msg_file`.
Expand All @@ -46,18 +54,14 @@ Generate meaningful commit messages based on your git diff:
git commit -F "$msg_file"
Generate Documentation
----------------------
Generate docstrings for all functions in a file:
.. rubric:: Generate Documentation

.. TODO: not automation, move to examples.
Generate docstrings for all functions in a file:

.. code-block:: bash
#!/bin/bash
gptme --non-interactive "Patch these files to include concise docstrings for all functions, skip functions that already have docstrings. Include: brief description, parameters." $@
These examples demonstrate how gptme can be used to create simple yet powerful automation tools. Each script can be easily customized and expanded to fit specific project needs.

15 changes: 14 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ sphinx = "^8.0"
sphinx-click = "^6.0"
sphinx-book-theme = "^1.0.1"
sphinxcontrib-programoutput = "^0.17"
sphinxcontrib-asciinema = "^0.4.2"
myst-parser = "*"

# types
Expand Down

0 comments on commit fdfc658

Please sign in to comment.