From 06d467a2522c5ac9c5bdaba2437fcd85ad68828a Mon Sep 17 00:00:00 2001 From: samm81 Date: Thu, 1 Jun 2023 12:38:26 -0400 Subject: [PATCH] fix(completionEndpoint): limit to 1 `PromptStrings` only when `Stream` --- api/openai.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/openai.go b/api/openai.go index 1a166adb..de159053 100644 --- a/api/openai.go +++ b/api/openai.go @@ -190,10 +190,6 @@ func completionEndpoint(cm *ConfigMerger, o *Option) func(c *fiber.Ctx) error { templateFile = config.TemplateConfig.Completion } - if (len(config.PromptStrings) > 1) { - return errors.New("cannot handle more than 1 `PromptStrings`") - } - predInput := config.PromptStrings[0] // A model can have a "file.bin.tmpl" file associated with a prompt template prefix @@ -206,6 +202,10 @@ func completionEndpoint(cm *ConfigMerger, o *Option) func(c *fiber.Ctx) error { } if input.Stream { + if (len(config.PromptStrings) > 1) { + return errors.New("cannot handle more than 1 `PromptStrings` when `Stream`ing") + } + responses := make(chan OpenAIResponse) go process(predInput, input, config, o.loader, responses)