judahpaul16 / gpt-home

ChatGPT at home! Basically a better Google Nest Hub or Amazon Alexa home assistant. Built on the Raspberry Pi using the OpenAI API.
https://hub.docker.com/r/judahpaul/gpt-home
GNU General Public License v3.0
453 stars 43 forks source link

Web interface event log sometimes truncates logs #19

Open judahpaul16 opened 6 months ago

judahpaul16 commented 6 months ago

I was able to build everything without any errors! I had to run an "apt --fix-broken" though as libflac12 had a number of dependencies to correct and install.

Now, I am getting these messages in the log (assuming that the wake word is "computer" - I don't get a response):

INFO:functions:Timed out, waiting for phrase to start... ERROR:functions:Listening timed out: Traceback (most recent call last): ERROR:functions:Listening timed out: Traceback (most recent call last): ERROR:functions:Listening timed out: Traceback (most recent call last): ERROR:functions:Listening timed out: Traceback (most recent call last): ERROR:functions:Listening timed out: Traceback (most recent call last): ERROR:functions:Listening timed out: Traceback (most recent call last): ERROR:functions:Listening timed out: Traceback (most recent call last):

Originally posted by @brainhig in https://github.com/judahpaul16/gpt-home/issues/12#issuecomment-2098830415

image

judahpaul16 commented 6 months ago

Likely related to how new logs are being split in backend.py by line:

@app.post("/new-logs")
def last_logs(request: Request, last_line_number: Optional[int] = 0):
    log_file_path = PARENT_DIRECTORY / "events.log"

    if log_file_path.exists() and log_file_path.is_file():
        with log_file_path.open("r") as f:
            lines = f.readlines()
            if len(lines) != last_line_number:
                new_logs = lines[last_line_number:]
                return JSONResponse(content={"last_logs": new_logs, "new_last_line_number": len(lines)})
            else:
                return JSONResponse(content={"last_logs": [], "new_last_line_number": len(lines)})
    else:
        return Response(status_code=status.HTTP_404_NOT_FOUND, content="Log file not found")
judahpaul16 commented 5 months ago

This issue persists possibly because of the ` included in some responses.

Web Interface:

image

Expected output:

image