This commit is contained in:
Rafael dos Santos Silva 2023-02-22 20:48:51 -03:00
parent 6cf411ec90
commit f572a7cc2c
No known key found for this signature in database
GPG Key ID: 5E50360227B34938
3 changed files with 5 additions and 16 deletions

View File

@ -25,7 +25,7 @@ module ::DiscourseAI
"#{SiteSetting.ai_sentiment_inference_service_api_endpoint}/api/v1/classify",
model,
content,
SiteSetting.ai_sentiment_inference_service_api_key
SiteSetting.ai_sentiment_inference_service_api_key,
)
store_classification(model, classification)

View File

@ -26,7 +26,7 @@ module ::DiscourseAI
"#{SiteSetting.ai_toxicity_inference_service_api_endpoint}/api/v1/classify",
SiteSetting.ai_toxicity_inference_service_api_model,
content,
SiteSetting.ai_toxicity_inference_service_api_key
SiteSetting.ai_toxicity_inference_service_api_key,
)
store_classification
consider_flagging

View File

@ -3,22 +3,11 @@
module ::DiscourseAI
class InferenceManager
def self.perform!(endpoint, model, content, api_key)
headers = { "Referer" => Discourse.base_url, "Content-Type" => "application/json" }
headers = {
"Referer" => Discourse.base_url,
"Content-Type" => "application/json",
}
headers["X-API-KEY"] = api_key if api_key.present?
if api_key.present?
headers["X-API-KEY"] = api_key
end
response =
Faraday.post(
endpoint,
{ model: model, content: content }.to_json,
headers,
)
response = Faraday.post(endpoint, { model: model, content: content }.to_json, headers)
raise Net::HTTPBadResponse unless response.status == 200