Skip to content

Commit 68c693d

Browse files
committed
add model config for ai
1 parent 6f90433 commit 68c693d

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

server/api/search_result_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package api
2+
3+
import (
4+
"encoding/json"
5+
"fmt"
6+
"github.com/madneal/gshark/global"
7+
"github.com/madneal/gshark/initialize"
8+
"github.com/madneal/gshark/model"
9+
"github.com/madneal/gshark/service"
10+
"testing"
11+
)
12+
13+
func TestStartAITask(t *testing.T) {
14+
global.GVA_VP = initialize.Viper("../config.yaml")
15+
global.GVA_LOG = initialize.Zap()
16+
global.GVA_DB = initialize.Gorm()
17+
err, list := service.ListSearchResultByStatus(0)
18+
if err != nil {
19+
fmt.Println(err)
20+
return
21+
}
22+
for _, result := range list {
23+
var content string
24+
textMatches := make([]model.TextMatch, 0)
25+
if json.Valid(result.TextMatchesJson) {
26+
err = json.Unmarshal(result.TextMatchesJson, &textMatches)
27+
if err != nil {
28+
fmt.Println(err)
29+
continue
30+
}
31+
for _, textMatch := range textMatches {
32+
content += *textMatch.Fragment + "\n"
33+
}
34+
} else {
35+
content = string(result.TextMatchesJson)
36+
}
37+
fmt.Println(content)
38+
}
39+
}

server/config-temp.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ system:
4444
gitlab-base:
4545
ai_server:
4646
ai_token:
47+
model:
4748
wechat:
4849
url:
4950
enable: false

server/config/system.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ type System struct {
99
GitlabBase string `mapstructure:"gitlab-base" yaml:"gitlab-base"`
1010
AiServer string `mapstructure:"ai_server" yaml:"ai_server"`
1111
AiToken string `mapstructure:"ai_token" yaml:"ai_token"`
12+
Model string `mapstructure:"model" json:"model" yaml:"model"`
1213
}

server/service/ai.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func Question(command, question string) string {
4545
func callChatCompletion(command, question string) ([]byte, error) {
4646
var result []byte
4747
requestData := ChatCompletionRequest{
48-
Model: "deepseek-r1",
48+
Model: global.GVA_CONFIG.System.Model,
4949
Messages: []Message{
5050
{
5151
Role: "system",

0 commit comments

Comments
 (0)