🆕real link es #1

This commit is contained in:
Havoc412 2024-11-12 12:41:57 +08:00
parent a0afee4161
commit 5f0e76c0bb
6 changed files with 25 additions and 3 deletions

View File

@ -71,4 +71,7 @@ const (
// GLM 部分
ErrorsGlmClientInitFail string = "GLM Client 初始化失败"
// ES 部分
ErrorsInitConnFail string = "初始化 Elasticsearch 连接失败"
)

View File

@ -9,10 +9,10 @@ import (
"strings"
"github.com/casbin/casbin/v2"
"github.com/elastic/go-elasticsearch/v8"
"github.com/yankeguo/zhipu"
"go.uber.org/zap"
"gorm.io/gorm"
)
var (
@ -46,6 +46,9 @@ var (
// GLM 全局客户端
GlmClient *zhipu.Client
// ES 全局客户端
ElasticClient *elasticsearch.Client
)
func init() {

View File

@ -74,7 +74,9 @@ func (e *Encounters) Create(context *gin.Context) {
return
}
// 3. ES speed
// TODO
if level := int(context.GetFloat64(consts.ValidatorPrefix + "level")); level > 1 {
// TODO
}
response.Success(context, consts.CurdStatusOkMsg, gin.H{
"encounter_id": encounter_id,

View File

@ -16,6 +16,7 @@ import (
"log"
"os"
"github.com/elastic/go-elasticsearch/v8"
"github.com/yankeguo/zhipu"
)
@ -119,4 +120,12 @@ func init() {
if err != nil {
log.Fatal(my_errors.ErrorsGlmClientInitFail + err.Error())
}
// 12. ES 客户端启动
variable.ElasticClient, err = elasticsearch.NewClient(elasticsearch.Config{
Addresses: []string{variable.ConfigYml.GetString("ElasticSearch.Addr")},
})
if err != nil {
log.Fatal(my_errors.ErrorsInitConnFail + err.Error())
}
}

View File

@ -155,4 +155,9 @@ Weixin:
Glm:
ApiKey: "0cf510ebc01599dba2a593069c1bdfbc.nQBQ4skP8xBh7ijU"
DefaultModel: "glm-4-flash"
ElasticSearch:
Addr: "http://localhost:9200"
UserName: "elastic"
Password: ""

View File

@ -13,7 +13,7 @@ func InitElastic() {
var err error
ElasticClient, err = elasticsearch.NewClient(elasticsearch.Config{
// Addresses: []string{"http://113.44.68.213:9200"},
Addresses: []string{"http://127.0.0.1:9200"},
Addresses: []string{"http://localhost:9200"}, // TIP 用 localhost 可以127.0.0.1 无效...
// Username: "elastic",
// Password: "U8n61yn*Sp4Kvbuqo_K8",
})