Skip to content

Commit 863f9c7

Browse files
committed
configured shuffle for example list
1 parent ebf63b4 commit 863f9c7

File tree

2 files changed

+70
-12
lines changed

2 files changed

+70
-12
lines changed

app/frontend/src/components/Example/ExampleList.tsx

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,51 @@
1+
import { useEffect, useState } from "react";
12
import { Example } from "./Example";
2-
3+
import { DEFAULT_EXAMPLES, GPT4V_EXAMPLES } from "../../i18n/examples.js";
34
import styles from "./Example.module.css";
45

5-
const DEFAULT_EXAMPLES: string[] = [
6-
"What is Sanlam's IT Strategy?",
7-
"How was Retail Affluent's performance in 2023?",
8-
"What savings products does Sanlam sell?"
9-
];
6+
// const DEFAULT_EXAMPLES: string[] = [
7+
// "What is Sanlam's IT Strategy?",
8+
// "How was Retail Affluent's performance in 2023?",
9+
// "What savings products does Sanlam sell?"
10+
// ];
11+
12+
// const GPT4V_EXAMPLES: string[] = [
13+
// "Compare the impact of interest rates and GDP in financial markets.",
14+
// "What is the expected trend for the S&P 500 index over the next five years? Compare it to the past S&P 500 performance",
15+
// "Can you identify any correlation between oil prices and stock market trends?"
16+
// ];
1017

11-
const GPT4V_EXAMPLES: string[] = [
12-
"Compare the impact of interest rates and GDP in financial markets.",
13-
"What is the expected trend for the S&P 500 index over the next five years? Compare it to the past S&P 500 performance",
14-
"Can you identify any correlation between oil prices and stock market trends?"
15-
];
18+
const shuffleArray = (array: string[]) => {
19+
for (let i = array.length - 1; i > 0; i--) {
20+
const j = Math.floor(Math.random() * (i + 1));
21+
[array[i], array[j]] = [array[j], array[i]];
22+
}
23+
return array;
24+
};
1625

1726
interface Props {
1827
onExampleClicked: (value: string) => void;
1928
useGPT4V?: boolean;
2029
}
2130

2231
export const ExampleList = ({ onExampleClicked, useGPT4V }: Props) => {
32+
const [currentExamples, setCurrentExamples] = useState<string[]>([]);
33+
34+
useEffect(() => {
35+
const loadExamples = () => {
36+
const examples = useGPT4V ? GPT4V_EXAMPLES : DEFAULT_EXAMPLES;
37+
setCurrentExamples(shuffleArray(examples).slice(0, 3));
38+
};
39+
40+
loadExamples();
41+
const intervalId = setInterval(loadExamples, 7000); // Replaced workerSetInterval
42+
43+
return () => clearInterval(intervalId); // Replaced workerClearInterval
44+
}, [useGPT4V]);
45+
2346
return (
2447
<ul className={styles.examplesNavList}>
25-
{(useGPT4V ? GPT4V_EXAMPLES : DEFAULT_EXAMPLES).map((question, i) => (
48+
{currentExamples.map((question, i) => (
2649
<li key={i}>
2750
<Example text={question} value={question} onClick={onExampleClicked} />
2851
</li>

app/frontend/src/i18n/examples.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
export const DEFAULT_EXAMPLES = [
2+
"What is Sanlam's IT Strategy?",
3+
"How was Retail Affluent's performance in 2023?",
4+
"What savings products does Sanlam sell?",
5+
"What risk products does Sanlam sell?",
6+
"What was the VNB for 2023?",
7+
"What was the VNB for 2022?",
8+
"How was Retail Affluent's performance in 2022?",
9+
"Did Sanlam meet its 2023 targets?",
10+
"What is Sanlam's target market?",
11+
"What is Sanlam's target market for savings products?",
12+
"What is Sanlam's target market for risk products?",
13+
"What is Wealth Bonus",
14+
"Which products include Wealth Bonus?",
15+
"How do I maximize my Wealth Bonus?",
16+
"How is Sanlam performing in the market?",
17+
"What is the market share of Sanlam?",
18+
"What is the market share of Sanlam in the risk market?",
19+
"What is the market share of Sanlam in the savings market?",
20+
"What is an endowment?",
21+
"What is a retirement annuity?",
22+
"What is a pension fund?",
23+
"What is two pot system?",
24+
"What is a unit trust?",
25+
"What is a tax free savings account?",
26+
"What is a living annuity?",
27+
"What is a preservation fund?",
28+
"What is a guaranteed annuity?"
29+
];
30+
31+
export const GPT4V_EXAMPLES = [
32+
"Compare the impact of interest rates and GDP in financial markets.",
33+
"What is the expected trend for the S&P 500 index over the next five years? Compare it to the past S&P 500 performance",
34+
"Can you identify any correlation between oil prices and stock market trends?"
35+
];

0 commit comments

Comments
 (0)