Skip to content

Commit

Permalink
Merge pull request #2 from deepflowio/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
beizhanyong authored Apr 8, 2024
2 parents 3182b6e + bc0b92c commit 1c5aab0
Show file tree
Hide file tree
Showing 57 changed files with 3,534 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[flake8]
# it's not a bug that we aren't using all of hacking, ignore:
# F401: A module has been imported but is not used anywhere in the file
# F812: list comprehension redefines ...
# H101: Use TODO(NAME)
# H202: assertRaises Exception too broad
# H233: Python 3.x incompatible use of print operator
# H301: one import per line
# H306: imports not in alphabetical order (time, os)
# H401: docstring should not start with a space
# H403: multi line docstrings should end on a new line
# H404: multi line docstring should start without a leading new line
# H405: multi line docstring summary not separated with an empty line
# H501: Do not use self.__dict__ for string formatting
#
# E501: line too long (82 > 79 characters)
# E129: visually indented line with same indent as next logical line
# E126: continuation line over-indented for hanging indent
# E711: comparison to None should be ‘if cond is None:’
# E999: SyntaxError: invalid syntax
# W504: line break after binary operator
# W503: line break before binary operator
# W605: invalid escape sequence
max-line-length = 248
ignore = N813,F401,F812,H101,H202,H233,H301,H306,H401,H403,H404,H405,H501,E501,E999,E129,E126,E711,W503,W504,W605,N801,N806
# exclude = web-servcie-base,fauths/tests
128 changes: 128 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches:
- main
- dev
- 'v**'
- 'feature-**'
- latest
tags:
- '*'
workflow_dispatch:
inputs:
ref:
description: "Why trigger?"
required: true
type: string

env:
IMAGE: "deepflowio-stella-agent-ce"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Set Env
run: |
echo "IMAGE_TAG_PREFIX=${{ github.ref_name }}"|sed 's|main|latest|' >> $GITHUB_ENV
echo "IMAGE_TAG=$(git rev-list --count HEAD)" >> $GITHUB_ENV
- name: Setup Pythons
uses: actions/setup-python@v5
with:
python-version: '3.8'

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true

- name: Log In To GitHub Docker Registry
uses: docker/login-action@v2
with:
registry: "ghcr.io"
username: "${{ github.repository_owner }}"
password: "${{ secrets.GITHUB_TOKEN }}"

- name: Log In To Docker Registry
uses: docker/login-action@v2
with:
username: "deepflowce"
password: "${{ secrets.REGISTRY_PASS }}"

- name: Build And Push deepflowio-stella-agent-ce Images
uses: docker/build-push-action@v2
with:
context: .
push: true
file: Dockerfile
platforms: linux/amd64,linux/arm64
tags: |
"ghcr.io/${{ github.repository_owner }}/deepflow-ce/${{ env.IMAGE }}:${{ env.IMAGE_TAG_PREFIX }}-${{ env.IMAGE_TAG }}"
"ghcr.io/${{ github.repository_owner }}/deepflow-ce/${{ env.IMAGE }}:${{ env.IMAGE_TAG_PREFIX }}"
"deepflowce/${{ env.IMAGE }}:${{ env.IMAGE_TAG_PREFIX }}"
- name: Log In To ALIYUN HongKong Docker Registry
uses: docker/login-action@v2
with:
registry: "registry.cn-hongkong.aliyuncs.com"
username: "${{ secrets.REGISTRY_ALIYUN_USER }}"
password: "${{ secrets.REGISTRY_PASS }}"

- name: Build And Push deepflowio-stella-agent-ce Images to ALIYUN HongKong
uses: docker/build-push-action@v2
with:
context: .
push: true
file: Dockerfile
platforms: linux/amd64,linux/arm64
tags: |
"registry.cn-hongkong.aliyuncs.com/deepflow-ce/${{ env.IMAGE }}:${{ env.IMAGE_TAG_PREFIX }}-${{ env.IMAGE_TAG }}"
"registry.cn-hongkong.aliyuncs.com/deepflow-ce/${{ env.IMAGE }}:${{ env.IMAGE_TAG_PREFIX }}"
- name: Log In To ALIYUN Docker Registry
uses: docker/login-action@v2
with:
registry: "registry.cn-beijing.aliyuncs.com"
username: "${{ secrets.REGISTRY_ALIYUN_USER }}"
password: "${{ secrets.REGISTRY_PASS }}"

- name: Build And Push deepflowio-stella-agent-ce Images To ALIYUN BeiJing
uses: docker/build-push-action@v2
with:
context: .
push: true
file: Dockerfile
platforms: linux/amd64,linux/arm64
tags: |
"registry.cn-beijing.aliyuncs.com/deepflow-ce/${{ env.IMAGE }}:${{ env.IMAGE_TAG_PREFIX }}-${{ env.IMAGE_TAG }}"
"registry.cn-beijing.aliyuncs.com/deepflow-ce/${{ env.IMAGE }}:${{ env.IMAGE_TAG_PREFIX }}"
- name: Build tar.gz
run: |
mkdir -p release/stella-agent-ce
mv deploy df-llm-agent etc Dockerfile requirements3.txt stream.html -t release/stella-agent-ce
cd release
tar -zcvf deepflow-gui-grafana.tar.gz ./stella-agent-ce/*
rm -r ./stella-agent-ce
- name: Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: |
./release/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__pycache__
.vscode
55 changes: 55 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# 构建层
FROM python:3.8-slim-buster AS builder
RUN apt-get update && \
apt-get install --no-install-suggests \
--no-install-recommends --yes \
python3-venv \
gcc \
libpython3-dev \
libpq-dev \
default-libmysqlclient-dev \
make \
&& \
python3 -m venv /root/venv && \
/root/venv/bin/pip install --upgrade pip --trusted-host mirrors.aliyun.com --index-url https://mirrors.aliyun.com/pypi/simple

# Base 构建层
FROM builder AS builder-venv-base
RUN /root/venv/bin/pip install cffi --trusted-host mirrors.aliyun.com --index-url https://mirrors.aliyun.com/pypi/simple/

# 自定义构建层
FROM builder-venv-base AS builder-venv-custom
COPY requirements3.txt /root/requirements3.txt
RUN /root/venv/bin/pip install --disable-pip-version-check \
--no-cache-dir \
--trusted-host mirrors.aliyun.com \
--index-url https://mirrors.aliyun.com/pypi/simple/ \
-r /root/requirements3.txt

FROM python:3.8-slim-buster AS runner

WORKDIR /root/df-llm-agent/

RUN apt-get update && apt-get install --no-install-suggests --no-install-recommends --yes gcc libpython3-dev
COPY --from=builder-venv-custom /usr/lib/*-linux-gnu/*.so* /usr/lib/x86_64-linux-gnu/
RUN mkdir /usr/lib/x86_64-linux-gnu/mariadb19
COPY --from=builder-venv-custom /usr/lib/*-linux-gnu/mariadb19/ /usr/lib/x86_64-linux-gnu/mariadb19/
COPY --from=builder-venv-custom /root/venv /root/venv

# Copy code
## 复制代码
COPY ./etc/df-llm-agent.yaml /etc/web/
COPY ./df-llm-agent /root/df-llm-agent/

RUN chmod +x /root/df-llm-agent/py2c.sh

RUN /root/df-llm-agent/py2c.sh

RUN ls -la /root/df-llm-agent

## dockerfile里的db_version 和issu里最大版本的x.x.x.x.sql 一致
ENV DB_VERSION=1.0.0.0

## Run
CMD /root/venv/bin/python3 -u /root/df-llm-agent/app.py

21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# stella-agent-ce
gpt agent

# 运行服务
进入deploy/templates 目录下,执行命令

```
kubectl create -f ./configmap.yaml
kubectl create -f ./deployment.yaml
kubectl create -f ./service.yaml
```

# 本地测试

python3 -m pip install virtualenv

/usr/local/bin/virtualenv --clear ./venv

./venv/bin/pip3 install -r ./requirements3.txt

./venv/bin/python3 ./app.py
26 changes: 26 additions & 0 deletions commit-template
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[feature|bugfix] commit message title

**Phenomenon and reproduction steps**

(Describe the phenomenon and scenario of the bug)

**Root cause and solution**

(Describe the cause of the bug and corresponding solution)

**Impactions**

(Visible changes after this fix)

**Test method**

(Test method to ensure the bug is fixed)

**Affected branch(es)**

* main

**Checklist**

- [ ] Dependencies update required
- [ ] Common bug (similar problem in other repo)
23 changes: 23 additions & 0 deletions deploy/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
7 changes: 7 additions & 0 deletions deploy/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
name: df-llm-agent
description: A Helm chart for Kubernetes

type: application

version: 6.1.6
66 changes: 66 additions & 0 deletions deploy/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# df-llm-agent Config
kind: ConfigMap
apiVersion: v1
metadata:
name: df-llm-agent
namespace: deepflow
data:
df-llm-agent.yaml: |-
daemon: True
api_timeout: 500
sql_show: False
log_file: /var/log/df-llm-agent.log
log_level: info
instance_path: /root/df-llm-agent
redis:
host:
- redis
cluster_enabled: False # True,False
port: 6379
db: 6
password: "password123"
mysql:
user_name: root
user_password: password123
host: mysql
port: 30130
database: deepflow_llm
ai:
enable: False # True,False
platforms:
-
enable: False
platform: "azure"
model: "gpt"
api_type: "azure"
api_key: ""
api_base: ""
api_version: ""
engine_name:
- ""
-
enable: False
platform: "aliyun"
model: "dashscope"
api_key: ""
engine_name:
- "qwen-turbo"
- "qwen-plus"
-
enable: False
platform: "baidu"
model: "qianfan"
api_key: ""
api_secre: ""
engine_name:
- "ERNIE-Bot"
- "ERNIE-Bot-turbo"
-
enable: False
platform: "zhipu"
model: "zhipuai"
api_key: ""
engine_name:
- "chatglm_turbo"
Loading

0 comments on commit 1c5aab0

Please sign in to comment.