# DoctorGPT DoctorGPT brings GPT into production for error diagnosing! (Not production ready, yet...) DoctorGPT is a lightweight self-contained binary that monitors your application logs for problems and diagnoses them. ## Usage `OPENAI_KEY=$YOUR_KEY doctorgpt --logfile="program.log" --configfile="config.yaml" --outdir="~/errors"` DoctorGPT will start tailing `program.log` (without stopping). For each log line, user-defined parsers triggering a diagnosis event (based on regex variable matches) will generate a diagnosis file (see example below) under directory `~/errors` using the triggered log line and all previous log context using the OpenAI API. `config.yaml` file is used at startup to configure the program. ## CLI flags - `--logfile (string)` log file to tail and monitor - `--configfile (string)` yaml config file location - `--outdir (string)` diagnosis files directory (created if it does not exist) - `--bundlingtimeoutseconds (int)` wait some time for logs to come-in after the triggered line (for multi-line error dumps) (`default: 5`) - `--debug (bool)` debug logging (`default: true`) - `--buffersize (int)` maximum number of log entries per buffer (`default: 100`) - `--maxtokens (int)` maximum number of tokens allowed in API (`default: 8000`) - `--gptmodel (string)` GPT model to use (`default: "gpt-4"`). For list of models see: [OpenAI API Models](https://platform.openai.com/docs/models/overview) ## Configuration See example yaml documentation: ```yaml # Prompt to be sent alongside error context to the GPT API prompt: "You are ErrorDebuggingGPT. Your sole purpose in this world is to help software engineers by diagnosing software system errors and bugs that can occur in any type of computer system. The message following the first line containing \"ERROR:\" up until the end of the prompt is a computer error no more and no less. It is your job to try to diagnose and fix what went wrong. Ready?\nERROR:\n$ERROR" parsers: # Matches line: [1217/201832.950515:ERROR:cache_util.cc(140)] Unable to move cache folder GPUCache to old_GPUCache_000 - regex: '^\[(\d{4}\/\d{6}\.\d{6}):(?P\w+):([\w\.\_]+)\(\d+\)\]\s+(?P.*)$' # Conditions in which the parsed log will trigger a diagnosis triggers: - variable: "LEVEL" regex: "ERROR" # Conditions in which the parsed log will be ignored for triggers # To create exceptions which won't trigger the GPT API filters: - variable: "MESSAGE" regex: "HTTP 401" # Conditions in which the parsed log will be ignored and excluded from the API context # For sensitive or spammy log entries. These will never be sent to the GPT API excludes: - variable: "LEVEL" regex: "DEBUG" # Matches line: 2022-01-27 21:37:36.776 0x2eb3 Default 511 photolibraryd: PLModelMigration.m:314 Creating sqlite error indicator file - regex: '^(?P[^ ]+)\s+(?P