mirror of
				https://github.com/discourse/discourse-ai.git
				synced 2025-10-31 14:38:37 +00:00 
			
		
		
		
	fix lint
This commit is contained in:
		
							parent
							
								
									6cf411ec90
								
							
						
					
					
						commit
						f572a7cc2c
					
				| @ -25,7 +25,7 @@ module ::DiscourseAI | |||||||
|                 "#{SiteSetting.ai_sentiment_inference_service_api_endpoint}/api/v1/classify", |                 "#{SiteSetting.ai_sentiment_inference_service_api_endpoint}/api/v1/classify", | ||||||
|                 model, |                 model, | ||||||
|                 content, |                 content, | ||||||
|                 SiteSetting.ai_sentiment_inference_service_api_key |                 SiteSetting.ai_sentiment_inference_service_api_key, | ||||||
|               ) |               ) | ||||||
| 
 | 
 | ||||||
|             store_classification(model, classification) |             store_classification(model, classification) | ||||||
|  | |||||||
| @ -26,7 +26,7 @@ module ::DiscourseAI | |||||||
|             "#{SiteSetting.ai_toxicity_inference_service_api_endpoint}/api/v1/classify", |             "#{SiteSetting.ai_toxicity_inference_service_api_endpoint}/api/v1/classify", | ||||||
|             SiteSetting.ai_toxicity_inference_service_api_model, |             SiteSetting.ai_toxicity_inference_service_api_model, | ||||||
|             content, |             content, | ||||||
|             SiteSetting.ai_toxicity_inference_service_api_key |             SiteSetting.ai_toxicity_inference_service_api_key, | ||||||
|           ) |           ) | ||||||
|         store_classification |         store_classification | ||||||
|         consider_flagging |         consider_flagging | ||||||
|  | |||||||
| @ -3,22 +3,11 @@ | |||||||
| module ::DiscourseAI | module ::DiscourseAI | ||||||
|   class InferenceManager |   class InferenceManager | ||||||
|     def self.perform!(endpoint, model, content, api_key) |     def self.perform!(endpoint, model, content, api_key) | ||||||
|  |       headers = { "Referer" => Discourse.base_url, "Content-Type" => "application/json" } | ||||||
| 
 | 
 | ||||||
|       headers = { |       headers["X-API-KEY"] = api_key if api_key.present? | ||||||
|         "Referer" => Discourse.base_url, |  | ||||||
|         "Content-Type" => "application/json", |  | ||||||
|       } |  | ||||||
| 
 | 
 | ||||||
|       if api_key.present? |       response = Faraday.post(endpoint, { model: model, content: content }.to_json, headers) | ||||||
|         headers["X-API-KEY"] = api_key |  | ||||||
|       end |  | ||||||
| 
 |  | ||||||
|       response = |  | ||||||
|         Faraday.post( |  | ||||||
|           endpoint, |  | ||||||
|           { model: model, content: content }.to_json, |  | ||||||
|           headers, |  | ||||||
|         ) |  | ||||||
| 
 | 
 | ||||||
|       raise Net::HTTPBadResponse unless response.status == 200 |       raise Net::HTTPBadResponse unless response.status == 200 | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user