From 0189345b88d2d0876ef5a297bc82c44b6c201ad7 Mon Sep 17 00:00:00 2001 From: Victor Elias Date: Thu, 9 Jan 2025 18:43:33 -0300 Subject: [PATCH] ai/worker: Update package with what was in go.mod (c19289d) --- ai/worker/docker.go | 1 - ai/worker/multipart.go | 50 +++++++++ ai/worker/runner.gen.go | 218 +++++++++++++++++++--------------------- ai/worker/worker.go | 20 ++-- 4 files changed, 167 insertions(+), 122 deletions(-) diff --git a/ai/worker/docker.go b/ai/worker/docker.go index 1b30f350c..9d7720fdf 100644 --- a/ai/worker/docker.go +++ b/ai/worker/docker.go @@ -61,7 +61,6 @@ var pipelineToImage = map[string]string{ "segment-anything-2": "livepeer/ai-runner:segment-anything-2", "text-to-speech": "livepeer/ai-runner:text-to-speech", "audio-to-text": "livepeer/ai-runner:audio-to-text", - "llm": "livepeer/ai-runner:llm", } var livePipelineToImage = map[string]string{ diff --git a/ai/worker/multipart.go b/ai/worker/multipart.go index bc70ba8f4..551b0af84 100644 --- a/ai/worker/multipart.go +++ b/ai/worker/multipart.go @@ -259,6 +259,56 @@ func NewAudioToTextMultipartWriter(w io.Writer, req GenAudioToTextMultipartReque return mw, nil } +func NewLLMMultipartWriter(w io.Writer, req BodyGenLLM) (*multipart.Writer, error) { + mw := multipart.NewWriter(w) + + if err := mw.WriteField("prompt", req.Prompt); err != nil { + return nil, fmt.Errorf("failed to write prompt field: %w", err) + } + + if req.History != nil { + if err := mw.WriteField("history", *req.History); err != nil { + return nil, fmt.Errorf("failed to write history field: %w", err) + } + } + + if req.ModelId != nil { + if err := mw.WriteField("model_id", *req.ModelId); err != nil { + return nil, fmt.Errorf("failed to write model_id field: %w", err) + } + } + + if req.SystemMsg != nil { + if err := mw.WriteField("system_msg", *req.SystemMsg); err != nil { + return nil, fmt.Errorf("failed to write system_msg field: %w", err) + } + } + + if req.Temperature != nil { + if err := mw.WriteField("temperature", fmt.Sprintf("%f", *req.Temperature)); err != nil { + return nil, fmt.Errorf("failed to write temperature field: %w", err) + } + } + + if req.MaxTokens != nil { + if err := mw.WriteField("max_tokens", strconv.Itoa(*req.MaxTokens)); err != nil { + return nil, fmt.Errorf("failed to write max_tokens field: %w", err) + } + } + + if req.Stream != nil { + if err := mw.WriteField("stream", fmt.Sprintf("%v", *req.Stream)); err != nil { + return nil, fmt.Errorf("failed to write stream field: %w", err) + } + } + + if err := mw.Close(); err != nil { + return nil, fmt.Errorf("failed to close multipart writer: %w", err) + } + + return mw, nil +} + func NewSegmentAnything2MultipartWriter(w io.Writer, req GenSegmentAnything2MultipartRequestBody) (*multipart.Writer, error) { mw := multipart.NewWriter(w) writer, err := mw.CreateFormFile("image", req.Image.Filename()) diff --git a/ai/worker/runner.gen.go b/ai/worker/runner.gen.go index 587437edd..9b6fa10f2 100644 --- a/ai/worker/runner.gen.go +++ b/ai/worker/runner.gen.go @@ -144,6 +144,17 @@ type BodyGenImageToVideo struct { Width *int `json:"width,omitempty"` } +// BodyGenLLM defines model for Body_genLLM. +type BodyGenLLM struct { + History *string `json:"history,omitempty"` + MaxTokens *int `json:"max_tokens,omitempty"` + ModelId *string `json:"model_id,omitempty"` + Prompt string `json:"prompt"` + Stream *bool `json:"stream,omitempty"` + SystemMsg *string `json:"system_msg,omitempty"` + Temperature *float32 `json:"temperature,omitempty"` +} + // BodyGenSegmentAnything2 defines model for Body_genSegmentAnything2. type BodyGenSegmentAnything2 struct { // Box A length 4 array given as a box prompt to the model, in XYXY format. @@ -270,28 +281,8 @@ type ImageToTextResponse struct { Text string `json:"text"` } -// LLMMessage defines model for LLMMessage. -type LLMMessage struct { - Content string `json:"content"` - Role string `json:"role"` -} - -// LLMRequest defines model for LLMRequest. -type LLMRequest struct { - MaxTokens *int `json:"max_tokens,omitempty"` - Messages []LLMMessage `json:"messages"` - Model *string `json:"model,omitempty"` - Stream *bool `json:"stream,omitempty"` - Temperature *float32 `json:"temperature,omitempty"` - TopK *int `json:"top_k,omitempty"` - TopP *float32 `json:"top_p,omitempty"` -} - // LLMResponse defines model for LLMResponse. type LLMResponse struct { - Created int `json:"created"` - Id string `json:"id"` - Model string `json:"model"` Response string `json:"response"` TokensUsed int `json:"tokens_used"` } @@ -458,8 +449,8 @@ type GenImageToVideoMultipartRequestBody = BodyGenImageToVideo // GenLiveVideoToVideoJSONRequestBody defines body for GenLiveVideoToVideo for application/json ContentType. type GenLiveVideoToVideoJSONRequestBody = LiveVideoToVideoParams -// GenLLMJSONRequestBody defines body for GenLLM for application/json ContentType. -type GenLLMJSONRequestBody = LLMRequest +// GenLLMFormdataRequestBody defines body for GenLLM for application/x-www-form-urlencoded ContentType. +type GenLLMFormdataRequestBody = BodyGenLLM // GenSegmentAnything2MultipartRequestBody defines body for GenSegmentAnything2 for multipart/form-data ContentType. type GenSegmentAnything2MultipartRequestBody = BodyGenSegmentAnything2 @@ -637,7 +628,7 @@ type ClientInterface interface { // GenLLMWithBody request with any body GenLLMWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - GenLLM(ctx context.Context, body GenLLMJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + GenLLMWithFormdataBody(ctx context.Context, body GenLLMFormdataRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) // GenSegmentAnything2WithBody request with any body GenSegmentAnything2WithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -776,8 +767,8 @@ func (c *Client) GenLLMWithBody(ctx context.Context, contentType string, body io return c.Client.Do(req) } -func (c *Client) GenLLM(ctx context.Context, body GenLLMJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGenLLMRequest(c.Server, body) +func (c *Client) GenLLMWithFormdataBody(ctx context.Context, body GenLLMFormdataRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGenLLMRequestWithFormdataBody(c.Server, body) if err != nil { return nil, err } @@ -1097,15 +1088,15 @@ func NewGenLiveVideoToVideoRequestWithBody(server string, contentType string, bo return req, nil } -// NewGenLLMRequest calls the generic GenLLM builder with application/json body -func NewGenLLMRequest(server string, body GenLLMJSONRequestBody) (*http.Request, error) { +// NewGenLLMRequestWithFormdataBody calls the generic GenLLM builder with application/x-www-form-urlencoded body +func NewGenLLMRequestWithFormdataBody(server string, body GenLLMFormdataRequestBody) (*http.Request, error) { var bodyReader io.Reader - buf, err := json.Marshal(body) + bodyStr, err := runtime.MarshalForm(body, nil) if err != nil { return nil, err } - bodyReader = bytes.NewReader(buf) - return NewGenLLMRequestWithBody(server, "application/json", bodyReader) + bodyReader = strings.NewReader(bodyStr.Encode()) + return NewGenLLMRequestWithBody(server, "application/x-www-form-urlencoded", bodyReader) } // NewGenLLMRequestWithBody generates requests for GenLLM with any type of body @@ -1347,7 +1338,7 @@ type ClientWithResponsesInterface interface { // GenLLMWithBodyWithResponse request with any body GenLLMWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*GenLLMResponse, error) - GenLLMWithResponse(ctx context.Context, body GenLLMJSONRequestBody, reqEditors ...RequestEditorFn) (*GenLLMResponse, error) + GenLLMWithFormdataBodyWithResponse(ctx context.Context, body GenLLMFormdataRequestBody, reqEditors ...RequestEditorFn) (*GenLLMResponse, error) // GenSegmentAnything2WithBodyWithResponse request with any body GenSegmentAnything2WithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*GenSegmentAnything2Response, error) @@ -1784,8 +1775,8 @@ func (c *ClientWithResponses) GenLLMWithBodyWithResponse(ctx context.Context, co return ParseGenLLMResponse(rsp) } -func (c *ClientWithResponses) GenLLMWithResponse(ctx context.Context, body GenLLMJSONRequestBody, reqEditors ...RequestEditorFn) (*GenLLMResponse, error) { - rsp, err := c.GenLLM(ctx, body, reqEditors...) +func (c *ClientWithResponses) GenLLMWithFormdataBodyWithResponse(ctx context.Context, body GenLLMFormdataRequestBody, reqEditors ...RequestEditorFn) (*GenLLMResponse, error) { + rsp, err := c.GenLLMWithFormdataBody(ctx, body, reqEditors...) if err != nil { return nil, err } @@ -2991,87 +2982,86 @@ func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handl // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/+xdeW/jtrb/KoTeA5IB7GzttA8B7h+ZpTPBTaZBljst2sCXlo5lTiRSJakk7rx89wcu", - "kkiJsuU0Sft6/dc4Epez/s4heaj5GsUsLxgFKkV0+DUS8RxyrH8enR2/55xx9TsBEXNSSMJodKjeIFCv", - "EAdRMCoA5SyBbCcaRQVnBXBJQI+Ri7Tb/XIOtnsOQuAUVD9JZAbRYXQqUvXXolB/CMkJTaOHh1HE4beS", - "cEiiw1/0qNdNl5rQuh+bfoFYRg+j6KhMCDu3VHZJOffoRzPGEVY9UAoUOFatukzpFvpHlv04iw5/+Rr9", - "N4dZdBj9124jzV0ryt1TSAi+Oj+JHq5HAUnYmSAxM+90uDXTufx6PAWYfsOSxSQFqhtesku4l4rcHi58", - "kq6KjOGkogbNSAZIMjQFJDmmquUUEiWTGeM5ltFhNCUU80XUoq+rxFGUg8QJltjMOsNlpvp/fYjacjlK", - "EqJ+4gx9YVNEqJmMMGppKbAQkKg/5BxQQQrICPXtqJorRIdS9oQkPh0dKj6WaUpoin7AcWUgx+9QqSZW", - "hlLJo6ispJ7aNE1CU3OQJacTSXIQEueF8GmQvIQOHee6D2r6mOnnnkqQhHu5gy7KomBcWdMtzkoQh2hL", - "AJVAY9gaoa07xpOtEVJmjgxRaMpYBpii7S01+ZZ6tzXDmYCtVzvonaEMEYHs6+1mvFc7VUuUA6YCUeYQ", - "uWNns+/U7/EUa601bRypWS4vG8msgoGOY4Tsfol7HOc4hUum/+n6R1qSBNMYJiLGGXhq+n7ndVtH72nM", - "So5TENZSZI0hgEiuX8QZE5AtUEboTWO8Sm+o4CwvJNqek3QO3OoO5XiBOCRlbIdAv5U4I3LxypXbB0sn", - "utB01vzSMp8CV/ySisEeTzdjS6YoJ7MFuiNy3vGrfnc38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JbvdHIkhK9/gdO4whua+UQzlAxbCQ00ixEGQIN9a2rYQsJiP", - "l5dnPTVG6tXAIiMDFsMLcup6oW5BzrsKd8zMHuK05WendZhu2Onh9V84I4kerua6j5UKnJdy0h7PQXLD", - "SQjGXWrbA4Toxjy5w1x7vZXFoDoq5d9LETstSpXvmUqquuDnzGuzjPkWIDmcfShK1GdybrI76DjE5tZu", - "+7Pq2SrULZqG9byjhnHXdAJSXqKMC4mlGKQGDjgbq2itFbIMZBVZohr3kQpp+3xLKYbsv65WDPsBtfQS", - "/hFwJudvqzzbl6garhThtGyuOyLTpErNHMqAlrki9sd/RqPo/fn5j+fRKDp+d/LeJe/CTLCKYUuHy5dD", - "doArvVRcq2oytEwJrG57hNFeW7jZ6eraStfKTLHEquzV0nLd6resptI5f1xLMDqlXyaX/tVAIxVd27dy", - "KdBO0VtpeYiDAKMnJ6enpiy3a9AxoxKodL3urX0U2tphmeeg5yxb7ZzcNKpmcuh3CAuTfQ6/lSACJ/k5", - "vp9IdgO0fab0nbtnfI8uTZtwmqhnFoNDs0Ptg1uVaodpG6iFos4WjAeGwZW+5IBzr5+uyfTrKnAeXHhL", - "yAtlYiWH1pHi966xNY0CJ3eSFRN/j2G873RmBfpnUKKqX9EumHK7na0sBKmV4ltJZQd9VtJ4b8u6OShv", - "86zbPgqesQ9ZlFRKXalH7pDV7E623dRZ9WtbnZTCJ9iYMLoSQ7ZDuDO+M9zILA1yS2ollraQl0AIuQV9", - "jGZP084wx8ZjunDCWTYpebZi7/Hq/ESjqSinut6Z0BTdEowuOYlv9IkFkyxmmd2JTPTGtD10z8itPXkf", - "SzZulxegQhPnoutbQxa64kFNwa1y9DWILsppRsRc0Wz69pNeJQBVXoBpgjKWeuS9N2P0UDdwM1etVttZ", - "B5IM8ZJ25aZemB9f2HQHfWKSxICkrrycE4GIQGodmaBq8qquoqpgNZtiTM6BI85KCWKkN1yJRAkDgSiT", - "pkRMzYRRcKfZlFzAPY6lebYtXqEECqCJQIz6nJC8yC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DWytmda5MjyNVIFPGsssZ6BkozytDQQ1hzld1EA76paz/Hvh7PZbIh5", + "Qikz4LFI7EH6ZtmCmfKl3d/5wGfr8VuPf0KPt3e9berhWW6duipOH9Lq4p/hYb+PV3cEVaXQ+D0Y5UvW", + "AIE7hZ55HdCZ8YXd3C8y3zr61tGfztFr76uNmxw+wu9V10EG0Z6J2WscRnxo1SjjboBTkhxO853ar2fK", + "8LvVZdtzh63b/03cHuvq/sCxg3bcz3N2W6G31uaf38X977Xs/4pUfy1cbwvqRS0g5YlTlOn9n1M9SGGr", + "/p4VKrzCwhfGCv9/QNtixRYrnh4rGhd6HFhU3REtSueuzyBMVPcNNisBMp7XV+rjR5JakcWVykG3X9xY", + "+Myrg3qibXaw9fi/icc7t31u6Oql6wwKCVA4Xeu65boC+V0myoS8E3lecqbn5APVMKPzqPokGOue1dHe", + "XiKB5sPUvt3Nqu67semOhfY9419qzCr6hm0GUthujxZsbwya7jX8Ptw8/G8AAAD//5bIT20SdgAA", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/ai/worker/worker.go b/ai/worker/worker.go index 6c5a2f4e5..e381e4be2 100644 --- a/ai/worker/worker.go +++ b/ai/worker/worker.go @@ -394,11 +394,10 @@ func (w *Worker) AudioToText(ctx context.Context, req GenAudioToTextMultipartReq return resp.JSON200, nil } -func (w *Worker) LLM(ctx context.Context, req GenLLMJSONRequestBody) (interface{}, error) { +func (w *Worker) LLM(ctx context.Context, req GenLLMFormdataRequestBody) (interface{}, error) { isStreaming := req.Stream != nil && *req.Stream - ctx, cancel := context.WithCancel(ctx) - defer cancel() - c, err := w.borrowContainer(ctx, "llm", *req.Model) + borrowCtx, cancel := context.WithCancel(context.Background()) + c, err := w.borrowContainer(borrowCtx, "llm", *req.ModelId) if err != nil { return nil, err } @@ -409,10 +408,17 @@ func (w *Worker) LLM(ctx context.Context, req GenLLMJSONRequestBody) (interface{ return nil, errors.New("container client is nil") } - slog.Info("Container borrowed successfully", "model_id", *req.Model) + slog.Info("Container borrowed successfully", "model_id", *req.ModelId) + + var buf bytes.Buffer + mw, err := NewLLMMultipartWriter(&buf, req) + if err != nil { + cancel() + return nil, err + } if isStreaming { - resp, err := c.Client.GenLLM(ctx, req) + resp, err := c.Client.GenLLMWithBody(ctx, mw.FormDataContentType(), &buf) if err != nil { cancel() return nil, err @@ -421,7 +427,7 @@ func (w *Worker) LLM(ctx context.Context, req GenLLMJSONRequestBody) (interface{ } defer cancel() - resp, err := c.Client.GenLLMWithResponse(ctx, req) + resp, err := c.Client.GenLLMWithBodyWithResponse(ctx, mw.FormDataContentType(), &buf) if err != nil { return nil, err }