terry3041 / pyChatGPT

An unofficial Python wrapper for OpenAI's ChatGPT API
GNU General Public License v3.0
1.35k stars 255 forks source link

Cannot connect to chrome #82

Open ARezaK opened 1 year ago

ARezaK commented 1 year ago

Intermittently having this error. Will try to start up a session and seems to work the first couple of times and then will stop working. Running in docker with ubuntu. Restarting the docker container fixes the issue for a while

image

My code:

api1 = ChatGPT(session_token)  # auth with session token
summary = api1.send_message(msg_to_send)
print(summary)
if "I'm sorry" in summary['message']:
    raise Exception("ChatGPT could not get information")
# save summary to file
with open('data/' + ticker + '.summary' + '.txt', 'w+') as outfile:
    outfile.write(summary['message'])
api1.__del__()
terry3041 commented 1 year ago

Can you show your Dockerfile?

kimkimkeren commented 1 year ago

Same problem here, but I'm running using aws lambda instead of ubuntu

My dockerfile :

FROM public.ecr.aws/lambda/python:3.9

COPY lambda_function.py ${LAMBDA_TASK_ROOT}

RUN yum install -y wget
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
RUN yum install -y ./google-chrome-stable_current_*.rpm
RUN yum install -y xorg-x11-server-Xvfb gcc-c++
RUN pip3 install pychatgpt tweepy ffmpeg_downloader PyPasser pocketsphinx

CMD [ "lambda_function.lambda_handler" ]
terry3041 commented 1 year ago

Same problem here, but I'm running using aws lambda instead of ubuntu

Should be related to this: https://github.com/ultrafunkamsterdam/undetected-chromedriver/pull/643 Try manually install undetected-chromedriver by pip3 install undetected-chromedriver==3.2.1. I will bump the version of uc later on.

ARezaK commented 1 year ago

My Dockerfile


FROM ubuntu:focal

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
ADD . /app

ENV NAME DOCKER
ENV DEBIAN_FRONTEND=noninteractive
# Prevents Python from buffering stdout and stderr (equivalent to python -u option)
ENV PYTHONUNBUFFERED 1
# Prevents Python from writing pyc files to disc (equivalent to python -B option)
ENV PYTHONDONTWRITEBYTECODE 1

RUN apt-get update && apt-get install -y \
    python3-dev \
    python3-pip \
    apt-utils \
    xvfb \
    wget

# for installing chrome
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN apt install -y ./google-chrome-stable_current_amd64.deb

EXPOSE 5000

COPY requirements.txt /app/requirements.txt

RUN pip3 --no-cache-dir install -r /app/requirements.txt
RUN apt-get update && apt-get install -y build-essential && apt-get install -y wget

CMD gunicorn app:app --timeout 600 --worker-class gevent --bind 0.0.0.0:5000 --reload
kimkimkeren commented 1 year ago

Same problem here, but I'm running using aws lambda instead of ubuntu

Should be related to this: ultrafunkamsterdam/undetected-chromedriver#643 Try manually install undetected-chromedriver by pip3 install undetected-chromedriver==3.2.1. I will bump the version of uc later on.

after adding undetected-chromedriver==3.2.1, the problem still persists here