Commit a2c8fcf8 authored by Wade's avatar Wade

add docker compose

parent 7440fa13
# Stage 1: Build stage
FROM golang:1.24-alpine AS build
WORKDIR /app
# Install dependencies for swag CLI (git is required)
RUN apk add --no-cache git
# Install swag CLI for Swagger generation
# RUN go install github.com/swaggo/swag/cmd/swag@latest
# Copy and download dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy the source code
COPY . .
# Generate Swagger docs
# RUN swag init -g cmd/agentchat/main.go -o docs
# Build the Go application
RUN CGO_ENABLED=0 GOOS=linux go build -o myapp .
# Stage 2: Final stage
FROM alpine:edge
WORKDIR /app
# Copy the binary from the build stage
COPY --from=build /app/myapp .
# Copy swagger.yaml (optional, since it's embedded in the binary)
COPY --from=build /app/docs/swagger.yaml /app/docs/swagger.yaml
# Install curl and CA certificates
RUN apk update && apk add --no-cache curl ca-certificates
# Expose port
EXPOSE 8000
# Set the entrypoint command
ENTRYPOINT ["/app/myapp"]
\ No newline at end of file
This diff is collapsed.
version: '3.9'
services:
agentchat:
container_name: "agentchat"
build:
context: . # Build context is the current directory
dockerfile: Dockerfile # Dockerfile for agentchat
volumes:
- /var/log:/var/log
environment:
- GEMINI_API_KEY=${GEMINI_API_KEY} # Reference variable from .env
ports:
- "8000:8000"
entrypoint: /app/myapp
docker-host:
image: qoomon/docker-host
cap_add: ['NET_ADMIN', 'NET_RAW']
mem_limit: 8M
restart: on-failure
# etcd:
# container_name: milvus-etcd
# image: quay.io/coreos/etcd:v3.5.18
# environment:
# - ETCD_AUTO_COMPACTION_MODE=revision
# - ETCD_AUTO_COMPACTION_RETENTION=1000
# - ETCD_QUOTA_BACKEND_BYTES=4294967296
# - ETCD_SNAPSHOT_COUNT=50000
# volumes:
# - ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/etcd:/etcd
# command: etcd -advertise-client-urls=http://etcd:2379 -listen-client-urls http://0.0.0.0:2379 --data-dir /etcd
# healthcheck:
# test: ["CMD", "etcdctl", "endpoint", "health"]
# interval: 30s
# timeout: 20s
# retries: 3
# minio:
# container_name: milvus-minio
# image: minio/minio:RELEASE.2023-03-20T20-16-18Z
# environment:
# MINIO_ACCESS_KEY: minioadmin
# MINIO_SECRET_KEY: minioadmin
# ports:
# - "9001:9001"
# - "9000:9000"
# volumes:
# - ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/minio:/minio_data
# command: minio server /minio_data --console-address ":9001"
# healthcheck:
# test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
# interval: 30s
# timeout: 20s
# retries: 3
# standalone:
# container_name: milvus-standalone
# image: milvusdb/milvus:v2.5.10
# command: ["milvus", "run", "standalone"]
# security_opt:
# - seccomp:unconfined
# environment:
# ETCD_ENDPOINTS: etcd:2379
# MINIO_ADDRESS: minio:9000
# volumes:
# - ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/milvus:/var/lib/milvus
# healthcheck:
# test: ["CMD", "curl", "-f", "http://localhost:9091/healthz"]
# interval: 30s
# start_period: 90s
# timeout: 20s
# retries: 3
# ports:
# - "19530:19530"
# - "9091:9091"
# depends_on:
# - "etcd"
# - "minio"
# db:
# image: mysql/mysql-server
# environment:
# MYSQL_USER: 'user'
# MYSQL_PASSWORD: 'password'
# MYSQL_ROOT_PASSWORD: 'aa123456'
# ports:
# - 3306:3306
# volumes:
# - dbgpt-myql-db:/var/lib/mysql
# - ./docker/examples/my.cnf:/etc/my.cnf
# - ./docker/examples/sqls:/docker-entrypoint-initdb.d
# - ./assets/schema/dbgpt.sql:/docker-entrypoint-initdb.d/dbgpt.sql
# restart: unless-stopped
# webserver:
# image: eosphorosai/dbgpt-openai:latest
# command: dbgpt start webserver --config /app/configs/dbgpt-graphrag.toml
# environment:
# - SILICONFLOW_API_KEY=${SILICONFLOW_API_KEY}
# - MYSQL_PASSWORD=aa123456
# - MYSQL_HOST=db
# - MYSQL_PORT=3306
# - MYSQL_DATABASE=dbgpt
# - MYSQL_USER=root
# - OPENAI_API_KEY=sk-UIpD9DohtE0Ok4wtFdC21668Dc3241629e8aA05d5dAeFdA1
# volumes:
# - ./configs:/app/configs
# - /data:/data
# # May be you can mount your models to container
# - /data/models:/app/models
# - dbgpt-data:/app/pilot/data
# - dbgpt-message:/app/pilot/message
# depends_on:
# - db
# - tugraph
# ports:
# - 5670:5670/tcp
# # webserver may be failed, it must wait all sqls in /docker-entrypoint-initdb.d execute finish.
# restart: unless-stopped
# networks:
# - dbgptnet
# ipc: host
# tugraph:
# image: tugraph/tugraph-runtime-centos7:4.5.1
# command: lgraph_server -d run --enable_plugin true
# ports:
# - 7070:7070
# - 7687:7687
# - 9090:9090
# container_name: tugraph_demo
# restart: unless-stopped
# volumes:
# dbgpt-myql-db:
# dbgpt-data:
# dbgpt-message:
# dbgpt-alembic-versions:
...@@ -74,6 +74,8 @@ require ( ...@@ -74,6 +74,8 @@ require (
github.com/swaggo/files v1.0.1 // indirect github.com/swaggo/files v1.0.1 // indirect
github.com/swaggo/http-swagger v1.3.4 // indirect github.com/swaggo/http-swagger v1.3.4 // indirect
github.com/swaggo/swag v1.16.4 // indirect github.com/swaggo/swag v1.16.4 // indirect
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1180 // indirect
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/lkeap v1.0.1179 // indirect
github.com/test-go/testify v1.1.4 // indirect github.com/test-go/testify v1.1.4 // indirect
github.com/tidwall/gjson v1.18.0 // indirect github.com/tidwall/gjson v1.18.0 // indirect
github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/match v1.1.1 // indirect
...@@ -105,4 +107,4 @@ require ( ...@@ -105,4 +107,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )
replace github.com/firebase/genkit/go => ../genkit/go replace github.com/firebase/genkit/go => github.com/wade-liwei/genkit-web/go v0.0.0-20250605093206-aab2d64e9700
\ No newline at end of file
...@@ -318,6 +318,11 @@ github.com/swaggo/http-swagger v1.3.4 h1:q7t/XLx0n15H1Q9/tk3Y9L4n210XzJF5WtnDX64 ...@@ -318,6 +318,11 @@ github.com/swaggo/http-swagger v1.3.4 h1:q7t/XLx0n15H1Q9/tk3Y9L4n210XzJF5WtnDX64
github.com/swaggo/http-swagger v1.3.4/go.mod h1:9dAh0unqMBAlbp1uE2Uc2mQTxNMU/ha4UbucIg1MFkQ= github.com/swaggo/http-swagger v1.3.4/go.mod h1:9dAh0unqMBAlbp1uE2Uc2mQTxNMU/ha4UbucIg1MFkQ=
github.com/swaggo/swag v1.16.4 h1:clWJtd9LStiG3VeijiCfOVODP6VpHtKdQy9ELFG3s1A= github.com/swaggo/swag v1.16.4 h1:clWJtd9LStiG3VeijiCfOVODP6VpHtKdQy9ELFG3s1A=
github.com/swaggo/swag v1.16.4/go.mod h1:VBsHJRsDvfYvqoiMKnsdwhNV9LEMHgEDZcyVYX0sxPg= github.com/swaggo/swag v1.16.4/go.mod h1:VBsHJRsDvfYvqoiMKnsdwhNV9LEMHgEDZcyVYX0sxPg=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1179/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1180 h1:k1q0xmirtk285MAjO79xcgYMNj5KBbNGbdiN3is8p2E=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1180/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/lkeap v1.0.1179 h1:JiFl6PpxQCHStBvlEtkr0hZKwAT8i/OX3C0hyqsIeEQ=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/lkeap v1.0.1179/go.mod h1:tmxc9DURqZNGJIbv6aWci0FxwkqrSevwkmStsFeX5LE=
github.com/test-go/testify v1.1.4 h1:Tf9lntrKUMHiXQ07qBScBTSA0dhYQlu83hswqelv1iE= github.com/test-go/testify v1.1.4 h1:Tf9lntrKUMHiXQ07qBScBTSA0dhYQlu83hswqelv1iE=
github.com/test-go/testify v1.1.4/go.mod h1:rH7cfJo/47vWGdi4GPj16x3/t1xGOj2YxzmNQzk2ghU= github.com/test-go/testify v1.1.4/go.mod h1:rH7cfJo/47vWGdi4GPj16x3/t1xGOj2YxzmNQzk2ghU=
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
...@@ -337,6 +342,8 @@ github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBn ...@@ -337,6 +342,8 @@ github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBn
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
github.com/wade-liwei/genkit-web/go v0.0.0-20250605093206-aab2d64e9700 h1:eLxnJ2ApSEvLfsaeW7jHVzAJ9Px/Nu4DLuw0zzwWtOU=
github.com/wade-liwei/genkit-web/go v0.0.0-20250605093206-aab2d64e9700/go.mod h1:+YRtLa+m5EQLU6B0ukcrhaeukNeJx1EKYvTOFqdp9NI=
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc= github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw= github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
......
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"strings" "strings"
"time"
"github.com/firebase/genkit/go/ai" "github.com/firebase/genkit/go/ai"
"github.com/firebase/genkit/go/genkit" "github.com/firebase/genkit/go/genkit"
...@@ -307,6 +308,9 @@ func main() { ...@@ -307,6 +308,9 @@ func main() {
log.Info().Msgf("promptInput.Context: %s", promptInput.Context) log.Info().Msgf("promptInput.Context: %s", promptInput.Context)
} }
begin := time.Now()
graphResponse, err := ai.Retrieve(ctx, graphRetriever, ai.WithDocs(dRequest)) graphResponse, err := ai.Retrieve(ctx, graphRetriever, ai.WithDocs(dRequest))
if err != nil { if err != nil {
log.Error().Msgf("graph Retrieve err.Error() %s", err.Error()) log.Error().Msgf("graph Retrieve err.Error() %s", err.Error())
...@@ -320,6 +324,11 @@ func main() { ...@@ -320,6 +324,11 @@ func main() {
log.Info().Msgf("promptInput.Graph : %s", promptInput.Graph) log.Info().Msgf("promptInput.Graph : %s", promptInput.Graph)
} }
fmt.Println("graph time",time.Since(begin).Seconds())
resp, err := simpleQaPrompt.Execute(ctx, ai.WithInput(promptInput)) resp, err := simpleQaPrompt.Execute(ctx, ai.WithInput(promptInput))
if err != nil { if err != nil {
......
ubuntu@ip-172-26-8-199:~/DB-GPT$ cat docker-compose.yml
# To run current docker compose file, you should prepare the siliconflow api key in your environment. # To run current docker compose file, you should prepare the siliconflow api key in your environment.
# SILICONFLOW_API_KEY=${SILICONFLOW_API_KEY} docker compose up -d # SILICONFLOW_API_KEY=${SILICONFLOW_API_KEY} docker compose up -d
services: services:
...@@ -68,5 +66,3 @@ networks: ...@@ -68,5 +66,3 @@ networks:
driver: bridge driver: bridge
name: dbgptnet name: dbgptnet
ubuntu@ip-172-26-8-199:~/DB-GPT$
package main
import (
"fmt"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
lkeap "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/lkeap/v20240522"
)
func main() {
// 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
// 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性
// 以下代码示例仅供参考,建议采用更安全的方式来使用密钥
// 请参见:https://cloud.tencent.com/document/product/1278/85305
// 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
//os.Setenv("TENCENTCLOUD_SECRET_ID", "AKID64oLfmfLtESUJ6i8LPSM4gCVbiniQuBF")
//os.Setenv("TENCENTCLOUD_SECRET_KEY", "rX2JMBnBMJ2YqulOo37xa5OUMSN4Xnpd")
credential := common.NewCredential(
"AKID64oLfmfLtESUJ6i8LPSM4gCVbiniQuBF",
"rX2JMBnBMJ2YqulOo37xa5OUMSN4Xnpd",
)
// 使用临时密钥示例
// credential := common.NewTokenCredential("SecretId", "SecretKey", "Token")
// 实例化一个client选项,可选的,没有特殊需求可以跳过
cpf := profile.NewClientProfile()
cpf.HttpProfile.Endpoint = "lkeap.tencentcloudapi.com"
// 实例化要请求产品的client对象,clientProfile是可选的
client, _ := lkeap.NewClient(credential, "ap-guangzhou", cpf)
// 实例化一个请求对象,每个接口都会对应一个request对象
request := lkeap.NewQueryRewriteRequest()
request.Model = common.StringPtr("*")
// 返回的resp是一个QueryRewriteResponse的实例,与请求对象对应
response, err := client.QueryRewrite(request)
if _, ok := err.(*errors.TencentCloudSDKError); ok {
fmt.Printf("An API error has returned: %s", err)
return
}
if err != nil {
panic(err)
}
// 输出json格式的字符串回包
fmt.Printf("%s", response.ToJsonString())
}
\ No newline at end of file
This diff is collapsed.
package knowledge
import (
"fmt"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
lkeap "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/lkeap/v20240522"
)
func knowldge() {
// 实例化一个认证对象,入参需要传入腾讯云账户 SecretId SecretKey,此处还需注意密钥对的保密
// 代码泄露可能会导致 SecretId SecretKey 泄露,并威胁账号下所有资源的安全性
// 以下代码示例仅供参考,建议采用更安全的方式来使用密钥
// 请参见:https://cloud.tencent.com/document/product/1278/85305
// 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
credential := common.NewCredential(
"SecretId",
"SecretKey",
)
// 使用临时密钥示例
// credential := common.NewTokenCredential("SecretId", "SecretKey", "Token")
// 实例化一个client选项,可选的,没有特殊需求可以跳过
cpf := profile.NewClientProfile()
cpf.HttpProfile.Endpoint = "lkeap.tencentcloudapi.com"
// 实例化要请求产品的client对象,clientProfile是可选的
client, _ := lkeap.NewClient(credential, "", cpf)
// 实例化一个请求对象,每个接口都会对应一个request对象
request := lkeap.NewQueryRewriteRequest()
// 返回的resp是一个QueryRewriteResponse的实例,与请求对象对应
response, err := client.QueryRewrite(request)
if _, ok := err.(*errors.TencentCloudSDKError); ok {
fmt.Printf("An API error has returned: %s", err)
return
}
if err != nil {
panic(err)
}
// 输出json格式的字符串回包
fmt.Printf("%s", response.ToJsonString())
}
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment