Compare commits
24 Commits
895e6ecfbd
...
f1346a604c
| Author | SHA1 | Date |
|---|---|---|
|
|
f1346a604c | |
|
|
ed46e3c435 | |
|
|
26b3567565 | |
|
|
41dd5b11f4 | |
|
|
cf8a624dd0 | |
|
|
aed04af9cd | |
|
|
31e15aeb71 | |
|
|
eb398a4b4d | |
|
|
f94738f7e7 | |
|
|
5046e31b63 | |
|
|
cc0a05eb97 | |
|
|
9d9c65242c | |
|
|
7bbe7093da | |
|
|
4452fb1568 | |
|
|
3a7925fb55 | |
|
|
0721a4e82e | |
|
|
b7d042ff20 | |
|
|
4221c3a012 | |
|
|
618909ea18 | |
|
|
2187057b7b | |
|
|
bb9650aa3a | |
|
|
900cb0c1c7 | |
|
|
72ed9b3717 | |
|
|
a47758213c |
|
|
@ -143,7 +143,7 @@ eino_tools:
|
||||||
# == 通用工具 ==
|
# == 通用工具 ==
|
||||||
# 表格转图片
|
# 表格转图片
|
||||||
excel2pic:
|
excel2pic:
|
||||||
base_url: "http://192.168.6.109:8010/api/v1/convert"
|
base_url: "http://excel2pic:8000/api/v1/convert"
|
||||||
|
|
||||||
dingtalk:
|
dingtalk:
|
||||||
api_key: "dingsbbntrkeiyazcfdg"
|
api_key: "dingsbbntrkeiyazcfdg"
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ eino_tools:
|
||||||
# == 通用工具 ==
|
# == 通用工具 ==
|
||||||
# 表格转图片
|
# 表格转图片
|
||||||
excel2pic:
|
excel2pic:
|
||||||
base_url: "http://192.168.6.109:8010/api/v1/convert"
|
base_url: "http://excel2pic:8000/api/v1/convert"
|
||||||
|
|
||||||
dingtalk:
|
dingtalk:
|
||||||
api_key: "dingsbbntrkeiyazcfdg"
|
api_key: "dingsbbntrkeiyazcfdg"
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#export GOPATH=/root/go
|
#export GOPATH=/root/go
|
||||||
#export GOCACHE=/root/.cache/go-build
|
#export GOCACHE=/root/.cache/go-build
|
||||||
export CONTAINER_NAME=ai_scheduler
|
export CONTAINER_NAME=ai_scheduler
|
||||||
|
export NETWORK_NAME=ai_scheduler_network
|
||||||
#export CGO_ENABLED='0'
|
#export CGO_ENABLED='0'
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -29,10 +30,17 @@ git pull origin "$BRANCH"
|
||||||
docker build -t ${CONTAINER_NAME} .
|
docker build -t ${CONTAINER_NAME} .
|
||||||
docker stop ${CONTAINER_NAME}
|
docker stop ${CONTAINER_NAME}
|
||||||
docker rm -f ${CONTAINER_NAME}
|
docker rm -f ${CONTAINER_NAME}
|
||||||
|
|
||||||
|
# 依赖服务绑定同一网络,以便相互通信
|
||||||
|
docker network create "${NETWORK_NAME}" 2>/dev/null || true
|
||||||
|
docker network connect "${NETWORK_NAME}" excel2pic 2>/dev/null || true
|
||||||
|
docker network connect "${NETWORK_NAME}" WeKnora-app 2>/dev/null || true
|
||||||
|
|
||||||
docker run -itd \
|
docker run -itd \
|
||||||
--name "${CONTAINER_NAME}" \
|
--name "${CONTAINER_NAME}" \
|
||||||
--restart=always \
|
--restart=always \
|
||||||
--add-host=host.docker.internal:host-gateway \
|
--add-host=host.docker.internal:host-gateway \
|
||||||
|
--network="${NETWORK_NAME}" \
|
||||||
-e "OLLAMA_BASE_URL=${OLLAMA_BASE_URL:-http://host.docker.internal:11434}" \
|
-e "OLLAMA_BASE_URL=${OLLAMA_BASE_URL:-http://host.docker.internal:11434}" \
|
||||||
-e "MODE=${MODE}" \
|
-e "MODE=${MODE}" \
|
||||||
-p 8090:8090 \
|
-p 8090:8090 \
|
||||||
|
|
|
||||||
12
go.mod
12
go.mod
|
|
@ -9,6 +9,7 @@ require (
|
||||||
github.com/alibabacloud-go/dingtalk v1.6.96
|
github.com/alibabacloud-go/dingtalk v1.6.96
|
||||||
github.com/alibabacloud-go/tea v1.2.2
|
github.com/alibabacloud-go/tea v1.2.2
|
||||||
github.com/alibabacloud-go/tea-utils/v2 v2.0.6
|
github.com/alibabacloud-go/tea-utils/v2 v2.0.6
|
||||||
|
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible
|
||||||
github.com/cloudwego/eino v0.7.7
|
github.com/cloudwego/eino v0.7.7
|
||||||
github.com/cloudwego/eino-ext/components/model/ollama v0.1.6
|
github.com/cloudwego/eino-ext/components/model/ollama v0.1.6
|
||||||
github.com/cloudwego/eino-ext/components/model/openai v0.1.5
|
github.com/cloudwego/eino-ext/components/model/openai v0.1.5
|
||||||
|
|
@ -25,10 +26,12 @@ require (
|
||||||
github.com/gofiber/websocket/v2 v2.2.1
|
github.com/gofiber/websocket/v2 v2.2.1
|
||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
github.com/google/wire v0.7.0
|
github.com/google/wire v0.7.0
|
||||||
github.com/json-iterator/go v1.1.12
|
|
||||||
github.com/ollama/ollama v0.12.7
|
github.com/ollama/ollama v0.12.7
|
||||||
github.com/redis/go-redis/v9 v9.16.0
|
github.com/redis/go-redis/v9 v9.16.0
|
||||||
|
github.com/robfig/cron/v3 v3.0.1
|
||||||
|
github.com/shopspring/decimal v1.4.0
|
||||||
github.com/spf13/viper v1.17.0
|
github.com/spf13/viper v1.17.0
|
||||||
|
github.com/stretchr/testify v1.11.1
|
||||||
github.com/tmc/langchaingo v0.1.13
|
github.com/tmc/langchaingo v0.1.13
|
||||||
github.com/xuri/excelize/v2 v2.10.0
|
github.com/xuri/excelize/v2 v2.10.0
|
||||||
golang.org/x/sync v0.17.0
|
golang.org/x/sync v0.17.0
|
||||||
|
|
@ -39,14 +42,12 @@ require (
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
dario.cat/mergo v1.0.0 // indirect
|
|
||||||
filippo.io/edwards25519 v1.1.0 // indirect
|
filippo.io/edwards25519 v1.1.0 // indirect
|
||||||
github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.5 // indirect
|
github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.5 // indirect
|
||||||
github.com/alibabacloud-go/debug v1.0.1 // indirect
|
github.com/alibabacloud-go/debug v1.0.1 // indirect
|
||||||
github.com/alibabacloud-go/gateway-dingtalk v1.0.2 // indirect
|
github.com/alibabacloud-go/gateway-dingtalk v1.0.2 // indirect
|
||||||
github.com/alibabacloud-go/openapi-util v0.1.1 // indirect
|
github.com/alibabacloud-go/openapi-util v0.1.1 // indirect
|
||||||
github.com/alibabacloud-go/tea-xml v1.1.3 // indirect
|
github.com/alibabacloud-go/tea-xml v1.1.3 // indirect
|
||||||
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible // indirect
|
|
||||||
github.com/aliyun/credentials-go v1.4.6 // indirect
|
github.com/aliyun/credentials-go v1.4.6 // indirect
|
||||||
github.com/andybalholm/brotli v1.1.0 // indirect
|
github.com/andybalholm/brotli v1.1.0 // indirect
|
||||||
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
||||||
|
|
@ -58,6 +59,7 @@ require (
|
||||||
github.com/clbanning/mxj/v2 v2.5.5 // indirect
|
github.com/clbanning/mxj/v2 v2.5.5 // indirect
|
||||||
github.com/cloudwego/base64x v0.1.6 // indirect
|
github.com/cloudwego/base64x v0.1.6 // indirect
|
||||||
github.com/cloudwego/eino-ext/libs/acl/openai v0.1.2 // indirect
|
github.com/cloudwego/eino-ext/libs/acl/openai v0.1.2 // indirect
|
||||||
|
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||||
github.com/dlclark/regexp2 v1.11.4 // indirect
|
github.com/dlclark/regexp2 v1.11.4 // indirect
|
||||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
|
|
@ -73,6 +75,7 @@ require (
|
||||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
github.com/jinzhu/now v1.1.5 // indirect
|
github.com/jinzhu/now v1.1.5 // indirect
|
||||||
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/klauspost/compress v1.17.9 // indirect
|
github.com/klauspost/compress v1.17.9 // indirect
|
||||||
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
|
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
|
||||||
github.com/leodido/go-urn v1.4.0 // indirect
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
|
|
@ -89,14 +92,13 @@ require (
|
||||||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/pkoukk/tiktoken-go v0.1.6 // indirect
|
github.com/pkoukk/tiktoken-go v0.1.6 // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||||
github.com/richardlehane/mscfb v1.0.4 // indirect
|
github.com/richardlehane/mscfb v1.0.4 // indirect
|
||||||
github.com/richardlehane/msoleps v1.0.4 // indirect
|
github.com/richardlehane/msoleps v1.0.4 // indirect
|
||||||
github.com/rivo/uniseg v0.2.0 // indirect
|
github.com/rivo/uniseg v0.2.0 // indirect
|
||||||
github.com/robfig/cron/v3 v3.0.1 // indirect
|
|
||||||
github.com/sagikazarmark/locafero v0.3.0 // indirect
|
github.com/sagikazarmark/locafero v0.3.0 // indirect
|
||||||
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
||||||
github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee // indirect
|
github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee // indirect
|
||||||
github.com/shopspring/decimal v1.4.0 // indirect
|
|
||||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||||
github.com/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f // indirect
|
github.com/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f // indirect
|
||||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||||
|
|
|
||||||
4
go.sum
4
go.sum
|
|
@ -35,8 +35,6 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
|
||||||
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
|
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
|
||||||
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
||||||
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
|
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
|
||||||
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
|
|
||||||
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
|
|
||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||||
|
|
@ -195,8 +193,6 @@ github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclK
|
||||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||||
github.com/go-kratos/kratos/v2 v2.9.1 h1:EGif6/S/aK/RCR5clIbyhioTNyoSrii3FC118jG40Z0=
|
|
||||||
github.com/go-kratos/kratos/v2 v2.9.1/go.mod h1:a1MQLjMhIh7R0kcJS9SzJYR43BRI7EPzzN0J1Ksu2bA=
|
|
||||||
github.com/go-kratos/kratos/v2 v2.9.2 h1:px8GJQBeLpquDKQWQ9zohEWiLA8n4D/pv7aH3asvUvo=
|
github.com/go-kratos/kratos/v2 v2.9.2 h1:px8GJQBeLpquDKQWQ9zohEWiLA8n4D/pv7aH3asvUvo=
|
||||||
github.com/go-kratos/kratos/v2 v2.9.2/go.mod h1:Jc7jaeYd4RAPjetun2C+oFAOO7HNMHTT/Z4LxpuEDJM=
|
github.com/go-kratos/kratos/v2 v2.9.2/go.mod h1:Jc7jaeYd4RAPjetun2C+oFAOO7HNMHTT/Z4LxpuEDJM=
|
||||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||||
|
|
|
||||||
|
|
@ -253,7 +253,7 @@ func (d *Do) startMessageHandler(
|
||||||
requireData *entitys.RequireData,
|
requireData *entitys.RequireData,
|
||||||
) <-chan struct{} {
|
) <-chan struct{} {
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
var chat []string
|
var chat []entitys.Response
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|
@ -263,10 +263,13 @@ func (d *Do) startMessageHandler(
|
||||||
hisLog = &entitys.ChatHisLog{}
|
hisLog = &entitys.ChatHisLog{}
|
||||||
)
|
)
|
||||||
if len(chat) > 0 {
|
if len(chat) > 0 {
|
||||||
|
// 合并所有回答-转json字符串
|
||||||
|
ans, _ := json.Marshal(chat)
|
||||||
|
|
||||||
AiRes := &model.AiChatHi{
|
AiRes := &model.AiChatHi{
|
||||||
SessionID: requireData.Session,
|
SessionID: requireData.Session,
|
||||||
Ques: requireData.Req.Text,
|
Ques: requireData.Req.Text,
|
||||||
Ans: strings.Join(chat, ""),
|
Ans: string(ans),
|
||||||
Files: requireData.Req.Img,
|
Files: requireData.Req.Img,
|
||||||
TaskID: requireData.Task.TaskID,
|
TaskID: requireData.Task.TaskID,
|
||||||
}
|
}
|
||||||
|
|
@ -281,14 +284,42 @@ func (d *Do) startMessageHandler(
|
||||||
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
streamText := ""
|
||||||
|
streamIndex := ""
|
||||||
for v := range requireData.Ch { // 自动检测通道关闭
|
for v := range requireData.Ch { // 自动检测通道关闭
|
||||||
if err := sendWithTimeout(client, v, 10*time.Second); err != nil {
|
if err := sendWithTimeout(client, v, 10*time.Second); err != nil {
|
||||||
log.Errorf("Send error: %v", err)
|
log.Errorf("Send error: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if v.Type == entitys.ResponseText || v.Type == entitys.ResponseStream || v.Type == entitys.ResponseJson {
|
// 文本+卡片
|
||||||
chat = append(chat, v.Content)
|
if v.Type == entitys.ResponseText || v.Type == entitys.ResponseJson {
|
||||||
|
chat = append(chat, v)
|
||||||
}
|
}
|
||||||
|
// 流式-追加
|
||||||
|
if v.Type == entitys.ResponseStream {
|
||||||
|
streamText += v.Content
|
||||||
|
streamIndex = v.Index
|
||||||
|
}
|
||||||
|
// 流式-阶段结束|对话结束
|
||||||
|
if streamText != "" && v.Type != entitys.ResponseStream {
|
||||||
|
chat = append(chat, entitys.Response{
|
||||||
|
Content: streamText,
|
||||||
|
Type: entitys.ResponseText,
|
||||||
|
Index: streamIndex,
|
||||||
|
})
|
||||||
|
streamText = ""
|
||||||
|
streamIndex = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 流式结束
|
||||||
|
if streamText != "" {
|
||||||
|
chat = append(chat, entitys.Response{
|
||||||
|
Content: streamText,
|
||||||
|
Type: entitys.ResponseText,
|
||||||
|
Index: streamIndex,
|
||||||
|
})
|
||||||
|
streamText = ""
|
||||||
|
streamIndex = ""
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,9 +36,12 @@ func (f *WithSys) CreatePrompt(ctx context.Context, rec *entitys.Recognize) (mes
|
||||||
mes = append(prompt, api.Message{
|
mes = append(prompt, api.Message{
|
||||||
Role: "system", // 系统角色
|
Role: "system", // 系统角色
|
||||||
Content: rec.SystemPrompt, // 系统提示内容
|
Content: rec.SystemPrompt, // 系统提示内容
|
||||||
|
// }, api.Message{ // 助手回复无需
|
||||||
|
// Role: "assistant", // 助手角色
|
||||||
|
// Content: "### 聊天记录:" + pkg.JsonStringIgonErr(rec.ChatHis), // 助手回复内容
|
||||||
}, api.Message{
|
}, api.Message{
|
||||||
Role: "assistant", // 助手角色
|
Role: "assistant", // 助手角色
|
||||||
Content: "### 聊天记录:" + pkg.JsonStringIgonErr(rec.ChatHis), // 助手回复内容
|
Content: "用户历史输入:" + pkg.JsonStringIgonErr(rec.ChatHis), // 用户历史输入
|
||||||
}, api.Message{
|
}, api.Message{
|
||||||
Role: "user", // 用户角色
|
Role: "user", // 用户角色
|
||||||
Content: content.String(), // 用户输入内容
|
Content: content.String(), // 用户输入内容
|
||||||
|
|
@ -63,10 +66,10 @@ func (f *WithSys) getUserContent(ctx context.Context, rec *entitys.Recognize) (c
|
||||||
content.WriteString(rec.UserContent.Tag)
|
content.WriteString(rec.UserContent.Tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(rec.ChatHis.Messages) > 0 {
|
// if len(rec.ChatHis.Messages) > 0 {
|
||||||
content.WriteString("### 引用历史聊天记录:\n")
|
// content.WriteString("### 引用历史聊天记录:\n")
|
||||||
content.WriteString(pkg.JsonStringIgonErr(rec.ChatHis))
|
// content.WriteString(pkg.JsonStringIgonErr(rec.ChatHis))
|
||||||
}
|
// }
|
||||||
|
|
||||||
if hasFile {
|
if hasFile {
|
||||||
content.WriteString("\n")
|
content.WriteString("\n")
|
||||||
|
|
|
||||||
|
|
@ -174,16 +174,17 @@ func (r *AiRouterBiz) buildChatHistory(requireData *entitys.RequireData) entitys
|
||||||
// 用户消息
|
// 用户消息
|
||||||
messages = append(messages, entitys.HisMessage{
|
messages = append(messages, entitys.HisMessage{
|
||||||
Role: constants.RoleUser, // 用户角色
|
Role: constants.RoleUser, // 用户角色
|
||||||
Content: h.Ans, // 用户输入内容
|
Content: h.Ques, // 用户输入内容
|
||||||
Timestamp: h.CreateAt.Format(time.DateTime),
|
Timestamp: h.CreateAt.Format(time.DateTime),
|
||||||
})
|
})
|
||||||
|
|
||||||
// 助手消息
|
// 助手消息 - 助手回复噪音太大且无需,pass
|
||||||
messages = append(messages, entitys.HisMessage{
|
// ansStr := r.ansNoiseReduction(h.Ans) // 助手回复降噪
|
||||||
Role: constants.RoleAssistant, // 助手角色
|
// messages = append(messages, entitys.HisMessage{
|
||||||
Content: h.Ques, // 助手回复内容
|
// Role: constants.RoleAssistant, // 助手角色
|
||||||
Timestamp: h.CreateAt.Format(time.DateTime),
|
// Content: ansStr, // 助手回复内容
|
||||||
})
|
// Timestamp: h.CreateAt.Format(time.DateTime),
|
||||||
|
// })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构建聊天历史上下文
|
// 构建聊天历史上下文
|
||||||
|
|
@ -196,3 +197,20 @@ func (r *AiRouterBiz) buildChatHistory(requireData *entitys.RequireData) entitys
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ansNoiseReduction 助手回复降噪
|
||||||
|
// func (r *AiRouterBiz) ansNoiseReduction(ansJson string) string {
|
||||||
|
// // 使用anw统一类型解析
|
||||||
|
// ansStruct := make([]*entitys.Response, 0)
|
||||||
|
// err := json.Unmarshal([]byte(ansJson), &ansStruct)
|
||||||
|
// if err != nil {
|
||||||
|
// log.Errorf("解析助手回复失败: %s", err.Error())
|
||||||
|
// return ansJson
|
||||||
|
// }
|
||||||
|
// var ansStr string
|
||||||
|
// for _, item := range ansStruct {
|
||||||
|
// ansStr += item.Content
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return ansStr
|
||||||
|
// }
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ type AiChatHi struct {
|
||||||
Useful int32 `gorm:"column:useful;not null;comment:0不评价,1有用,其他为无用" json:"useful"` // 0不评价,1有用,其他为无用
|
Useful int32 `gorm:"column:useful;not null;comment:0不评价,1有用,其他为无用" json:"useful"` // 0不评价,1有用,其他为无用
|
||||||
CreateAt time.Time `gorm:"column:create_at;default:CURRENT_TIMESTAMP" json:"create_at"`
|
CreateAt time.Time `gorm:"column:create_at;default:CURRENT_TIMESTAMP" json:"create_at"`
|
||||||
UpdatedAt time.Time `gorm:"column:updated_at;default:CURRENT_TIMESTAMP" json:"updated_at"`
|
UpdatedAt time.Time `gorm:"column:updated_at;default:CURRENT_TIMESTAMP" json:"updated_at"`
|
||||||
TaskID int32 `gorm:"column:task_id;not null" json:"task_id"` // 任务ID
|
TaskID int32 `gorm:"column:task_id;comment:任务id" json:"task_id"` // 任务id
|
||||||
Content string `gorm:"column:content" json:"content"` // 前端回传数据
|
Content string `gorm:"column:content;comment:前端回传数据" json:"content"` // 前端回传数据
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableName AiChatHi's table name
|
// TableName AiChatHi's table name
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ func (c *Client) ToolSelect(ctx context.Context, messages []api.Message, tools [
|
||||||
res = resp
|
res = resp
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,14 @@ var resellerBlackList = []string{
|
||||||
"通钱-2025年12月",
|
"通钱-2025年12月",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var resellerBlackListProduct = []string{
|
||||||
|
"悦跑",
|
||||||
|
"电商-独立",
|
||||||
|
"蓝星严选连续包月",
|
||||||
|
"通钱-2025年12月",
|
||||||
|
"彦浩同行",
|
||||||
|
}
|
||||||
|
|
||||||
type BbxtTools struct {
|
type BbxtTools struct {
|
||||||
cacheDir string
|
cacheDir string
|
||||||
excelTempDir string
|
excelTempDir string
|
||||||
|
|
@ -149,14 +157,14 @@ func (b *BbxtTools) StatisOursProductLossSum(now time.Time) (report []*ReportRes
|
||||||
)
|
)
|
||||||
// 构建分组
|
// 构建分组
|
||||||
for _, v := range resellers {
|
for _, v := range resellers {
|
||||||
if v.Total <= -100 && !slices.Contains(resellerBlackList, v.ResellerName) {
|
if v.Total <= -100 && !slices.Contains(resellerBlackListProduct, v.ResellerName) {
|
||||||
total = append(total, []string{
|
total = append(total, []string{
|
||||||
fmt.Sprintf("%s", v.ResellerName),
|
fmt.Sprintf("%s", v.ResellerName),
|
||||||
fmt.Sprintf("%.2f", v.Total),
|
fmt.Sprintf("%.2f", v.Total),
|
||||||
})
|
})
|
||||||
totalSum += v.Total
|
totalSum += v.Total
|
||||||
}
|
}
|
||||||
if v.Total <= -500 && !slices.Contains(resellerBlackList, v.ResellerName) {
|
if v.Total <= -500 && !slices.Contains(resellerBlackListProduct, v.ResellerName) {
|
||||||
gt = append(gt, v)
|
gt = append(gt, v)
|
||||||
totalSum500 += v.Total
|
totalSum500 += v.Total
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ type Uploader struct {
|
||||||
ossClient *utils_oss.Client
|
ossClient *utils_oss.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
const RequestUrl = "http://192.168.6.109:8010/api/v1/convert"
|
const RequestUrl = "http://excel2pic:8000/api/v1/convert"
|
||||||
|
|
||||||
func NewUploader(oss *utils_oss.Client) *Uploader {
|
func NewUploader(oss *utils_oss.Client) *Uploader {
|
||||||
return &Uploader{
|
return &Uploader{
|
||||||
|
|
@ -63,7 +63,7 @@ func (u *Uploader) Run(report *ReportRes) (err error) {
|
||||||
|
|
||||||
// excel2picPy 将excel转换为图片python
|
// excel2picPy 将excel转换为图片python
|
||||||
// python 接口如下:
|
// python 接口如下:
|
||||||
// curl --location --request POST 'http://192.168.6.109:8010/api/v1/convert' \
|
// curl --location --request POST 'http://excel2pic:8000/api/v1/convert' \
|
||||||
// --header 'Content-Type: multipart/form-data; boundary=--------------------------952147881043913664015069' \
|
// --header 'Content-Type: multipart/form-data; boundary=--------------------------952147881043913664015069' \
|
||||||
// --form 'file=@"C:\\Users\\Administrator\\Downloads\\销售同比分析2025-12-29 0-12点.xlsx"' \
|
// --form 'file=@"C:\\Users\\Administrator\\Downloads\\销售同比分析2025-12-29 0-12点.xlsx"' \
|
||||||
// --form 'sheet_name="销售同比分析"'
|
// --form 'sheet_name="销售同比分析"'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue