Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into SITES-20315
Browse files Browse the repository at this point in the history
  • Loading branch information
irenelagno committed May 22, 2024
2 parents 0393f44 + 3b94064 commit 5b995bd
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 121 deletions.
1 change: 1 addition & 0 deletions actions/FirefallClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class FirefallClient {
presence_penalty: 0,
n: 1,
},
store_context: true,
})
.json();

Expand Down
5 changes: 3 additions & 2 deletions scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ async function deploy() {
try {
const currentBranch = await getCurrentGitBranch();
console.log(`Current Git branch: ${currentBranch}`);
if (currentBranch === 'main') {
// If the current branch is 'main', deploy using settings from environment variables (CI/CD pipeline).
if (currentBranch === 'main' || currentBranch.startsWith('/refs/tags/')) {
// If the current branch is 'main' or a tag, deploy using settings from environment variables (CI/CD pipeline).
await deployApp();
return;
}
Expand Down Expand Up @@ -149,6 +149,7 @@ async function deploy() {
await deployApp(answers.answer);
} catch (error) {
console.error(`Error during execution: ${error.message}`);
process.exit(1);
}
}

Expand Down
7 changes: 2 additions & 5 deletions web-src/src/components/ConsentDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { useIntl } from 'react-intl';

import { intlMessages } from './App.l10n.js';
import { LegalTermsLink } from './LegalTermsLink.js';
import { sampleRUM } from '../rum.js';
import { log } from '../helpers/MetricsHelper.js';
import ConsentHero from '../assets/consent-hero.png';

Expand All @@ -46,8 +45,7 @@ export function ConsentDialog({ onConsentChange }) {
}, [setOpen]);

const handleAgree = () => {
log('consent:agree');
sampleRUM('genai:consent:agree', { source: 'ConsentDialog#handleAgree' });
log('consent:agree', { source: 'ConsentDialog#handleAgree' });
settingsApi.set({
groupId: EXC_SHELL_GROUP_ID,
level: SettingsLevel.USERORG,
Expand All @@ -59,8 +57,7 @@ export function ConsentDialog({ onConsentChange }) {
};

const handleCancel = () => {
log('consent:cancel');
sampleRUM('genai:consent:cancel', { source: 'ConsentDialog#handleCancel' });
log('consent:cancel', { source: 'ConsentDialog#handleCancel' });
setOpen(false);
onConsentChange(false);
};
Expand Down
4 changes: 1 addition & 3 deletions web-src/src/components/FavoriteVariantCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { useApplicationContext } from './ApplicationProvider.js';
import { useShellContext } from './ShellProvider.js';
import { toHTML, toText } from '../helpers/PromptExporter.js';
import { generateImagePrompt } from '../helpers/ImageHelper.js';
import { sampleRUM } from '../rum.js';
import { VariantImagesView } from './VariantImagesView.js';
import { log } from '../helpers/MetricsHelper.js';
import ExpressNoAccessInfo from './ExpressNoAccessInfo.js';
Expand Down Expand Up @@ -136,8 +135,7 @@ export function FavoriteVariantCard({
isQuiet
UNSAFE_className="hover-cursor-pointer"
onPress={() => {
log('prompt:copyfavorite');
sampleRUM('genai:prompt:copyfavorite', { source: 'FavoriteCard#onPress' });
log('prompt:copyfavorite', { source: 'FavoriteCard#onPress' });
navigator.clipboard.writeText(toText(variant.content));
ToastQueue.positive(
formatMessage(intlMessages.favoritesView.copyTextSuccessToast),
Expand Down
7 changes: 2 additions & 5 deletions web-src/src/components/GenerateButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { LegalTermsLink } from './LegalTermsLink.js';
import { useSaveResults } from '../state/SaveResultsHook.js';
import { createVariants } from '../helpers/ResultsParser.js';
import { log } from '../helpers/MetricsHelper.js';
import { sampleRUM } from '../rum.js';
import { contentFragmentState } from '../state/ContentFragmentState.js';
import { RUN_MODE_CF } from '../state/RunMode.js';
import { FIREFALL_ACTION_TYPES } from '../services/FirefallService.js';
Expand Down Expand Up @@ -121,17 +120,15 @@ export function GenerateButton() {
if (runMode !== RUN_MODE_CF) {
await saveResults();
}
log('prompt:generate:variations:generated', { variations: variants.length, queryId });
sampleRUM('genai:prompt:generatedvariations', { source: 'GenerateButton#generateResults', target: variants.length });
log('prompt:generate:variations:generated', { source: 'GenerateButton#generateResults', variations: variants.length, queryId });
} catch (error) {
console.error(error);
throw error;
}
}, [firefallService, prompt, parameters, temperature]);

const handleGenerate = useCallback(() => {
log('prompt:generate');
sampleRUM('genai:prompt:generate', { source: 'GenerateButton#handleGenerate' });
log('prompt:generate', { source: 'GenerateButton#handleGenerate' });
setGenerationInProgress(true);
setIsOpenPromptEditor(false);

Expand Down
24 changes: 15 additions & 9 deletions web-src/src/components/MainSidePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/
import {
Flex, Grid, Image, Link, Text, ActionButton, TooltipTrigger, Tooltip, Heading, Item,
Flex, Grid, Image, Link, Text, ActionButton, TooltipTrigger, Tooltip, Heading,
} from '@adobe/react-spectrum';
import React, { useCallback } from 'react';
import ShowMenu from '@spectrum-icons/workflow/ShowMenu';
Expand Down Expand Up @@ -205,14 +205,20 @@ export function MainSidePanel(props) {
&& sessions.toReversed().map((session) => {
const sessionDate = new Date(session.name);
const groupingLabel = groupingLabelGenerator(sessionDate);

return (<Item key={sessionDate}>
{groupingLabel && <Text UNSAFE_className={style.subMenuHeader}>{groupingLabel}</Text>}
{/* eslint-disable-next-line max-len */}
<li className={currentSession && viewType === ViewType.CurrentSession && session && session.id === currentSession.id ? derivedStyles.clickedSubMenuItem : style.subMenuItem} key={session.id}>
<Link href="#" UNSAFE_className={style.menuItemLink} onPress={() => handleRecent(session)}>{session.name}</Link>
</li>
</Item>);
return (
<>
{groupingLabel
&& <Text key={groupingLabel} UNSAFE_className={style.subMenuHeader}>
{groupingLabel}
</Text>}
{/* eslint-disable-next-line max-len */}
<li className={currentSession && viewType === ViewType.CurrentSession && session && session.id === currentSession.id ? derivedStyles.clickedSubMenuItem : style.subMenuItem}
key={session.id}>
<Link href="#" UNSAFE_className={style.menuItemLink}
onPress={() => handleRecent(session)}>{session.name}</Link>
</li>
</>
);
})}
</ul>
</Flex>
Expand Down
30 changes: 13 additions & 17 deletions web-src/src/components/PromptResultCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import { parametersState } from '../state/ParametersState.js';
import { resultsState } from '../state/ResultsState.js';
import { useSaveResults } from '../state/SaveResultsHook.js';
import { useVariantImages } from '../state/VariantImagesHook.js';
import { sampleRUM } from '../rum.js';
import { log } from '../helpers/MetricsHelper.js';
import { toHTML, toText } from '../helpers/PromptExporter.js';
import { generateImagePrompt } from '../helpers/ImageHelper.js';
Expand Down Expand Up @@ -348,18 +347,17 @@ export function PromptResultCard({ result, ...props }) {
}
<TooltipTrigger delay={0}>
<ActionButton
isQuiet
UNSAFE_className="hover-cursor-pointer"
onPress={() => {
log('prompt:copy', { variant: selectedVariant.id });
sampleRUM('genai:prompt:copy', { source: 'ResultCard#onPress' });
navigator.clipboard.writeText(toText(selectedVariant.content));
ToastQueue.positive(
formatMessage(intlMessages.promptResultCard.copyTextSuccessToast),
{ timeout: 1000 },
);
}}>
<CopyOutlineIcon/>
isQuiet
UNSAFE_className="hover-cursor-pointer"
onPress={() => {
log('prompt:copy', { source: 'ResultCard#onPress', variant: selectedVariant.id });
navigator.clipboard.writeText(toText(selectedVariant.content));
ToastQueue.positive(
formatMessage(intlMessages.promptResultCard.copyTextSuccessToast),
{ timeout: 1000 },
);
}}>
<CopyOutlineIcon />
</ActionButton>
<Tooltip>{formatMessage(intlMessages.promptResultCard.copyButtonTooltip)}</Tooltip>
</TooltipTrigger>
Expand Down Expand Up @@ -404,8 +402,7 @@ export function PromptResultCard({ result, ...props }) {
isDisabled={isFeedback(selectedVariant)}
UNSAFE_className="hover-cursor-pointer"
onPress={() => {
log('prompt:thumbsup', { variant: selectedVariant.id });
sampleRUM('genai:prompt:thumbsup', { source: 'ResultCard#onPress' });
log('prompt:thumbsup', { source: 'ResultCard#onPress', variant: selectedVariant.id });
sendFeedback(true, selectedVariant);
}}>
{isFeedback(selectedVariant) ? <ThumbsUpDisabledIcon /> : <ThumbsUpOutlineIcon />}
Expand All @@ -418,8 +415,7 @@ export function PromptResultCard({ result, ...props }) {
isDisabled={isFeedback(selectedVariant)}
UNSAFE_className="hover-cursor-pointer"
onPress={() => {
log('prompt:thumbsdown', { variant: selectedVariant.id });
sampleRUM('genai:prompt:thumbsdown', { source: 'ResultCard#onPress' });
log('prompt:thumbsdown', { source: 'ResultCard#onPress', variant: selectedVariant.id });
sendFeedback(false, selectedVariant);
}}>
{isFeedback(selectedVariant) ? <ThumbsDownDisabledIcon /> : <ThumbsDownOutlineIcon />}
Expand Down
5 changes: 2 additions & 3 deletions web-src/src/components/PromptTemplatesView.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { sessionState } from '../state/SessionState.js';
import { ViewType, viewTypeState } from '../state/ViewType.js';
import { lastUsedPromptTemplateIdState } from '../state/LastUsedPromptTemplateIdState.js';
import { log } from '../helpers/MetricsHelper.js';
import { sampleRUM } from '../rum.js';
import { formatTimestamp } from '../helpers/FormatHelper.js';
import { useApplicationContext } from './ApplicationProvider.js';

Expand Down Expand Up @@ -67,10 +66,10 @@ export function PromptTemplatesView() {
label,
});
if (id === NEW_PROMPT_TEMPLATE_ID) {
sampleRUM('genai:prompt:new', { source: 'HomePanel#handleSelect' });
log('prompt:new', { source: 'HomePanel#handleSelect' });
} else {
const promptType = isBundled ? 'isadobeselected' : 'iscustomselected';
sampleRUM(`genai:prompt:${promptType}`, { source: 'HomePanel#handleSelect' });
log(`prompt:${promptType}`, { source: 'HomePanel#handleSelect' });
}
setCurrentSession(createNewSession(label, description, template));
setViewType(ViewType.CurrentSession);
Expand Down
1 change: 1 addition & 0 deletions web-src/src/components/SavePromptButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export function SavePromptButton(props) {
template: prompt,
modes: [runMode],
isShared,
isBundled: false,
created: new Date().getTime(),
lastModified: new Date().getTime(),
createdBy: name,
Expand Down
4 changes: 2 additions & 2 deletions web-src/src/helpers/Parser.generated.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ var grammar = {
{"name": "string$ebnf$1", "symbols": [/[a-zA-Z0-9\-_?:.,']/]},
{"name": "string$ebnf$1", "symbols": ["string$ebnf$1", /[a-zA-Z0-9\-_?:.,']/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
{"name": "string", "symbols": ["string$ebnf$1"], "postprocess": ([string]) => string.join('')},
{"name": "quotedString$ebnf$1", "symbols": [/[a-zA-Z0-9\-_=/&?:\s.,']/]},
{"name": "quotedString$ebnf$1", "symbols": ["quotedString$ebnf$1", /[a-zA-Z0-9\-_=/&?:\s.,']/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
{"name": "quotedString$ebnf$1", "symbols": [/[^\"{}]/]},
{"name": "quotedString$ebnf$1", "symbols": ["quotedString$ebnf$1", /[^\"{}]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
{"name": "quotedString", "symbols": [{"literal":"\""}, "quotedString$ebnf$1", {"literal":"\""}], "postprocess": ([,string]) => string.join('')}
]
, ParserStart: "placeholder"
Expand Down
7 changes: 7 additions & 0 deletions web-src/src/helpers/Parser.test.js

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

2 changes: 1 addition & 1 deletion web-src/src/helpers/expressions.ne
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ parameter -> "," _ key _ "=" _ value _ {% ([, , key, , , , value]) => ({ key, va
key -> [a-zA-Z0-9_]:+ {% ([key]) => key.join('') %}
value -> string {% ([value]) => value %} | quotedString {% ([value]) => value %}
string -> [a-zA-Z0-9\-_?:.,']:+ {% ([string]) => string.join('') %}
quotedString -> "\"" [a-zA-Z0-9\-_=/&?:\s.,']:+ "\"" {% ([,string]) => string.join('') %}
quotedString -> "\"" [^\"{}]:+ "\"" {% ([,string]) => string.join('') %}
Loading

0 comments on commit 5b995bd

Please sign in to comment.