Skip to content

Commit ce904f2

Browse files
committed
Add seeder values
1 parent 2cd0744 commit ce904f2

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

app/lib/seeder.rb

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

app/services/bedrock_doc_screener.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def self.prompt_for(document_type:)
4646
{
4747
"verdict": "pass" | "fail",
4848
"reason": "unreadable" | "no_doc_type_match" | "wrong_document_type" | expired" | "fake" | "other",
49-
"explanation": [Brief 1-2 sentence explanation of reason. Explain why valid/invalid.],
49+
"explanation": [Brief 1-2 sentence explanation of reason. Explain why invalid if so. The briefer the better, please do not be redundant.],
5050
"confidence": number between 0.0-1.0,
5151
}
5252
PROMPT

0 commit comments

Comments
 (0)