Skip to content

Merge master (v1.18.2) into develop #1931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ jobs:
node-version: 20
cache: 'npm'
- run: npm ci
- run: npm run ${{ inputs.build_script }}
- run: npm run "$BUILD_SCRIPT"
env:
BUILD_SCRIPT: ${{ inputs.build_script }}
- name: Create build-output-US artifact
uses: actions/upload-artifact@v4
with:
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/build_i18n.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ jobs:
node-version: 20
cache: 'npm'
- run: npm ci
- run: LANGUAGE=${{ matrix.language }} CLOUD_REGION=${{ inputs.cloud_region }} npm run ${{ inputs.build_script }}
- run: LANGUAGE="$LANGUAGE" CLOUD_REGION="$CLOUD_REGION" npm run "$BUILD_SCRIPT"
env:
LANGUAGE: ${{ matrix.language }}
CLOUD_REGION: ${{ inputs.cloud_regiont }}
BUILD_SCRIPT: ${{ inputs.build_script }}
- run: |
if [ "${{ matrix.language }}" == "en" ]; then
npm run size
Expand All @@ -55,7 +59,7 @@ jobs:
with:
name: build-output-${{ inputs.cloud_region }}-${{ matrix.language }}
path: dist/

merge_multiple_artifacts:
needs: build
runs-on: ubuntu-latest
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ jobs:
aws-region: us-east-1
- name: Deploy to S3
run: |
aws s3 cp ./dist/ s3://assets.sitescdn.net/${{ inputs.bucket }}/${{ inputs.directory }} \
aws s3 cp ./dist/ s3://assets.sitescdn.net/"$BUCKET"/"$DIRECTORY" \
--acl public-read \
--recursive \
--cache-control ${{ inputs.cache-control }}
--cache-control "CACHE_CONTROL"
env:
BUCKET: ${{ inputs.bucket }}
DIRECTORY: ${{ inputs.directory }}
CACHE_CONTROL: ${{ inputs.cache-control }}
8 changes: 6 additions & 2 deletions .github/workflows/deploy_hold.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,14 @@ jobs:
aws-region: us-east-1
- name: Deploy to S3
run: |
aws s3 cp ./dist/ s3://assets.sitescdn.net/${{ inputs.bucket }}/${{ inputs.directory }} \
aws s3 cp ./dist/ s3://assets.sitescdn.net/"$BUCKET"/"$DIRECTORY" \
--acl public-read \
--recursive \
--cache-control ${{ inputs.cache-control }}
--cache-control "$CACHE_CONTROL"
env:
BUCKET: ${{ inputs.bucket }}
DIRECTORY: ${{ inputs.directory }}
CACHE_CONTROL: ${{ inputs.cache-control }}

deploy-gcp:
runs-on: ubuntu-latest
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/extract_versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ on:
default: ''
type: string
outputs:
major_version:
major_version:
value: ${{ jobs.extract_versions.outputs.major_version }}
minor_version:
minor_version:
value: ${{ jobs.extract_versions.outputs.minor_version }}
full_version:
full_version:
value: ${{ jobs.extract_versions.outputs.full_version }}

