diff --git a/agent/AgentConfiguration.go b/agent/AgentConfiguration.go index 59e81de..05bb88e 100644 --- a/agent/AgentConfiguration.go +++ b/agent/AgentConfiguration.go @@ -3,6 +3,7 @@ package agent import "time" type AgentConfiguration struct { + Name string ReportingIntervalMiliseconds uint } diff --git a/agent/LlamaCppObserver.go b/agent/LlamaCppObserver.go index f696c8b..9eaccd7 100644 --- a/agent/LlamaCppObserver.go +++ b/agent/LlamaCppObserver.go @@ -7,6 +7,7 @@ import ( "github.com/distantmagic/paddler/goroutine" "github.com/distantmagic/paddler/llamacpp" "github.com/distantmagic/paddler/management" + "github.com/google/uuid" "github.com/hashicorp/go-hclog" ) @@ -26,6 +27,19 @@ func (self *LlamaCppObserver) ObserveAndReport( "host", self.LlamaCppClient.LlamaCppConfiguration.HttpAddress.GetHostWithPort(), ) + agentRuntimeId, err := uuid.NewV7() + + if err != nil { + serverEventsChannel <- goroutine.ResultMessage{ + Comment: "failed to generate agent uuid", + Error: err, + } + + return + } + + agentRuntimeIdString := agentRuntimeId.String() + llamaCppHealthStatusChannel := make(chan llamacpp.LlamaCppHealthStatus) defer close(llamaCppHealthStatusChannel) @@ -45,6 +59,8 @@ func (self *LlamaCppObserver) ObserveAndReport( serverEventsChannel, self.ExternalLlamaCppConfiguration, &llamaCppHealthStatus, + agentRuntimeIdString, + self.AgentConfiguration.Name, ) cancel() diff --git a/go.mod b/go.mod index 6f03343..2856c0a 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/aws/aws-sdk-go-v2 v1.27.1 github.com/aws/aws-sdk-go-v2/config v1.27.17 github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.4 + github.com/google/uuid v1.6.0 github.com/hashicorp/go-hclog v1.6.2 github.com/puzpuzpuz/xsync/v3 v3.4.0 github.com/smira/go-statsd v1.3.3 diff --git a/go.sum b/go.sum index af4dc48..d9f93d9 100644 --- a/go.sum +++ b/go.sum @@ -32,6 +32,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hashicorp/go-hclog v1.6.2 h1:NOtoftovWkDheyUM/8JW3QMiXyxJK3uHRK7wV04nD2I= github.com/hashicorp/go-hclog v1.6.2/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= diff --git a/llamacpp/LlamaCppClient_test.go b/llamacpp/LlamaCppClient_test.go index bbe9001..a64fe5b 100644 --- a/llamacpp/LlamaCppClient_test.go +++ b/llamacpp/LlamaCppClient_test.go @@ -40,8 +40,6 @@ func TestHealthIsObtained(t *testing.T) { func TestCompletionsAreGenerated(t *testing.T) { responseChannel := make(chan LlamaCppCompletionToken) - defer close(responseChannel) - go llamaCppClient.GenerateCompletion( context.Background(), responseChannel, @@ -69,8 +67,6 @@ func TestCompletionsAreGenerated(t *testing.T) { func TestJsonSchemaConstrainedCompletionsAreGenerated(t *testing.T) { responseChannel := make(chan LlamaCppCompletionToken) - defer close(responseChannel) - go llamaCppClient.GenerateCompletion( context.Background(), responseChannel, diff --git a/loadbalancer/LlamaCppTargetConfiguration.go b/loadbalancer/LlamaCppTargetConfiguration.go index 6db26a4..2aabed8 100644 --- a/loadbalancer/LlamaCppTargetConfiguration.go +++ b/loadbalancer/LlamaCppTargetConfiguration.go @@ -4,5 +4,6 @@ import "github.com/distantmagic/paddler/llamacpp" type LlamaCppTargetConfiguration struct { Id string + Name string LlamaCppConfiguration *llamacpp.LlamaCppConfiguration `json:"llama_cpp_configuration"` } diff --git a/main.go b/main.go index 248f6ae..59e6db0 100644 --- a/main.go +++ b/main.go @@ -160,6 +160,11 @@ func main() { Value: DefaultManagementScheme, Destination: &agent.ManagementServerConfiguration.HttpAddress.Scheme, }, + &cli.StringFlag{ + Name: "name", + Value: "", + Destination: &agent.AgentConfiguration.Name, + }, &cli.StringFlag{ Name: "status-server-host", Value: "127.0.0.1", diff --git a/management/Client.go b/management/Client.go index 1c712a0..bfa2304 100644 --- a/management/Client.go +++ b/management/Client.go @@ -22,11 +22,14 @@ func (self *Client) ReportLlamaCppHealthStatus( serverEventsChannel chan<- goroutine.ResultMessage, llamaCppConfiguration *llamacpp.LlamaCppConfiguration, llamaCppHealthStatus *llamacpp.LlamaCppHealthStatus, + llamaCppTargetId string, + llamaCppTargetName string, ) { jsonData, err := json.Marshal(&RegisterTargetRequest{ LlamaCppHealthStatus: llamaCppHealthStatus, LlamaCppTargetConfiguration: &loadbalancer.LlamaCppTargetConfiguration{ - Id: llamaCppConfiguration.String(), + Id: llamaCppTargetId, + Name: llamaCppTargetName, LlamaCppConfiguration: llamaCppConfiguration, }, }) diff --git a/management/RegisterTargetRequest.go b/management/RegisterTargetRequest.go index ecc361c..4c69c89 100644 --- a/management/RegisterTargetRequest.go +++ b/management/RegisterTargetRequest.go @@ -8,4 +8,5 @@ import ( type RegisterTargetRequest struct { LlamaCppHealthStatus *llamacpp.LlamaCppHealthStatus `json:"llama_cpp_health_status"` LlamaCppTargetConfiguration *loadbalancer.LlamaCppTargetConfiguration `json:"llama_cpp_target_configuration"` + PaddlerAgentName string `json:"paddler_agent_name"` } diff --git a/management/resources/views/index.html b/management/resources/views/index.html index 1ce5d4e..634c773 100644 --- a/management/resources/views/index.html +++ b/management/resources/views/index.html @@ -24,9 +24,13 @@
+ Name: + {{.LlamaCppTargetConfiguration.Name}} +
Host: - {{.LlamaCppTargetConfiguration}} + {{.LlamaCppTargetConfiguration.LlamaCppConfiguration}}
Status: