-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy pathfactory_test.go
More file actions
89 lines (75 loc) · 2.29 KB
/
Copy pathfactory_test.go
File metadata and controls
89 lines (75 loc) · 2.29 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package agents_test
import (
"context"
"fmt"
"github.com/ambient-code/platform/components/ambient-api-server/pkg/api/openapi"
"github.com/ambient-code/platform/components/ambient-api-server/plugins/agents"
"github.com/openshift-online/rh-trex-ai/pkg/api/presenters"
"github.com/openshift-online/rh-trex-ai/pkg/environments"
)
func newAgent(name string) (*agents.Agent, error) {
agentService := agents.Service(&environments.Environment().Services)
agent := &agents.Agent{
ProjectId: "test-project_id",
Name: name,
}
sub, err := agentService.Create(context.Background(), agent)
if err != nil {
return nil, err
}
return sub, nil
}
func newAgentWithProject(name string, projectID string) (*agents.Agent, error) {
agentService := agents.Service(&environments.Environment().Services)
agent := &agents.Agent{
ProjectId: projectID,
Name: name,
}
sub, err := agentService.Create(context.Background(), agent)
if err != nil {
return nil, fmt.Errorf("agents.Create: %s", err.Error())
}
return sub, nil
}
func newAgentList(namePrefix string, count int) ([]*agents.Agent, error) {
var items []*agents.Agent
for i := 1; i <= count; i++ {
name := fmt.Sprintf("%s_%d", namePrefix, i)
c, err := newAgent(name)
if err != nil {
return nil, err
}
items = append(items, c)
}
return items, nil
}
func presentAgent(agent *agents.Agent) openapi.Agent {
reference := presenters.PresentReference(agent.ID, agent)
return openapi.Agent{
Id: reference.Id,
Kind: reference.Kind,
Href: reference.Href,
CreatedAt: openapi.PtrTime(agent.CreatedAt),
UpdatedAt: openapi.PtrTime(agent.UpdatedAt),
ProjectId: agent.ProjectId,
ParentAgentId: agent.ParentAgentId,
OwnerUserId: openapi.PtrString(agent.OwnerUserId),
Name: agent.Name,
DisplayName: agent.DisplayName,
Description: agent.Description,
Prompt: agent.Prompt,
RepoUrl: agent.RepoUrl,
WorkflowId: agent.WorkflowId,
LlmModel: openapi.PtrString(agent.LlmModel),
LlmTemperature: openapi.PtrFloat64(agent.LlmTemperature),
LlmMaxTokens: openapi.PtrInt32(agent.LlmMaxTokens),
}
}
func stringPtr(s string) *string { return &s }
var (
_ = newAgent
_ = newAgentWithProject
_ = newAgentList
_ = presentAgent
_ = stringPtr
)