-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserviceAgent.go
48 lines (42 loc) · 1.6 KB
/
serviceAgent.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) 2025 minRAG Authors.
//
// This file is part of minRAG.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses>.
package main
import (
"context"
"gitee.com/chunanyong/zorm"
)
// AgentRequestBody 请求Agent的参数
type AgentRequestBody struct {
Model string `json:"model,omitempty"`
Messages []ChatMessage `json:"messages,omitempty"`
Stream bool `json:"stream,omitempty"`
User string `json:"user,omitempty"`
}
// findAllAgentList 查询所有的智能体
func findAllAgentList(ctx context.Context) ([]Agent, error) {
finder := zorm.NewSelectFinder(tableAgentName).Append("order by sortNo desc")
list := make([]Agent, 0)
err := zorm.Query(ctx, finder, &list, nil)
return list, err
}
// findAgentByID 查询Agent
func findAgentByID(ctx context.Context, agentID string) (*Agent, error) {
finder := zorm.NewSelectFinder(tableAgentName).Append("WHERE id=? and status=1", agentID)
agent := &Agent{}
_, err := zorm.QueryRow(ctx, finder, agent)
return agent, err
}