class Copyleaks::AIDetectionClient
Public Class Methods
Source
# File lib/copyleaks/ai_detection_client.rb, line 27 def initialize(api_client) @api_client = api_client end
Public Instance Methods
Source
# File lib/copyleaks/ai_detection_client.rb, line 74 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
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
-
@param [CopyleaksAuthToken] authToken Copyleaks
authentication token @param [String] scanId Attach your own scan Id @param [SourceCodeSubmissionModel] submission document
Source
# File lib/copyleaks/ai_detection_client.rb, line 41 def submit_source_code(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::SourceCodeSubmissionModel) raise 'submission is Invalid, must be instance of type Copyleaks::SourceCodeSubmissionModel' end ClientUtils.verify_auth_token(authToken) path = "/v2/writer-detector/source-code/#{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 ClientUtils.handle_response(@api_client.request(request), 'submit_source_code') end
Use Copyleaks
AI Content Detection to differentiate between human source code and AI written source code.
-
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
-
@param [CopyleaksAuthToken] authToken Copyleaks
authentication token @param [String] scanId Attach your own scan Id @param [SourceCodeSubmissionModel] submission document