update docker image

add openai api_base

update api base

update chatgpt add api_base

update chatgpt add api_base
This commit is contained in:
wujiyu115
2023-03-27 17:20:32 +08:00
parent ad99c5909c
commit 2fe283d304
6 changed files with 71 additions and 1 deletions

45
.github/workflows/docker-image.yaml vendored Normal file
View File

@@ -0,0 +1,45 @@
# docker-image.yml
name: Publish Docker image
on:
push:
branches: # master分支有push时触发此workflow
- 'master'
tags: # tag更新时触发此workflow
- '*'
jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }} # 配置dockerhub的认证在Github项目主页 【Settings】 -> 【Secrets】 添加对应变量
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: jungwinter/split@v2
id: split
with:
msg: ${{ github.repository }}
separator: "/"
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ steps.split.outputs._1 }} #dockerhub用户名/仓库名
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

11
Dockerfile Normal file
View File

@@ -0,0 +1,11 @@
FROM python:3.7-alpine
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["python", "app.py"]

View File

@@ -3,6 +3,7 @@
"type" : "chatgpt",
"openai": {
"api_key": "YOUR API KEY",
"api_base": "https://api.xxx.com/v1",
"model": "gpt-3.5-turbo",
"proxy": "",
"conversation_max_tokens": 1000,

View File

@@ -13,10 +13,14 @@ user_session = dict()
class ChatGPTModel(Model):
def __init__(self):
openai.api_key = model_conf(const.OPEN_AI).get('api_key')
api_base = model_conf(const.OPEN_AI).get('api_base')
if api_base:
openai.api_base = api_base
proxy = model_conf(const.OPEN_AI).get('proxy')
if proxy:
openai.proxy = proxy
log.info("[CHATGPT] api_base={} proxy={}".format(
api_base, proxy))
def reply(self, query, context=None):
# acquire reply content
if not context or not context.get('type') or context.get('type') == 'TEXT':

View File

@@ -13,6 +13,11 @@ user_session = dict()
class OpenAIModel(Model):
def __init__(self):
openai.api_key = model_conf(const.OPEN_AI).get('api_key')
api_base = model_conf(const.OPEN_AI).get('api_base')
if api_base:
openai.api_base = api_base
proxy = model_conf(const.OPEN_AI).get('proxy')
log.info("[OPEN_AI] api_base={}".format(openai.api_base))
def reply(self, query, context=None):

4
requirements.txt Normal file
View File

@@ -0,0 +1,4 @@
PyJWT
flask
itchat-uos==1.5.0.dev0
openai