diff --git a/Dockerfile b/Dockerfile index 14f33d6..27e267b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,4 +2,5 @@ FROM python:3.10 RUN mkdir -p /usr/src/app/logs /usr/src/app/celery-logs COPY . /usr/src/app WORKDIR /usr/src/app -RUN pip3 install -U pip && pip3 install -r requirements.txt -i https://mirrors.cloud.tencent.com/pypi/simple +RUN pip3 install -U pip -i https://mirrors.cloud.tencent.com/pypi/simple && pip3 install -r requirements.txt -i https://mirrors.cloud.tencent.com/pypi/simple +RUN bin/proxy_gemini.sh diff --git a/bin/proxy_gemini.sh b/bin/proxy_gemini.sh new file mode 100755 index 0000000..12e4526 --- /dev/null +++ b/bin/proxy_gemini.sh @@ -0,0 +1,13 @@ +SITE_PACKAGES=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") + +sed -i'.bak' '161a\ + from django.conf import settings' "$SITE_PACKAGES/google/ai/generativelanguage_v1beta/services/generative_service/transports/grpc.py" + +sed -i'.bak2' '175a\ + ("grpc.http_proxy", settings.OPENAI_HTTP_PROXY_URL),' "$SITE_PACKAGES/google/ai/generativelanguage_v1beta/services/generative_service/transports/grpc.py" + +sed -i'.bak' '206a\ + from django.conf import settings' "$SITE_PACKAGES/google/ai/generativelanguage_v1beta/services/generative_service/transports/grpc_asyncio.py" + +sed -i'.bak2' '220a\ + ("grpc.http_proxy", settings.OPENAI_HTTP_PROXY_URL),' "$SITE_PACKAGES/google/ai/generativelanguage_v1beta/services/generative_service/transports/grpc_asyncio.py" diff --git a/bin/proxy_gemini_macos.sh b/bin/proxy_gemini_macos.sh new file mode 100755 index 0000000..3fe4c4b --- /dev/null +++ b/bin/proxy_gemini_macos.sh @@ -0,0 +1,17 @@ +SITE_PACKAGES=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") + +sed -i'.bak' '161a\ + from django.conf import settings\ +' "$SITE_PACKAGES/google/ai/generativelanguage_v1beta/services/generative_service/transports/grpc.py" + +sed -i'.bak2' '175a\ + ("grpc.http_proxy", settings.OPENAI_HTTP_PROXY_URL),\ +' "$SITE_PACKAGES/google/ai/generativelanguage_v1beta/services/generative_service/transports/grpc.py" + +sed -i'.bak' '206a\ + from django.conf import settings\ +' "$SITE_PACKAGES/google/ai/generativelanguage_v1beta/services/generative_service/transports/grpc_asyncio.py" + +sed -i'.bak2' '220a\ + ("grpc.http_proxy", settings.OPENAI_HTTP_PROXY_URL),\ +' "$SITE_PACKAGES/google/ai/generativelanguage_v1beta/services/generative_service/transports/grpc_asyncio.py" diff --git a/requirements.txt b/requirements.txt index da64fc8..585eba9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -22,3 +22,5 @@ tiktoken==0.4.0 # Gemini google-generativeai==0.3.2 +google_api_core==2.15.0 +google-ai-generativelanguage==0.4.0