From 40700f42331cc08491b43f6b6ea9f028205fb26c Mon Sep 17 00:00:00 2001 From: Brad | ad-astra <99882368+ad-astra-video@users.noreply.github.com> Date: Tue, 14 Jan 2025 01:50:57 -0600 Subject: [PATCH] Fix codegen and some small updates (#395) * fix openapi yaml and runner.gen.go * fix streaming * cancel context if borrow container fails * fix error message --- runner/app/pipelines/llm.py | 2 +- runner/app/routes/llm.py | 4 +- runner/gateway.openapi.yaml | 12 ++- runner/gen_openapi.py | 1 + runner/openapi.yaml | 12 ++- worker/runner.gen.go | 170 ++++++++++++++++++------------------ worker/worker.go | 15 ++-- 7 files changed, 116 insertions(+), 100 deletions(-) diff --git a/runner/app/pipelines/llm.py b/runner/app/pipelines/llm.py index 3387ad0a..67d37498 100644 --- a/runner/app/pipelines/llm.py +++ b/runner/app/pipelines/llm.py @@ -204,7 +204,7 @@ async def generate( input_tokens = len(tokenizer.encode(full_prompt)) if input_tokens > self.engine_args.max_model_len: raise ValueError( - f"Input sequence length ({input_tokens}) exceeds maximum allowed ({self.engine.engine_args.max_model_len})") + f"Input sequence length ({input_tokens}) exceeds maximum allowed ({self.engine_args.max_model_len})") total_tokens = 0 current_response = "" diff --git a/runner/app/routes/llm.py b/runner/app/routes/llm.py index 9a5dde19..40d29aeb 100644 --- a/runner/app/routes/llm.py +++ b/runner/app/routes/llm.py @@ -101,7 +101,9 @@ async def llm( logger.error(f"LLM processing error: {str(e)}") return JSONResponse( status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, - content={"detail": "Internal server error during LLM processing."} + content=http_error( + "Internal server error during LLM processing." + ) ) diff --git a/runner/gateway.openapi.yaml b/runner/gateway.openapi.yaml index 6367cc77..bd3d302e 100644 --- a/runner/gateway.openapi.yaml +++ b/runner/gateway.openapi.yaml @@ -525,7 +525,8 @@ components: AudioResponse: properties: audio: - $ref: '#/components/schemas/MediaURL' + allOf: + - $ref: '#/components/schemas/MediaURL' description: The generated audio. type: object required: @@ -826,7 +827,8 @@ components: HTTPError: properties: detail: - $ref: '#/components/schemas/APIError' + allOf: + - $ref: '#/components/schemas/APIError' description: Detailed error information. type: object required: @@ -876,9 +878,11 @@ components: title: Finish Reason default: '' delta: - $ref: '#/components/schemas/LLMMessage' + allOf: + - $ref: '#/components/schemas/LLMMessage' message: - $ref: '#/components/schemas/LLMMessage' + allOf: + - $ref: '#/components/schemas/LLMMessage' type: object required: - index diff --git a/runner/gen_openapi.py b/runner/gen_openapi.py index 94072e04..c91259ae 100644 --- a/runner/gen_openapi.py +++ b/runner/gen_openapi.py @@ -123,6 +123,7 @@ def write_openapi(fname: str, entrypoint: str = "runner"): description="An application to run AI pipelines", routes=app.routes, servers=SERVERS, + separate_input_output_schemas=False ) # Translate OpenAPI schema to 'gateway' side entrypoint if requested. diff --git a/runner/openapi.yaml b/runner/openapi.yaml index 8bb39f3c..2fd6a8bd 100644 --- a/runner/openapi.yaml +++ b/runner/openapi.yaml @@ -558,7 +558,8 @@ components: AudioResponse: properties: audio: - $ref: '#/components/schemas/MediaURL' + allOf: + - $ref: '#/components/schemas/MediaURL' description: The generated audio. type: object required: @@ -918,7 +919,8 @@ components: HTTPError: properties: detail: - $ref: '#/components/schemas/APIError' + allOf: + - $ref: '#/components/schemas/APIError' description: Detailed error information. type: object required: @@ -1022,9 +1024,11 @@ components: title: Finish Reason default: '' delta: - $ref: '#/components/schemas/LLMMessage' + allOf: + - $ref: '#/components/schemas/LLMMessage' message: - $ref: '#/components/schemas/LLMMessage' + allOf: + - $ref: '#/components/schemas/LLMMessage' type: object required: - index diff --git a/worker/runner.gen.go b/worker/runner.gen.go index b5ddefc7..1376bd81 100644 --- a/worker/runner.gen.go +++ b/worker/runner.gen.go @@ -41,7 +41,7 @@ type APIError struct { // AudioResponse Response model for audio generation. type AudioResponse struct { - // Audio A URL from which media can be accessed. + // Audio The generated audio. Audio MediaURL `json:"audio"` } @@ -226,7 +226,7 @@ type GPUUtilizationInfo struct { // HTTPError HTTP error response model. type HTTPError struct { - // Detail API error response model. + // Detail Detailed error information. Detail APIError `json:"detail"` } @@ -3006,89 +3006,89 @@ func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handl // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/+xdeW/ctrb/KsS8B9gBZry1aR8M3D8cJ02Ma6eGl5sWbTCXI53RMJZIlaRsT/P83R94", - "qIWUqFlc2+3rnb8ylric9XcOySPm6yASWS44cK0Gh18HKppBRvHn0fnJOymFNL9jUJFkuWaCDw7NGwLm", - "FZGgcsEVkEzEkO4MhoNcihykZoBjZCrpdr+aQdk9A6VoAqafZjqFweHgTCXmr3lu/lBaMp4MHh6GAwm/", - "FUxCPDj8BUf93HSpCa37ickXiPTgYTg4KmImLkoqu6RcePSTqZCEmh4kAQ6SmlZdprCF+fHfEqaDw8F/", - "7TYy3C0FuHsGMaPXF6cd4m1vl3yPxAAPb0Q8HyfAseGVuIJ7bWbvIcpn8DpPBY0hLtmashSIFmQCREvK", - "TcsJxIbFqZAZ1YPDwYRxKueDFn1dnQwHGWgaU03trFNapKb/14fBsG0vcczMT5qSL2JCGLeTMcFLWnKq", - "FMTmDz0DkrMcUsZ9s6jmCtFhdDdmsU9Hh4oPRZIwnpAfaFTp++QtKczERu+VPPJK6fXUtmkcmlqCLiQf", - "a5aB0jTLlU+DlgV06LjAPqTpY6efeSohGu71Drks8lxIDTG5pWkB6pBsKeAaeARbQ7J1J2S8NSTGaokl", - "ikyESIFysr1lJt8y77amNFWw9WqHvLWUEaZI+Xq7Ge/VTtWSZEC5Ilw4RO6Us5XvzO/RhKLWmjaO1Eou", - "rxrJLPPqjmOE7H6Be5xkNIErgf90/SMpWEx5BGMV0RQ8NX2/87qto3c8EoWkCajSUnQNCUBYhi+iVChI", - "5yRl/KYxXqM3kkuR5Zpsz1gyA1nqjmR0TiTERVQOQX4raMr0/JUrt/clneQS6az55UU2AWn4ZRWDPZ5u", - "x9bCUM6mc3LH9KzjV/3ubuUXsHUcd7xAjvtdOb6FRAISczdj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/8zANdiZlORNk2jRZGxdpKTUNvYWubVrnmz501k5zXNHjZ35v2i", + "NqCd2AIJgDezr84Awgny2tNmI/qTzZxPmKA2JlkXlv8QGg+THIq6jm1XmXTNnO5fLAHRN+msA4rfhBZk", + "M0lzUAjICmLBE3RvLw+5McO70n0/gFtznPY9mm++DVK1LQnjBKdztQbRj3bwEN21fbeZf6gdH+fPP9Vr", + "LRsPTydyYVpPpmV8DbrLxd7+t102LmuCxsS42jRMGZXTXJRcGwPYMZvllptQoM3sVGheVTBrfuZm7qx6", + "3rIsM2DPOL7qmfDENnuLTHuCuVO7YAomtEwnA7C8u9/LUxsRsDOhSdKCsSewTZfJR2/hUS06JCjIpxmm", + "zYN9bcLLYwlU1XJ7UzwycFimZBjgV6cv+2/+H2cvm7yi1sQtSzreu7e7/3UID7Hlg+DwRxy7T/WBM4yd", + "OpZMMeeQ5sD1IV/oOePpfn+amYq7wKYpydCByNeESkkXJGU3wAlVhJKpuKu3AKo4Q1wcGfl/+vmnn4lF", + "Y1fat+JucM3dJ35U472yzD8W4am6njBelDoon7gdS1AiKxHUTGOCjTtC6UXBYoxKXKxRUki4YaJU5kfC", + "YuzNdOVXozarwrjYu/t49yN59fEfP/5j/8036JLnhydeJnliKB8hm3+5VW9eZiaK1fVElLpR5BI8ODK5", + "dQmjVoN2VpHVruDcJOBmQLstSPMpS0ujTKt661ZqRMRMAzd/JmWM+36gNciqp55TbhCH8TQDxwyeVDXn", + "5AfLeQg8uHGqjP0Ok1gImaiHiVcIxjXBnoxTDaqZQJtx2yUF5SmQX3ZHe1eVi2Dvii6BuwJibZtPwTaQ", + "oMxD88iaL2G5wUrBlT9jVbTIOytDSFCXWD8YPt3tV1EuZpVUlSE6sXA7BwkEaFyxT5gxHHn10+jn1y36", + "eYk0Nuty5uTvyFhGp5AFGDvG501G47FWc7NHGE9YjPqnpimkUpQ8qVqb+X7XazKl8bXbpM+uJbtkQzwT", + "KdMP8BbbTZGSj00EqLnITIaD7mnHIowrbWZ9MT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DHbXU4lB77uxTbGoWow5zWEsbkBKliDye+gwinbmVY3kTo3CKaAKfBBzC1yjZ0SQ", + "UCHtukBy7+qpHshWEvuSNmWyS0Wti0afXVZL6I9JWY9hxMTi0GHx7OvnlMupTn2cVJZFlAaXVmZSbj6v", + "DM/Kh0WRLepvLL1rbJQ92i+kMEmWs1jrTdOde4eeeZ72qL3wRO3Xy25m6uGZejNDPXSGspdVXAjSfLH8", + "wCmK+YHhgsAamTluWFkcWJ2Y+9dSvUzA/xmJeah4fBP1f/H8fAM9j4aeRybHzItQF3humhvpgsjzIXQP", + "24OSjvreopfBIEvthUHI30zawM8m6XiGyG/u/3pc6NeBMYp2MnYDY7/icdXyI7jwcKqZbe2ee6+qLiWH", + "hABP8OodFYSIbvHdUph4vI0GCldfGCUGKw03gLEBjKcDDONmFiz+CGpk3ci0yJHla6QKeNZYYj0DJRnl", + "aWkgrDnK76PA8clzBX77sdhLB7vzOdQmvjfx/YTxjdHy4HjOchvCVSn6mFZXwo33hyO6uj2uKnzGr78o", + "X5LxB26be+asv0fxhcPcLynfBPom0J8u0Ovoq52b7D8i7lU/QEbRjpmh1zh6+NCpSMa1v1OAHE7qnUqv", + "Z5rW+7Vkm1OGTdj/TcIeq+j+wCGDdsLPC3Zbj7fWVp/fxf0v9+z/lFZ/G1xvAuq28o/yxCnB9P4fugGk", + "sDV+zwoVXhnhC2OF/78ibrBigxVPjxVNCD0OLKruiBalcwt0ECaqm2iblQCZLur/ZgM/idSKtJftB8O+", + "vcv2mVcHNaFNdrCJ+L9JxDv3QD8w1Es3GBQyoJBc5yL+ut74XSbKhLwTeV5yphfkA9VwSxdR9QEwVjmr", + "g52dRALNx6l9u51V3bdj0x3L6gfGP9eYVQwN2wyksN0OLdjOFDTdaeS9v7r/vwAAAP//r12GsSZ6AAA=", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/worker/worker.go b/worker/worker.go index 7ec429cf..726485a2 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -399,12 +399,15 @@ func (w *Worker) LLM(ctx context.Context, req GenLLMJSONRequestBody) (interface{ ctx, cancel := context.WithCancel(ctx) c, err := w.borrowContainer(ctx, "llm", *req.Model) if err != nil { + cancel() return nil, err } if c == nil { + cancel() return nil, errors.New("borrowed container is nil") } if c.Client == nil { + cancel() return nil, errors.New("container client is nil") } @@ -781,19 +784,21 @@ func (w *Worker) handleStreamingResponse(ctx context.Context, c *RunnerContainer default: line := scanner.Text() data := strings.TrimPrefix(line, "data: ") - + if data == "" { + continue + } if data == "[DONE]" { break } - var llmRes *LLMResponse - if err := json.Unmarshal([]byte(data), llmRes); err != nil { - slog.Error("Error unmarshaling stream data", slog.String("err", err.Error())) + var llmRes LLMResponse + if err := json.Unmarshal([]byte(data), &llmRes); err != nil { + slog.Error("Error unmarshaling stream data", slog.String("err", err.Error()), slog.String("json", data)) continue } select { - case outputChan <- llmRes: + case outputChan <- &llmRes: case <-ctx.Done(): return }