From e829b0de4e13b7edc43d3e6ba9e12f405d0d3a23 Mon Sep 17 00:00:00 2001 From: gioelecerati Date: Fri, 11 Oct 2024 20:21:17 +0200 Subject: [PATCH] llm: fix panic on missing required fields --- server/ai_mediaserver.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/ai_mediaserver.go b/server/ai_mediaserver.go index d8bca64a5..30f4b686f 100644 --- a/server/ai_mediaserver.go +++ b/server/ai_mediaserver.go @@ -416,6 +416,11 @@ func (ls *LivepeerServer) LLM() http.Handler { return } + if req.ModelId == nil || req.Prompt == "" || req.Stream == nil || req.MaxTokens == nil { + respondJsonError(ctx, w, errors.New("missing required fields"), http.StatusBadRequest) + return + } + clog.V(common.VERBOSE).Infof(ctx, "Received LLM request prompt=%v model_id=%v stream=%v", req.Prompt, *req.ModelId, *req.Stream) params := aiRequestParams{