Compare commits
No commits in common. "f1346a604c7314dd4d5cb23b4f02e91dfcf3fc6a" and "895e6ecfbd6ca3d1bca6d871953b85dc5a23670f" have entirely different histories.
f1346a604c
...
895e6ecfbd
|
|
@ -143,7 +143,7 @@ eino_tools:
|
|||
# == 通用工具 ==
|
||||
# 表格转图片
|
||||
excel2pic:
|
||||
base_url: "http://excel2pic:8000/api/v1/convert"
|
||||
base_url: "http://192.168.6.109:8010/api/v1/convert"
|
||||
|
||||
dingtalk:
|
||||
api_key: "dingsbbntrkeiyazcfdg"
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ eino_tools:
|
|||
# == 通用工具 ==
|
||||
# 表格转图片
|
||||
excel2pic:
|
||||
base_url: "http://excel2pic:8000/api/v1/convert"
|
||||
base_url: "http://192.168.6.109:8010/api/v1/convert"
|
||||
|
||||
dingtalk:
|
||||
api_key: "dingsbbntrkeiyazcfdg"
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
#export GOPATH=/root/go
|
||||
#export GOCACHE=/root/.cache/go-build
|
||||
export CONTAINER_NAME=ai_scheduler
|
||||
export NETWORK_NAME=ai_scheduler_network
|
||||
#export CGO_ENABLED='0'
|
||||
|
||||
|
||||
|
|
@ -30,17 +29,10 @@ git pull origin "$BRANCH"
|
|||
docker build -t ${CONTAINER_NAME} .
|
||||
docker stop ${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 \
|
||||
--name "${CONTAINER_NAME}" \
|
||||
--restart=always \
|
||||
--add-host=host.docker.internal:host-gateway \
|
||||
--network="${NETWORK_NAME}" \
|
||||
-e "OLLAMA_BASE_URL=${OLLAMA_BASE_URL:-http://host.docker.internal:11434}" \
|
||||
-e "MODE=${MODE}" \
|
||||
-p 8090:8090 \
|
||||
|
|
|
|||
12
go.mod
12
go.mod
|
|
@ -9,7 +9,6 @@ require (
|
|||
github.com/alibabacloud-go/dingtalk v1.6.96
|
||||
github.com/alibabacloud-go/tea v1.2.2
|
||||
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-ext/components/model/ollama v0.1.6
|
||||
github.com/cloudwego/eino-ext/components/model/openai v0.1.5
|
||||
|
|
@ -26,12 +25,10 @@ require (
|
|||
github.com/gofiber/websocket/v2 v2.2.1
|
||||
github.com/google/uuid v1.6.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/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/stretchr/testify v1.11.1
|
||||
github.com/tmc/langchaingo v0.1.13
|
||||
github.com/xuri/excelize/v2 v2.10.0
|
||||
golang.org/x/sync v0.17.0
|
||||
|
|
@ -42,12 +39,14 @@ require (
|
|||
)
|
||||
|
||||
require (
|
||||
dario.cat/mergo v1.0.0 // indirect
|
||||
filippo.io/edwards25519 v1.1.0 // 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/gateway-dingtalk v1.0.2 // indirect
|
||||
github.com/alibabacloud-go/openapi-util v0.1.1 // 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/andybalholm/brotli v1.1.0 // indirect
|
||||
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
||||
|
|
@ -59,7 +58,6 @@ require (
|
|||
github.com/clbanning/mxj/v2 v2.5.5 // indirect
|
||||
github.com/cloudwego/base64x v0.1.6 // 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/dlclark/regexp2 v1.11.4 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
|
|
@ -75,7 +73,6 @@ require (
|
|||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // 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/cpuid/v2 v2.2.9 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
|
|
@ -92,13 +89,14 @@ require (
|
|||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||
github.com/pkg/errors v0.9.1 // 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/msoleps v1.0.4 // 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/slog-shim v0.1.0 // 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/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f // indirect
|
||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||
|
|
|
|||
4
go.sum
4
go.sum
|
|
@ -35,6 +35,8 @@ 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.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
||||
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=
|
||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||
|
|
@ -193,6 +195,8 @@ 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/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-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/go.mod h1:Jc7jaeYd4RAPjetun2C+oFAOO7HNMHTT/Z4LxpuEDJM=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ func (d *Do) startMessageHandler(
|
|||
requireData *entitys.RequireData,
|
||||
) <-chan struct{} {
|
||||
done := make(chan struct{})
|
||||
var chat []entitys.Response
|
||||
var chat []string
|
||||
|
||||
go func() {
|
||||
defer func() {
|
||||
|
|
@ -263,13 +263,10 @@ func (d *Do) startMessageHandler(
|
|||
hisLog = &entitys.ChatHisLog{}
|
||||
)
|
||||
if len(chat) > 0 {
|
||||
// 合并所有回答-转json字符串
|
||||
ans, _ := json.Marshal(chat)
|
||||
|
||||
AiRes := &model.AiChatHi{
|
||||
SessionID: requireData.Session,
|
||||
Ques: requireData.Req.Text,
|
||||
Ans: string(ans),
|
||||
Ans: strings.Join(chat, ""),
|
||||
Files: requireData.Req.Img,
|
||||
TaskID: requireData.Task.TaskID,
|
||||
}
|
||||
|
|
@ -284,42 +281,14 @@ func (d *Do) startMessageHandler(
|
|||
|
||||
}()
|
||||
|
||||
streamText := ""
|
||||
streamIndex := ""
|
||||
for v := range requireData.Ch { // 自动检测通道关闭
|
||||
if err := sendWithTimeout(client, v, 10*time.Second); err != nil {
|
||||
log.Errorf("Send error: %v", err)
|
||||
return
|
||||
}
|
||||
// 文本+卡片
|
||||
if v.Type == entitys.ResponseText || v.Type == entitys.ResponseJson {
|
||||
chat = append(chat, v)
|
||||
if v.Type == entitys.ResponseText || v.Type == entitys.ResponseStream || v.Type == entitys.ResponseJson {
|
||||
chat = append(chat, v.Content)
|
||||
}
|
||||
// 流式-追加
|
||||
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,12 +36,9 @@ func (f *WithSys) CreatePrompt(ctx context.Context, rec *entitys.Recognize) (mes
|
|||
mes = append(prompt, api.Message{
|
||||
Role: "system", // 系统角色
|
||||
Content: rec.SystemPrompt, // 系统提示内容
|
||||
// }, api.Message{ // 助手回复无需
|
||||
// Role: "assistant", // 助手角色
|
||||
// Content: "### 聊天记录:" + pkg.JsonStringIgonErr(rec.ChatHis), // 助手回复内容
|
||||
}, api.Message{
|
||||
Role: "assistant", // 助手角色
|
||||
Content: "用户历史输入:" + pkg.JsonStringIgonErr(rec.ChatHis), // 用户历史输入
|
||||
Role: "assistant", // 助手角色
|
||||
Content: "### 聊天记录:" + pkg.JsonStringIgonErr(rec.ChatHis), // 助手回复内容
|
||||
}, api.Message{
|
||||
Role: "user", // 用户角色
|
||||
Content: content.String(), // 用户输入内容
|
||||
|
|
@ -66,10 +63,10 @@ func (f *WithSys) getUserContent(ctx context.Context, rec *entitys.Recognize) (c
|
|||
content.WriteString(rec.UserContent.Tag)
|
||||
}
|
||||
|
||||
// if len(rec.ChatHis.Messages) > 0 {
|
||||
// content.WriteString("### 引用历史聊天记录:\n")
|
||||
// content.WriteString(pkg.JsonStringIgonErr(rec.ChatHis))
|
||||
// }
|
||||
if len(rec.ChatHis.Messages) > 0 {
|
||||
content.WriteString("### 引用历史聊天记录:\n")
|
||||
content.WriteString(pkg.JsonStringIgonErr(rec.ChatHis))
|
||||
}
|
||||
|
||||
if hasFile {
|
||||
content.WriteString("\n")
|
||||
|
|
|
|||
|
|
@ -174,17 +174,16 @@ func (r *AiRouterBiz) buildChatHistory(requireData *entitys.RequireData) entitys
|
|||
// 用户消息
|
||||
messages = append(messages, entitys.HisMessage{
|
||||
Role: constants.RoleUser, // 用户角色
|
||||
Content: h.Ques, // 用户输入内容
|
||||
Content: h.Ans, // 用户输入内容
|
||||
Timestamp: h.CreateAt.Format(time.DateTime),
|
||||
})
|
||||
|
||||
// 助手消息 - 助手回复噪音太大且无需,pass
|
||||
// ansStr := r.ansNoiseReduction(h.Ans) // 助手回复降噪
|
||||
// messages = append(messages, entitys.HisMessage{
|
||||
// Role: constants.RoleAssistant, // 助手角色
|
||||
// Content: ansStr, // 助手回复内容
|
||||
// Timestamp: h.CreateAt.Format(time.DateTime),
|
||||
// })
|
||||
// 助手消息
|
||||
messages = append(messages, entitys.HisMessage{
|
||||
Role: constants.RoleAssistant, // 助手角色
|
||||
Content: h.Ques, // 助手回复内容
|
||||
Timestamp: h.CreateAt.Format(time.DateTime),
|
||||
})
|
||||
}
|
||||
|
||||
// 构建聊天历史上下文
|
||||
|
|
@ -197,20 +196,3 @@ 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有用,其他为无用
|
||||
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"`
|
||||
TaskID int32 `gorm:"column:task_id;comment:任务id" json:"task_id"` // 任务id
|
||||
Content string `gorm:"column:content;comment:前端回传数据" json:"content"` // 前端回传数据
|
||||
TaskID int32 `gorm:"column:task_id;not null" json:"task_id"` // 任务ID
|
||||
Content string `gorm:"column:content" json:"content"` // 前端回传数据
|
||||
}
|
||||
|
||||
// TableName AiChatHi's table name
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ func (c *Client) ToolSelect(ctx context.Context, messages []api.Message, tools [
|
|||
res = resp
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,14 +29,6 @@ var resellerBlackList = []string{
|
|||
"通钱-2025年12月",
|
||||
}
|
||||
|
||||
var resellerBlackListProduct = []string{
|
||||
"悦跑",
|
||||
"电商-独立",
|
||||
"蓝星严选连续包月",
|
||||
"通钱-2025年12月",
|
||||
"彦浩同行",
|
||||
}
|
||||
|
||||
type BbxtTools struct {
|
||||
cacheDir string
|
||||
excelTempDir string
|
||||
|
|
@ -157,14 +149,14 @@ func (b *BbxtTools) StatisOursProductLossSum(now time.Time) (report []*ReportRes
|
|||
)
|
||||
// 构建分组
|
||||
for _, v := range resellers {
|
||||
if v.Total <= -100 && !slices.Contains(resellerBlackListProduct, v.ResellerName) {
|
||||
if v.Total <= -100 && !slices.Contains(resellerBlackList, v.ResellerName) {
|
||||
total = append(total, []string{
|
||||
fmt.Sprintf("%s", v.ResellerName),
|
||||
fmt.Sprintf("%.2f", v.Total),
|
||||
})
|
||||
totalSum += v.Total
|
||||
}
|
||||
if v.Total <= -500 && !slices.Contains(resellerBlackListProduct, v.ResellerName) {
|
||||
if v.Total <= -500 && !slices.Contains(resellerBlackList, v.ResellerName) {
|
||||
gt = append(gt, v)
|
||||
totalSum500 += v.Total
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ type Uploader struct {
|
|||
ossClient *utils_oss.Client
|
||||
}
|
||||
|
||||
const RequestUrl = "http://excel2pic:8000/api/v1/convert"
|
||||
const RequestUrl = "http://192.168.6.109:8010/api/v1/convert"
|
||||
|
||||
func NewUploader(oss *utils_oss.Client) *Uploader {
|
||||
return &Uploader{
|
||||
|
|
@ -63,7 +63,7 @@ func (u *Uploader) Run(report *ReportRes) (err error) {
|
|||
|
||||
// excel2picPy 将excel转换为图片python
|
||||
// python 接口如下:
|
||||
// curl --location --request POST 'http://excel2pic:8000/api/v1/convert' \
|
||||
// curl --location --request POST 'http://192.168.6.109:8010/api/v1/convert' \
|
||||
// --header 'Content-Type: multipart/form-data; boundary=--------------------------952147881043913664015069' \
|
||||
// --form 'file=@"C:\\Users\\Administrator\\Downloads\\销售同比分析2025-12-29 0-12点.xlsx"' \
|
||||
// --form 'sheet_name="销售同比分析"'
|
||||
|
|
|
|||
Loading…
Reference in New Issue