Class: Copyleaks::AIDetectionClient
- Inherits:
-
Object
- Object
- Copyleaks::AIDetectionClient
- Defined in:
- lib/copyleaks/ai_detection_client.rb
Instance Method Summary collapse
-
#initialize(api_client) ⇒ AIDetectionClient
constructor
A new instance of AIDetectionClient.
-
#submit_natural_language(authToken, scanId, submission) ⇒ Object
Use Copyleaks AI Content Detection to differentiate between human texts and AI written texts.
Constructor Details
#initialize(api_client) ⇒ AIDetectionClient
Returns a new instance of AIDetectionClient.
27 28 29 |
# File 'lib/copyleaks/ai_detection_client.rb', line 27 def initialize(api_client) @api_client = api_client end |
Instance Method Details
#submit_natural_language(authToken, scanId, submission) ⇒ Object
Use Copyleaks AI Content Detection to differentiate between human texts and AI written texts.
-
Exceptions:
-
CommandExceptions: Server reject the request. See response status code, headers and content for more info.
-
-
UnderMaintenanceException: Copyleaks servers are unavailable for maintenance. We recommend to implement exponential backoff algorithm as described here: api.copyleaks.com/documentation/v3/exponential-backoff
-
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/copyleaks/ai_detection_client.rb', line 41 def submit_natural_language(authToken, scanId, submission) raise 'scanId is Invalid, must be instance of String' if scanId.nil? || !scanId.instance_of?(String) if submission.nil? || !submission.instance_of?(Copyleaks::NaturalLanguageSubmissionModel) raise 'submission is Invalid, must be instance of type Copyleaks::NaturalLanguageSubmissionModel' end ClientUtils.verify_auth_token(authToken) path = "/v2/writer-detector/#{scanId}/check" headers = { 'Content-Type' => 'application/json', 'User-Agent' => Config.user_agent, 'Authorization' => "Bearer #{authToken.accessToken}" } request = Net::HTTP::Post.new(path, headers) request.body = submission.to_json res = ClientUtils.handle_response(@api_client.request(request), 'submit_natural_language') puts "RES: #{res}" res end |