Skip to content

Commit

Permalink
Merge pull request #1843 from usdoj/release-8.2.0
Browse files Browse the repository at this point in the history
Release 8.2.0
  • Loading branch information
ameshkin authored Jan 11, 2024
2 parents f25c304 + 83d2972 commit f9caa79
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-to-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
bundle install
- name: Run tests
run: |
NODE_ENV=production make test
NODE_ENV=production make build
# Install SSH Key
- name: Install SSH key
uses: webfactory/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-to-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
run: |
npm i
bundle install
- name: Run tests
- name: Run build
run: |
NODE_ENV=production make test
NODE_ENV=production make build
# Install SSH Key
- name: Install SSH key
uses: webfactory/[email protected]
Expand Down
34 changes: 19 additions & 15 deletions js/stores/wizard_store.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { create } from 'zustand';
import { shallow } from 'zustand/shallow';
import { fetchWizardInitData, fetchWizardPredictions } from '../util/wizard_api';
import {
convertSomeLinksToCards, normalizeScore, scanForTriggers, urlParams,
convertSomeLinksToCards, normalizeScore, scanForTriggers,
} from '../util/wizard_helpers';
import searchMatchingAgency from '../util/wizard_agency_search';
import allTopics from '../models/wizard_topics';
Expand All @@ -18,12 +18,11 @@ import { defaultSummary, stateLocalSummary, stateOrLocalFlow } from '../models/w
import agencyComponentStore from './agency_component';

const DEBUG_TO_CONSOLE = true;
const DEFAULT_CONFIDENCE_THRESHOLD = Number(
urlParams().get('confidence-threshold') || 0.5,
);

const CONFIDENCE_THRESHOLD_AGENCIES = DEFAULT_CONFIDENCE_THRESHOLD;
const CONFIDENCE_THRESHOLD_LINKS = DEFAULT_CONFIDENCE_THRESHOLD;
const THRESHOLDS = {
missionMatch: 0.7,
agencyFinder: 0.2,
freqdoc: 0.65,
};

/** @type {WizardVars} */
const initialWizardState = {
Expand Down Expand Up @@ -290,14 +289,17 @@ const useRawWizardStore = create((
set({ modelLoading: true });
await fetchWizardPredictions(query)
.then((data) => {
// Support both V1.1 and V1.0 API output.
const modelOutput = data.model_output || data;

if (triggerMatch) {
log('Collecting model results in case user chooses to switch to them.');
} else if (trustAgencyMatch) {
log('An agency match was most of user\'s query: Skipping intent model.');
} else {
// If a predefined flow is found, we switch to it, but we'll go ahead and populate
// the links and agencies anyway.
let { flow } = data.model_output.predefined_flow || {};
let { flow } = modelOutput.predefined_flow || {};
if (typeof flow === 'string') {
if (flow === stateOrLocalFlow) {
log('Moving user to state/local summary page due to intent model result.');
Expand Down Expand Up @@ -330,7 +332,7 @@ const useRawWizardStore = create((

// If name match, always include it.
recommendedAgencies.push(
...(data.model_output.agency_name_match || [])
...(modelOutput.agency_name_match || [])
.map((agency) => {
// Show near top.
agency.confidence_score = 9999;
Expand All @@ -339,18 +341,20 @@ const useRawWizardStore = create((
}),
);

log('Using thresholds', THRESHOLDS);

// Match from mission if above threshold.
recommendedAgencies.push(
...data.model_output.agency_mission_match
...modelOutput.agency_mission_match
.map(normalizeScore)
.filter((agency) => (agency.confidence_score >= CONFIDENCE_THRESHOLD_AGENCIES)),
.filter((agency) => (agency.confidence_score >= THRESHOLDS.missionMatch)),
);

// Match from finder if above threshold.
recommendedAgencies.push(
...data.model_output.agency_finder_predictions[0]
...modelOutput.agency_finder_predictions[0]
.map(normalizeScore)
.filter((agency) => (agency.confidence_score >= CONFIDENCE_THRESHOLD_AGENCIES)),
.filter((agency) => (agency.confidence_score >= THRESHOLDS.agencyFinder)),
);

// DESC score order
Expand All @@ -366,9 +370,9 @@ const useRawWizardStore = create((
return true;
});

recommendedLinks = data.model_output.freqdoc_predictions
recommendedLinks = modelOutput.freqdoc_predictions
.map(normalizeScore)
.filter((link) => link.confidence_score >= CONFIDENCE_THRESHOLD_LINKS);
.filter((link) => link.confidence_score >= THRESHOLDS.freqdoc);
})
.catch((err) => {
console.error(err);
Expand Down

0 comments on commit f9caa79

Please sign in to comment.