Skip to content

Commit

Permalink
fix(worker): ensure multipart writers correctly forward parameters (l…
Browse files Browse the repository at this point in the history
…ivepeer#98)

This commit ensure that the multipart writers correctly forward the
`safety_check` and `image_guidance_scale` parameters to the AI runner
container.
  • Loading branch information
rickstaa authored and eliteprox committed Jun 10, 2024
1 parent cf027de commit e869327
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions worker/multipart.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Package worker's module provides multipart form data utilities.
This module extends oapi-codegen Go bindings with multipart writers, enabling request
parameter encoding for inter-node communication (gateway, orchestrator, runner).
*/
package worker

import (
Expand Down Expand Up @@ -44,11 +50,21 @@ func NewImageToImageMultipartWriter(w io.Writer, req ImageToImageMultipartReques
return nil, err
}
}
if req.ImageGuidanceScale != nil {
if err := mw.WriteField("image_guidance_scale", fmt.Sprintf("%f", *req.ImageGuidanceScale)); err != nil {
return nil, err
}
}
if req.NegativePrompt != nil {
if err := mw.WriteField("negative_prompt", *req.NegativePrompt); err != nil {
return nil, err
}
}
if req.SafetyCheck != nil {
if err := mw.WriteField("safety_check", strconv.FormatBool(*req.SafetyCheck)); err != nil {
return nil, err
}
}
if req.Seed != nil {
if err := mw.WriteField("seed", strconv.Itoa(*req.Seed)); err != nil {
return nil, err
Expand Down Expand Up @@ -121,6 +137,11 @@ func NewImageToVideoMultipartWriter(w io.Writer, req ImageToVideoMultipartReques
return nil, err
}
}
if req.SafetyCheck != nil {
if err := mw.WriteField("safety_check", strconv.FormatBool(*req.SafetyCheck)); err != nil {
return nil, err
}
}

if err := mw.Close(); err != nil {
return nil, err
Expand Down

0 comments on commit e869327

Please sign in to comment.