FIX: Don't echo prompt back on HF/TGI (#338)

* FIX: Don't echo prompt back on HF/TGI

* teeeeests
This commit is contained in:
Rafael dos Santos Silva 2023-12-06 16:06:26 -03:00 committed by GitHub
parent d8267d8da0
commit 252efdf142
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 0 deletions

View File

@ -33,6 +33,7 @@ module DiscourseAi
token_limit = SiteSetting.ai_hugging_face_token_limit || 4_000
payload[:parameters][:max_new_tokens] = token_limit - prompt_size(prompt)
payload[:parameters][:return_full_text] = false
payload[:stream] = true if @streaming_mode
end

View File

@ -40,6 +40,7 @@ module ::DiscourseAi
parameters[:max_new_tokens] = token_limit - prompt_size
parameters[:temperature] = temperature if temperature
parameters[:repetition_penalty] = repetition_penalty if repetition_penalty
parameters[:return_full_text] = false
payload[:stream] = true if block_given?

View File

@ -18,6 +18,7 @@ RSpec.describe DiscourseAi::Completions::Endpoints::HuggingFace do
.tap do |payload|
payload[:parameters][:max_new_tokens] = (SiteSetting.ai_hugging_face_token_limit || 4_000) -
model.prompt_size(prompt)
payload[:parameters][:return_full_text] = false
end
.to_json
end
@ -29,6 +30,7 @@ RSpec.describe DiscourseAi::Completions::Endpoints::HuggingFace do
payload[:parameters][:max_new_tokens] = (SiteSetting.ai_hugging_face_token_limit || 4_000) -
model.prompt_size(prompt)
payload[:stream] = true
payload[:parameters][:return_full_text] = false
end
.to_json
end