Skip to content

Commit

Permalink
docs: improved docs structure (User & Dev guide), improved CLI & API …
Browse files Browse the repository at this point in the history
…Reference, extracted Prompts as new page, added Examples
  • Loading branch information
ErikBjare committed Sep 22, 2024
1 parent a4afd81 commit e1b881a
Show file tree
Hide file tree
Showing 11 changed files with 156 additions and 16 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ clean-test:
cloc: cloc-core cloc-tools cloc-server cloc-tests

cloc-core:
cloc gptme/*.py gptme/*/__init__.py gptme/*/base.py --by-file
cloc gptme/*.py gptme/tools/__init__.py gptme/tools/base.py --by-file

cloc-tools:
cloc gptme/tools/*.py --by-file
Expand All @@ -113,5 +113,11 @@ cloc-server:
cloc-tests:
cloc tests/*.py --by-file

cloc-eval:
cloc gptme/eval/**.py --by-file

cloc-total:
cloc ${SRCFILES} --by-file

bench-importtime:
time poetry run python -X importtime -m gptme --model openrouter --non-interactive 2>&1 | grep "import time" | cut -d'|' -f 2- | sort -n
25 changes: 21 additions & 4 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,46 @@ API Reference

Here is the API reference for ``gptme``.

.. toctree::
:maxdepth: 2
.. contents:: Content
:depth: 5
:local:
:backlinks: none


core
----

Some of the core classes and functions in ``gptme``.

Message
~~~~~~~

A message in the conversation.

.. autoclass:: gptme.message.Message
:members:

Codeblock
~~~~~~~~~

A codeblock in a message, possibly executable by tools.

.. automodule:: gptme.codeblock
:members:

LogManager
~~~~~~~~~~

Holds the current conversation as a list of messages, saves and loads the conversation to and from files, supports branching, etc.

.. automodule:: gptme.logmanager
:members:


prompts
-------

.. automodule:: gptme.prompts
:members:
See `Prompts <prompts.html>`_ for more information.

tools
-----
Expand Down
42 changes: 42 additions & 0 deletions docs/arewetiny.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Are we tiny?
============

gptme is intended to be small and simple, and focus on doing the right thing in the right way, rather than all the things in all the ways.

Since it is built by a single developer, there are limits imposed to how large things can get before it becomes too much to handle. Being aggressive about keeping things small and simple is a way to keep the project maintainable and fun to work on. The fastest way to kill a project is to make it too big and complex, and suffer burnout as a result.

To that end, in this document we will present some statistics about the current state of the project, trying to be mindful to keep an eye on this page and make sure we are not growing too much.


Lines of code
-------------

LoC Core
*******

.. command-output:: make -C .. cloc-core

LoC Tools
*********

.. command-output:: make -C .. cloc-tools

LoC Server
***********

.. command-output:: make -C .. cloc-server

LoC Tests
**********

.. command-output:: make -C .. cloc-tests

LoC Eval
********

.. command-output:: make -C .. cloc-eval

LoC Total
*********

.. command-output:: make -C .. cloc-total
17 changes: 17 additions & 0 deletions docs/cli.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
CLI Reference
=============

gptme provides the following commands:

.. contents:: Commands
:depth: 1
:local:
:backlinks: none

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

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

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

.. click:: gptme.eval:main
:prog: gptme-eval
:nested: full
2 changes: 2 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

import re

from docutils import nodes
Expand Down Expand Up @@ -86,6 +87,7 @@ def setup(app):
"sphinx.ext.extlinks",
"sphinx.ext.autosectionlabel",
"sphinx_click",
"sphinxcontrib.programoutput",
]


Expand Down
13 changes: 13 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Examples
========

A list of things you can do with gptme.

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


.. code-block:: bash
gptme 'write a web app to particles.html which shows off an impressive and colorful particle effect using three.js'
gptme 'render mandelbrot set to mandelbrot.png'
gptme 'suggest improvements to my vimrc'
12 changes: 10 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,25 @@ See the `README <https://github.com/ErikBjare/gptme/blob/master/README.md>`_ fil

.. toctree::
:maxdepth: 2
:caption: Contents
:caption: User Guide

getting-started
examples
demos
tools
providers
server
cli

.. toctree::
:maxdepth: 2
:caption: Developer Guide

prompts
evals
bot
finetuning
cli
arewetiny
api

.. toctree::
Expand Down
7 changes: 7 additions & 0 deletions docs/prompt.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Prompts
=======

Here you can read examples of the system prompts currently used by gptme.

.. automodule:: gptme.prompts
:members:
5 changes: 1 addition & 4 deletions docs/server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,4 @@ It can be started by running the following command:
You can then access the web UI by visiting http://localhost:5000 in your browser.


.. click:: gptme.server.cli:main
:prog: gptme-server
:nested: full
For more usage, see `the CLI documentation <cli.html#gptme-server>`_.
16 changes: 15 additions & 1 deletion poetry.lock

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

25 changes: 21 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ bashlex = "^0.18"
playwright = {version = "^1.37.0", optional=true}
youtube_transcript_api = {version = "^0.6.1", optional = true}

# llm-providers
# providers
openai = "^1.0"
anthropic = "^0.34.0"

Expand All @@ -52,20 +52,28 @@ pillow = {version = "*", optional=true}
flask = {version = "^2.3", optional=true}

[tool.poetry.group.dev.dependencies]
# lint
mypy = "*"
ruff = "*"

# test
pytest = "^7.2"
pytest-cov = "*"
pytest-xdist = "^3.5.0"
pytest-profiling = "^1.7.0"
pytest-dotenv = "^0.5.2"
pytest-timeout = "^2.2.0"
pytest-retry = "^1.6.3"
mypy = "*"
ruff = "*"
greenlet = "*" # dependency of playwright, but needed for coverage

# docs
sphinx = "^6.0"
sphinx-click = "^5.0.1"
sphinx-book-theme = "^1.0.1"
sphinxcontrib-programoutput = "^0.17"
myst-parser = "^2.0.0"
greenlet = "*" # dependency of playwright, but needed for coverage

# types
types-tabulate = "^0.9.0.20240106"
types-lxml = "^2024.9.16"

Expand Down Expand Up @@ -123,6 +131,15 @@ exclude_also = [
"if TYPE_CHECKING:",
]


# TODO: migrate to PEP 621 once supported by poetry
#[project]
#name = "gptme-python"
#dynamic = ["version"]
#
#[tool.setuptools.dynamic]
#version = {attr = "mymodule.__version__"}

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

0 comments on commit e1b881a

Please sign in to comment.