Skip to content

Commit

Permalink
chore: gemini pro api proxy #20
Browse files Browse the repository at this point in the history
  • Loading branch information
OrenZhang committed Jan 19, 2024
1 parent d069afb commit 74d35c4
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 13 additions & 0 deletions bin/proxy_gemini.sh
Original file line number Diff line number Diff line change
@@ -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"
17 changes: 17 additions & 0 deletions bin/proxy_gemini_macos.sh
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 74d35c4

Please sign in to comment.