필드 테스트를 위해 edge OpenAI-compatible 경로와 node adapter 설정을 확장하고, Jenkins 바이너리 빌드 및 control-plane/web compose 배포 구성을 함께 정리한다.
89 lines
2.5 KiB
Go
89 lines
2.5 KiB
Go
package node
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"google.golang.org/protobuf/types/known/structpb"
|
|
|
|
"iop/packages/config"
|
|
iop "iop/proto/gen/iop"
|
|
)
|
|
|
|
// BuildConfigPayload converts a NodeRecord's adapter config to the proto payload
|
|
// sent to node during registration.
|
|
func BuildConfigPayload(rec *NodeRecord) (*iop.NodeConfigPayload, error) {
|
|
payload := &iop.NodeConfigPayload{
|
|
Runtime: &iop.NodeRuntimeConfig{
|
|
Concurrency: int32(rec.Runtime.Concurrency),
|
|
WorkspaceRoot: rec.Runtime.WorkspaceRoot,
|
|
},
|
|
}
|
|
|
|
mockSettings, err := structpb.NewStruct(nil)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("buildConfigPayload: mock: %w", err)
|
|
}
|
|
payload.Adapters = append(payload.Adapters, &iop.AdapterConfig{
|
|
Type: "mock",
|
|
Enabled: true,
|
|
Settings: mockSettings,
|
|
})
|
|
|
|
if rec.Adapters.Ollama.Enabled {
|
|
payload.Adapters = append(payload.Adapters, &iop.AdapterConfig{
|
|
Type: "ollama",
|
|
Enabled: true,
|
|
Config: &iop.AdapterConfig_Ollama{
|
|
Ollama: &iop.OllamaAdapterConfig{
|
|
BaseUrl: rec.Adapters.Ollama.BaseURL,
|
|
ContextSize: int32(rec.Adapters.Ollama.ContextSize),
|
|
},
|
|
},
|
|
})
|
|
}
|
|
if rec.Adapters.Vllm.Enabled {
|
|
payload.Adapters = append(payload.Adapters, &iop.AdapterConfig{
|
|
Type: "vllm",
|
|
Enabled: true,
|
|
Config: &iop.AdapterConfig_Vllm{
|
|
Vllm: &iop.VllmAdapterConfig{Endpoint: rec.Adapters.Vllm.Endpoint},
|
|
},
|
|
})
|
|
}
|
|
if rec.Adapters.CLI.Enabled {
|
|
profiles := make(map[string]*iop.CLIProfileConfig, len(rec.Adapters.CLI.Profiles))
|
|
for name, p := range rec.Adapters.CLI.Profiles {
|
|
profiles[name] = cliProfileToProto(p)
|
|
}
|
|
payload.Adapters = append(payload.Adapters, &iop.AdapterConfig{
|
|
Type: "cli",
|
|
Enabled: true,
|
|
Config: &iop.AdapterConfig_Cli{
|
|
Cli: &iop.CLIAdapterConfig{Profiles: profiles},
|
|
},
|
|
})
|
|
}
|
|
return payload, nil
|
|
}
|
|
|
|
func cliProfileToProto(p config.CLIProfileConf) *iop.CLIProfileConfig {
|
|
out := &iop.CLIProfileConfig{
|
|
Command: p.Command,
|
|
Args: append([]string(nil), p.Args...),
|
|
Env: append([]string(nil), p.Env...),
|
|
Persistent: p.Persistent,
|
|
Terminal: p.Terminal,
|
|
ResponseIdleTimeoutMs: int32(p.ResponseIdleTimeoutMS),
|
|
StartupIdleTimeoutMs: int32(p.StartupIdleTimeoutMS),
|
|
OutputFormat: p.OutputFormat,
|
|
Mode: p.Mode,
|
|
ResumeArgs: append([]string(nil), p.ResumeArgs...),
|
|
}
|
|
if !p.CompletionMarker.Empty() {
|
|
out.CompletionMarker = &iop.CLICompletionMarker{
|
|
Line: p.CompletionMarker.Line,
|
|
Regex: p.CompletionMarker.Regex,
|
|
}
|
|
}
|
|
return out
|
|
}
|