Skip to content

Commit f3958f0

Browse files
authored
feature: 对接deer-flow (#54)
feature: 对接deer-flow
1 parent dc30b0d commit f3958f0

File tree

710 files changed

+112811
-51
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

710 files changed

+112811
-51
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Deer Flow Docker Image CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
paths:
7+
- 'runtime/deer-flow/**'
8+
- 'scripts/images/deer-flow-backend/**'
9+
- 'scripts/images/deer-flow-frontend/**'
10+
- '.github/workflows/docker-image-deer-flow.yml'
11+
pull_request:
12+
branches: [ "main" ]
13+
paths:
14+
- 'runtime/deer-flow/**'
15+
- 'scripts/images/deer-flow-backend/**'
16+
- 'scripts/images/deer-flow-frontend/**'
17+
- '.github/workflows/docker-image-deer-flow.yml'
18+
workflow_dispatch:
19+
20+
jobs:
21+
build-and-push:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
packages: write
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Login to GitHub Container Registry
31+
if: github.event_name != 'pull_request'
32+
uses: docker/login-action@v3
33+
with:
34+
registry: ghcr.io
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Set Docker Image Tag
39+
id: set-tag
40+
run: |
41+
if [[ $GITHUB_REF == refs/tags/v* ]]; then
42+
TAG=${GITHUB_REF#refs/tags/v}
43+
echo "TAGS=$TAG" >> $GITHUB_OUTPUT
44+
elif [[ $GITHUB_REF == refs/heads/main ]]; then
45+
echo "TAGS=latest" >> $GITHUB_OUTPUT
46+
else
47+
echo "TAGS=temp" >> $GITHUB_OUTPUT
48+
fi
49+
50+
- name: Build Docker Image
51+
run: |
52+
make build-deer-flow VERSION=latest
53+
54+
- name: Tag Docker Image
55+
run: |
56+
LOWERCASE_REPO=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
57+
docker tag deer-flow-backend:latest ghcr.io/$LOWERCASE_REPO/deer-flow-backend:${{ steps.set-tag.outputs.TAGS }}
58+
docker tag deer-flow-frontend:latest ghcr.io/$LOWERCASE_REPO/deer-flow-frontend:${{ steps.set-tag.outputs.TAGS }}
59+
60+
- name: Push Docker Image
61+
if: github.event_name != 'pull_request'
62+
run: |
63+
docker push ghcr.io/$LOWERCASE_REPO/deer-flow-backend:${{ steps.set-tag.outputs.TAGS }}
64+
docker push ghcr.io/$LOWERCASE_REPO/deer-flow-frontend:${{ steps.set-tag.outputs.TAGS }}

Makefile

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ WITH_MINERU ?= false # 默认不构建mineru
44
VERSION ?= latest
55
NAMESPACE ?= datamate
66

7+
ifdef COMSPEC
8+
# Windows 环境
9+
MAKE := "C:/Program Files (x86)/GnuWin32/bin/make"
10+
else
11+
# Linux/Mac 环境
12+
MAKE := make
13+
endif
14+
715
.PHONY: build-%
816
build-%:
917
$(MAKE) $*-docker-build
@@ -76,15 +84,10 @@ label-studio-adapter-docker-build:
7684

7785
.PHONY: deer-flow-docker-build
7886
deer-flow-docker-build:
79-
@if [ -d "../deer-flow/.git" ]; then \
80-
cd ../deer-flow && git pull; \
81-
else \
82-
git clone [email protected]:bytedance/deer-flow.git ../deer-flow; \
83-
fi
84-
sed -i "s/dark/light/g" "../deer-flow/web/src/components/deer-flow/theme-provider-wrapper.tsx"
85-
cp -n deployment/docker/deer-flow/.env.example ../deer-flow/.env
86-
cp -n deployment/docker/deer-flow/conf.yaml.example ../deer-flow/conf.yaml
87-
cd ../deer-flow && docker compose build
87+
cp -n runtime/deer-flow/.env.example runtime/deer-flow/.env
88+
cp -n runtime/deer-flow/conf.yaml.example runtime/deer-flow/conf.yaml
89+
docker build -t deer-flow-backend:$(VERSION) . -f scripts/images/deer-flow-backend/Dockerfile
90+
docker build -t deer-flow-frontend:$(VERSION) . -f scripts/images/deer-flow-frontend/Dockerfile
8891

8992
.PHONY: mineru-docker-build
9093
mineru-docker-build:
@@ -131,16 +134,19 @@ mineru-k8s-uninstall:
131134

132135
.PHONY: datamate-docker-install
133136
datamate-docker-install:
134-
cd deployment/docker/datamate && cp -n .env.example .env && docker compose -f docker-compose.yml up -d
137+
cd deployment/docker/datamate && cp .env.example .env && docker compose -f docker-compose.yml up -d
135138

136139
.PHONY: datamate-docker-uninstall
137140
datamate-docker-uninstall:
138141
cd deployment/docker/datamate && docker compose -f docker-compose.yml down -v
139142

140143
.PHONY: deer-flow-docker-install
141144
deer-flow-docker-install:
142-
cd deployment/docker/datamate && cp -n .env.deer-flow.example .env && docker compose -f docker-compose.yml up -d
143-
cd deployment/docker/deer-flow && cp -n .env.example .env && cp -n conf.yaml.example conf.yaml && docker compose -f docker-compose.yml up -d
145+
cd deployment/docker/datamate && cp .env.deer-flow.example .env && docker compose -f docker-compose.yml up -d
146+
cp -n runtime/deer-flow/.env.example runtime/deer-flow/.env
147+
cp -n runtime/deer-flow/conf.yaml.example runtime/deer-flow/conf.yaml
148+
cp runtime/deer-flow/.env deployment/docker/deer-flow/.env && cp runtime/deer-flow/conf.yaml deployment/docker/deer-flow/conf.yaml
149+
cd deployment/docker/deer-flow && docker compose -f docker-compose.yml up -d
144150

145151
.PHONY: deer-flow-docker-uninstall
146152
deer-flow-docker-uninstall:
@@ -158,3 +164,22 @@ datamate-k8s-install: create-namespace
158164
datamate-k8s-uninstall:
159165
helm uninstall datamate -n $(NAMESPACE) --ignore-not-found
160166
kubectl delete configmap datamate-init-sql -n $(NAMESPACE) --ignore-not-found
167+
168+
.PHONY: deer-flow-k8s-install
169+
deer-flow-k8s-install:
170+
helm upgrade datamate deployment/helm/datamate/ -n $(NAMESPACE) --install --set global.deerFlow.enable=true
171+
cp runtime/deer-flow/.env deployment/helm/deer-flow/charts/public/.env
172+
cp runtime/deer-flow/conf.yaml deployment/helm/deer-flow/charts/public/conf.yaml
173+
helm upgrade deer-flow deployment/helm/deer-flow -n $(NAMESPACE) --install
174+
175+
.PHONY: deer-flow-k8s-uninstall
176+
deer-flow-k8s-uninstall:
177+
helm uninstall deer-flow -n $(NAMESPACE) --ignore-not-found
178+
179+
.PHONY: milvus-k8s-install
180+
milvus-k8s-install:
181+
helm upgrade milvus deployment/helm/milvus -n $(NAMESPACE) --install
182+
183+
.PHONY: milvus-k8s-uninstall
184+
milvus-k8s-uninstall:
185+
helm uninstall milvus -n $(NAMESPACE) --ignore-not-found

backend/services/main-application/src/main/resources/application.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,3 @@ datamate:
164164
quality-control:
165165
enabled: ${QC_ENABLED:true}
166166
threshold: ${QC_THRESHOLD:0.8}
167-
168-
# RAG配置
169-
rag:
170-
milvus-host: ${MILVUS_HOST:milvus-standalone}
171-
milvus-port: ${MILVUS_PORT:19530}

backend/services/operator-market-service/src/main/java/com/datamate/operator/application/OperatorService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class OperatorService {
3232

3333
private final FileService fileService;
3434

35-
@Value("${operator.base.path:/operator}")
35+
@Value("${operator.base.path:/operators}")
3636
private String operatorBasePath;
3737

3838
public List<OperatorDto> getOperators(Integer page, Integer size, List<String> categories,

backend/services/rag-indexer-service/src/main/java/com/datamate/rag/indexer/infrastructure/event/RagEtlService.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@
5151
public class RagEtlService {
5252
private static final Semaphore SEMAPHORE = new Semaphore(10);
5353

54-
@Value("${datamate.rag.milvus-host}")
54+
@Value("${datamate.rag.milvus-host:-milvus-standalone}")
5555
private String milvusHost;
56-
@Value("${datamate.rag.milvus-port}")
56+
@Value("${datamate.rag.milvus-port:-19530}")
5757
private int milvusPort;
5858

5959
private final RagFileRepository ragFileRepository;
@@ -122,7 +122,7 @@ private void processRagFile(RagFile ragFile, DataInsertedEvent event) {
122122
// 调用嵌入模型获取嵌入向量
123123
List<Embedding> content = embeddingModel.embedAll(split).content();
124124
// 存储嵌入向量到 Milvus
125-
embeddingStore(embeddingModel, ragFile.getKnowledgeBaseId()).addAll(content, split);
125+
embeddingStore(embeddingModel, event.knowledgeBase().getName()).addAll(content, split);
126126
}
127127

128128
/**
@@ -152,11 +152,11 @@ public DocumentSplitter documentSplitter(ProcessType processType) {
152152
};
153153
}
154154

155-
public EmbeddingStore<TextSegment> embeddingStore(EmbeddingModel embeddingModel, String knowledgeBaseId) {
155+
public EmbeddingStore<TextSegment> embeddingStore(EmbeddingModel embeddingModel, String knowledgeBaseName) {
156156
return MilvusEmbeddingStore.builder()
157157
.host(milvusHost)
158158
.port(milvusPort)
159-
.collectionName("datamate_" + knowledgeBaseId)
159+
.collectionName(knowledgeBaseName)
160160
.dimension(embeddingModel.dimension())
161161
.build();
162162
}

deployment/helm/datamate/charts/backend/values.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,7 @@ imagePullSecrets: []
1919
nameOverride: "datamate-backend"
2020
fullnameOverride: "datamate-backend"
2121

22-
env:
23-
- name: namespace
24-
valueFrom:
25-
fieldRef:
26-
fieldPath: metadata.namespace
27-
- name: SPRING_CONFIG_LOCATION
28-
value: file:/opt/backend/application.yml
22+
env: []
2923

3024
# This section builds out the service account more information can be found here: https://kubernetes.io/docs/concepts/security/service-accounts/
3125
serviceAccount:

deployment/helm/datamate/charts/frontend/templates/configmap.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.global.deerFlow.enable }}
12
apiVersion: v1
23
kind: ConfigMap
34
metadata:
@@ -13,16 +14,72 @@ data:
1314
1415
client_max_body_size 1024M;
1516
17+
add_header Set-Cookie "NEXT_LOCALE=zh";
18+
1619
location /api/ {
1720
proxy_pass http://datamate-backend:8080/api/;
1821
proxy_set_header Host $host;
1922
proxy_set_header X-Real-IP $remote_addr;
2023
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
2124
}
2225
26+
location /chat {
27+
proxy_pass http://deer-flow-frontend:3000/chat;
28+
proxy_set_header Host $host;
29+
proxy_set_header X-Real-IP $remote_addr;
30+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
31+
}
32+
33+
location /_next {
34+
proxy_pass http://deer-flow-frontend:3000/_next;
35+
proxy_set_header Host $host;
36+
proxy_set_header X-Real-IP $remote_addr;
37+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
38+
}
39+
40+
location /deer-flow-backend/ {
41+
proxy_pass http://deer-flow-backend:8000/api/;
42+
proxy_set_header Host $host;
43+
proxy_set_header X-Real-IP $remote_addr;
44+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
45+
}
46+
2347
location / {
48+
if ($query_string ~* "_rsc=pmmii") {
49+
proxy_pass http://deer-flow-frontend:3000;
50+
break;
51+
}
52+
2453
root /opt/frontend;
2554
try_files $uri $uri/ /index.html;
2655
}
2756
}
57+
{{- else }}
58+
apiVersion: v1
59+
kind: ConfigMap
60+
metadata:
61+
name: datamate-nginx-conf
62+
data:
63+
backend.conf: |
64+
server {
65+
listen 80;
66+
server_name 0.0.0.0;
2867
68+
access_log /var/log/datamate/frontend/access.log main;
69+
error_log /var/log/datamate/frontend/error.log notice;
70+
71+
client_max_body_size 1024M;
72+
73+
location /api/ {
74+
proxy_pass http://datamate-backend:8080/api/;
75+
proxy_set_header Host $host;
76+
proxy_set_header X-Real-IP $remote_addr;
77+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
78+
}
79+
80+
location / {
81+
root /opt/frontend;
82+
try_files $uri $uri/ /index.html;
83+
}
84+
}
85+
{{- end }}

deployment/helm/datamate/charts/frontend/templates/deployment.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ spec:
1313
{{- include "frontend.selectorLabels" . | nindent 6 }}
1414
template:
1515
metadata:
16-
{{- with .Values.podAnnotations }}
1716
annotations:
17+
checksum/nginx: {{ include (print .Template.BasePath "/configmap.yaml") . | sha256sum }}
18+
{{- with .Values.podAnnotations }}
1819
{{- toYaml . | nindent 8 }}
19-
{{- end }}
20+
{{- end }}
2021
labels:
2122
{{- include "frontend.labels" . | nindent 8 }}
2223
{{- with .Values.podLabels }}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: deer-flow
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.0.1
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "0.0.1"

0 commit comments

Comments
 (0)