@@ -29,7 +29,7 @@ type Client struct {
2929}
3030
3131// NewClient creates a new DMR client from the provided configuration
32- func NewClient (_ context.Context , cfg * latest.ModelConfig , opts ... options.Opt ) (* Client , error ) {
32+ func NewClient (ctx context.Context , cfg * latest.ModelConfig , opts ... options.Opt ) (* Client , error ) {
3333 if cfg == nil {
3434 slog .Error ("DMR client creation failed" , "error" , "model configuration is required" )
3535 return nil , errors .New ("model configuration is required" )
@@ -48,7 +48,7 @@ func NewClient(_ context.Context, cfg *latest.ModelConfig, opts ...options.Opt)
4848 // Resolve base_url for DMR models. If not provided, configure with the docker model plugin, else fallback.
4949 baseURL := cfg .BaseURL
5050 if baseURL == "" {
51- endpoint , engine , err := getDockerModelEndpointAndEngine ()
51+ endpoint , engine , err := getDockerModelEndpointAndEngine (ctx )
5252 if err != nil {
5353 slog .Debug ("docker model status query failed" , "error" , err )
5454 }
@@ -61,7 +61,7 @@ func NewClient(_ context.Context, cfg *latest.ModelConfig, opts ...options.Opt)
6161 slog .Warn (w )
6262 }
6363 slog .Debug ("DMR provider_opts parsed" , "model" , cfg .Model , "context_size" , contextSize , "runtime_flags" , finalFlags , "engine" , engine )
64- if err := configureDockerModel (cfg .Model , contextSize , finalFlags ); err != nil {
64+ if err := configureDockerModel (ctx , cfg .Model , contextSize , finalFlags ); err != nil {
6565 slog .Debug ("docker model configure skipped or failed" , "error" , err )
6666 }
6767
@@ -464,10 +464,10 @@ func parseDMRProviderOpts(cfg *latest.ModelConfig) (contextSize int, runtimeFlag
464464 return contextSize , runtimeFlags
465465}
466466
467- func configureDockerModel (model string , contextSize int , runtimeFlags []string ) error {
467+ func configureDockerModel (ctx context. Context , model string , contextSize int , runtimeFlags []string ) error {
468468 args := buildDockerModelConfigureArgs (model , contextSize , runtimeFlags )
469469
470- cmd := exec .Command ( "docker" , args ... )
470+ cmd := exec .CommandContext ( ctx , "docker" , args ... )
471471 slog .Debug ("Running docker model configure" , "model" , model , "args" , args )
472472 var stdout , stderr bytes.Buffer
473473 cmd .Stdout = & stdout
@@ -494,8 +494,8 @@ func buildDockerModelConfigureArgs(model string, contextSize int, runtimeFlags [
494494 return args
495495}
496496
497- func getDockerModelEndpointAndEngine () (endpoint , engine string , err error ) {
498- cmd := exec .Command ( "docker" , "model" , "status" , "--json" )
497+ func getDockerModelEndpointAndEngine (ctx context. Context ) (endpoint , engine string , err error ) {
498+ cmd := exec .CommandContext ( ctx , "docker" , "model" , "status" , "--json" )
499499 var stdout , stderr bytes.Buffer
500500 cmd .Stdout = & stdout
501501 cmd .Stderr = & stderr
0 commit comments