DoctorGPT brings GPT into production for error diagnosing!
DoctorGPT 把 GPT 投入生产用来进行错误诊断!
(Not production ready, yet...)
还未准备好投产,但 。。。
DoctorGPT is a lightweight self-contained binary that monitors your application logs for problems and diagnoses them.
DoctorGPT 是一个轻量级的,自包含的二进制文件,可以监控应用日志中的问题并进行诊断。
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
Configuration
See example yaml documentation:
# 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<LEVEL>\w+):([\w\.\_]+)\(\d+\)\]\s+(?P<MESSAGE>.*)$'
# 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<DATE>[^ ]+)\s+(?P<TIME>[^ ]+)\s+[^ ]+(?P<LEVEL>[^ ]+)\s+(?P<MESSAGE>.*)$'
# When more than one trigger is present, just one trigger is sufficient to trigger a diagnosis
triggers:
- variable: "LEVEL"
regex: "Default"
- variable: "MESSAGE"
regex: "(?i)ERROR:"
# Filters and excludes were not specified
# Last parser must always be a generic one that matches any line
- regex: '^(?P<MESSAGE>.*)$'
# All filters, triggers and excludes were not specified
Example
This is how the file ::Users::yamilmolinar::error.log:18.diagnosed
file looks like:
LOG LINE:
/Users/yamilmolinar/error.log:18
BASE 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
CONTEXT:
yarn run v1.22.19
$ tsnd --respawn --transpile-only --no-notify --ignore-watch node_modules src/index.ts
[INFO] 15:20:25 ts-node-dev ver. 2.0.0 (using ts-node ver. 10.8.0, typescript ver. 4.8.4)
[INFO] DB ready
[INFO] Auth ready
[INFO] Apollo setup
[INFO] Server started at http://localhost:5555/graphql
标签:yamilmolinar,log,--,DoctorGPT,your,User,public
From: https://www.cnblogs.com/505donkey/p/17706359.html