@@ -190,9 +190,9 @@ def run
190190 document1 = Document . find_or_initialize_by ( display_name : "My Employment" , document_type : "Employment" , client : client , intake : intake )
191191 attach_upload_to_document ( document1 )
192192 document2 = Document . find_or_initialize_by ( display_name : "Identity Document" , document_type : "ID" , client : client , intake : intake )
193- attach_upload_to_document ( document2 )
193+ attach_upload_to_document ( document2 , pass_screener : false )
194194 document3 = Document . find_or_initialize_by ( display_name : "An old document type" , document_type : "F13614C / F15080 2020" , client : client , intake : intake )
195- attach_upload_to_document ( document3 )
195+ attach_upload_to_document ( document3 , pass_screener : false )
196196
197197 unless client . outgoing_text_messages . present?
198198 OutgoingTextMessage . create! ( client : client , body : "Hey client, nice to meet you" , user : user , sent_at : 3 . days . ago , to_phone_number : "+14155551212" )
@@ -771,14 +771,38 @@ def find_or_create_intake_and_client(intake_type, attributes)
771771 intake
772772 end
773773
774- def attach_upload_to_document ( document )
774+ def attach_upload_to_document ( document , pass_screener : true )
775775 document . upload . attach (
776776 io : File . open ( Rails . root . join ( "spec" , "fixtures" , "files" , "document_bundle.pdf" ) ) ,
777777 filename : "document_bundle.pdf"
778778 ) unless document . upload . present?
779779 document . save
780780
781- DocScreenerJob . perform_later ( document . id )
781+ # DocScreenerJob.perform_later(document.id)
782+ add_fake_doc_assessment ( document , pass : pass_screener ) unless document . assessments . present?
783+ end
784+
785+ def add_fake_doc_assessment ( doc , pass : true )
786+ verdict = pass ? "pass" : "fail"
787+ reason = pass ? "" : "wrong_document_type"
788+ DocAssessment . create! (
789+ document_id : doc . id ,
790+ input_blob_id : doc . upload . blob_id ,
791+ model_id : BedrockDocScreener ::MODEL_ID ,
792+ prompt_version : "v1" ,
793+ status : "complete" ,
794+ raw_response_json : { "id" => "msg_bdrk_idxxxxxx" , "role" => "assistant" , "type" => "message" , "model" => "claude-haiku-4-5-20251001" ,
795+ "usage" => { "input_tokens" => 17728 , "output_tokens" => 90 , "cache_creation" => { "ephemeral_1h_input_tokens" => 0 , "ephemeral_5m_input_tokens" => 0 } , "cache_read_input_tokens" => 0 , "cache_creation_input_tokens" => 0 } ,
796+ "content" => [ { "text" => "```json\n {\n \" verdict\" : \" #{ verdict } \" ,\n \" reason\" :#{ reason } \" \" ,\n \" explanation\" : \" This Form W-2 (Wage and Tax Statement) doc is #{ pass ? "valid" : "invalid." } .\" ,\n \" confidence\" : 0.99\n }\n ```" , "type" => "text" } ] ,
797+ "stop_reason" => "end_turn" ,
798+ "stop_sequence" => nil } ,
799+ result_json :
800+ { "reason" => reason ,
801+ "verdict" => verdict ,
802+ "confidence" => 0.99 ,
803+ "explanation" =>
804+ "This Form W-2 (Wage and Tax Statement) doc is #{ pass ? 'valid' : 'invalid.' } " } ,
805+ )
782806 end
783807
784808 def find_or_create_state_file_archived_intake ( attributes )
0 commit comments