jobs:
Expand All @@ -26,12 +26,14 @@ jobs:
- name: extract major and minor version substrings
id: vars
run: |
MAJOR_VERSION="$(echo "${GITHUB_REF_NAME##${{ inputs.ignore_prefix }}}" | cut -d '.' -f 1)"
MAJOR_VERSION="$(echo "${GITHUB_REF_NAME##"$IGNORE_PREFIX"}" | cut -d '.' -f 1)"
echo "Major version: $MAJOR_VERSION"
echo major_version=${MAJOR_VERSION} >> $GITHUB_OUTPUT
MINOR_VERSION="$(echo "${GITHUB_REF_NAME##${{ inputs.ignore_prefix }}}" | cut -d '.' -f 1,2)"
MINOR_VERSION="$(echo "${GITHUB_REF_NAME##"$IGNORE_PREFIX"}" | cut -d '.' -f 1,2)"
echo "Minor version: $MINOR_VERSION"
echo minor_version=${MINOR_VERSION} >> $GITHUB_OUTPUT
FULL_VERSION="${GITHUB_REF_NAME##${{ inputs.ignore_prefix }}}"
FULL_VERSION="${GITHUB_REF_NAME##"$IGNORE_PREFIX"}"
echo "Full version: $FULL_VERSION"
echo full_version=${FULL_VERSION} >> $GITHUB_OUTPUT
env:
IGNORE_PREFIX: ${{ inputs.ignore_prefix }}}
10 changes: 6 additions & 4 deletions .github/workflows/should_deploy_major_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
default: ''
type: string
outputs:
should_deploy_major_version:
should_deploy_major_version:
value: ${{ jobs.should_deploy_major_version.outputs.should_deploy_major_version }}

jobs:
Expand All @@ -23,14 +23,16 @@ jobs:
- name: allow for major version deployment if the next minor version from current tag does not exist
id: vars
run: |
MINOR_VERSION=$(echo "${GITHUB_REF_NAME##${{ inputs.ignore_prefix }}}" | cut -d '.' -f 2)
MAJOR_VERSION=$(echo "${GITHUB_REF_NAME##${{ inputs.ignore_prefix }}}" | cut -d '.' -f 1)
MINOR_VERSION=$(echo "${GITHUB_REF_NAME##"$IGNORE_PREFIX"}" | cut -d '.' -f 2)
MAJOR_VERSION=$(echo "${GITHUB_REF_NAME##"$IGNORE_PREFIX"}" | cut -d '.' -f 1)
NEXT_MINOR_VERSION=$(( $MINOR_VERSION + 1 ))
TAGS_FOR_NEXT_MINOR=$(git tag --list "${{ inputs.ignore_prefix }}$MAJOR_VERSION.$NEXT_MINOR_VERSION.*")
TAGS_FOR_NEXT_MINOR=$(git tag --list ""$IGNORE_PREFIX"$MAJOR_VERSION.$NEXT_MINOR_VERSION.*")
if [ -z "$TAGS_FOR_NEXT_MINOR" ]
then
echo 'Major version should be deployed.'
echo should_deploy_major_version=true >> $GITHUB_OUTPUT
else
echo 'Major version should not be deployed.'
fi
env:
IGNORE_PREFIX: ${{ inputs.ignore_prefix }}}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yext/answers-search-ui",
"version": "1.18.1",
"version": "1.18.2",
"description": "Javascript Search Programming Interface",
"main": "dist/answers-umd.js",
"repository": {
Expand Down
10 changes: 8 additions & 2 deletions src/core/models/generativedirectanswer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ export default class GenerativeDirectAnswer {

const verticalKey = searcher === Searcher.UNIVERSAL ? '' : verticalResults[0].verticalKey;

const citationIds = new Set(gdaResponse.citations);
const citationsData = verticalResults
.flatMap(vr => vr.results)
.filter(result => result.rawData?.uid && result.id && result.name)
.filter(result => gdaResponse.citations.includes(result.rawData.uid))
.filter(result => {
if (!result.rawData?.uid || !result.id || !result.name || !citationIds.has(result.rawData.uid)) {
return false;
}
citationIds.delete(result.rawData.uid);
return true;
})
.map(result => {
return {
id: result.id,
Expand Down
81 changes: 81 additions & 0 deletions tests/core/models/generativedirectanswer.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,85 @@ describe('Constructs a generative direct answer from an answers-core generative

expect(actualGenerativeDirectAnswer).toMatchObject(expectedGenerativeDirectAnswer);
});

it('GDA citations on universal search are deduplicated', () => {
const coreGenerativeDirectAnswerResponse = {
directAnswer: 'This is some generated text **with bold**.',
resultStatus: 'SUCCESS',
citations: ['uuid-1']
};

const verticalResults = [
{
results: [
{
id: 'entityid-1',
rawData: {
uid: 'uuid-1',
someField: 'someValue'
},
name: 'name-1',
description: 'description-1',
otherData: 'otherData'
}
],
resultsCount: 1,
verticalKey: 'vertical-key-1'
},
{
results: [
{
id: 'entityid-1',
rawData: {
uid: 'uuid-1',
someField: 'someValue'
},
name: 'name-1',
description: 'description-1',
otherData: 'otherData'
},
{
id: 'entityid-2',
rawData: {
uid: 'uuid-2',
someField: 'someValue'
},
name: 'name-2',
description: 'description-2',
otherData: 'otherData'
}
],
resultsCount: 2,
verticalKey: 'vertical-key-2'
}
];

const directAnswerAsHTML = RichTextFormatter.format(coreGenerativeDirectAnswerResponse.directAnswer, 'gda-snippet');
const expectedGenerativeDirectAnswer = {
directAnswer: directAnswerAsHTML,
resultStatus: 'SUCCESS',
citations: ['uuid-1'],
searcher: Searcher.UNIVERSAL,
citationsData: [
{
id: 'entityid-1',
name: 'name-1',
description: 'description-1',
rawData: {
uid: 'uuid-1',
someField: 'someValue'
}
}
],
verticalKey: ''
};

const actualGenerativeDirectAnswer = GenerativeDirectAnswer.fromCore(
coreGenerativeDirectAnswerResponse,
Searcher.UNIVERSAL,
verticalResults
);

expect(actualGenerativeDirectAnswer).toMatchObject(expectedGenerativeDirectAnswer);
});
});
Loading