diff --git a/agenta-web/src/components/Evaluations/Evaluations.tsx b/agenta-web/src/components/Evaluations/Evaluations.tsx
index 99dcddab5fe..555da6458ff 100644
--- a/agenta-web/src/components/Evaluations/Evaluations.tsx
+++ b/agenta-web/src/components/Evaluations/Evaluations.tsx
@@ -5,11 +5,9 @@ import EvaluationTable from '../EvaluationTable/EvaluationTable';
import EvaluationTableWithChat from '../EvaluationTable/EvaluationTableWithChat';
import { DownOutlined } from '@ant-design/icons';
import AppContext from '@/contexts/appContext';
-import { listVariants } from '@/services/api';
+import { listVariants, loadDatasetsList } from '@/services/api';
import { useRouter } from 'next/router';
-import dataset from './dataset-startup-ideas.json';
-
export default function Evaluations() {
const { app } = useContext(AppContext);
const router = useRouter();
@@ -23,6 +21,13 @@ export default function Evaluations() {
const [comparisonTableId, setComparisonTableId] = useState("");
const [newEvaluationEnvironment, setNewEvaluationEnvironment] = useState(false);
+ const breadcrumbItems = [
+ { title: 'Home' },
+ { title: {app} },
+ { title: Evaluations }
+ ];
+
+ const { datasets, isDatasetsLoading, isDatasetsLoadingError } = loadDatasetsList();
useEffect(() => {
if (app == "") {
@@ -30,13 +35,6 @@ export default function Evaluations() {
}
}, [app]);
-
- const breadcrumbItems = [
- { title: 'Home' },
- { title: {app} },
- { title: Evaluations }
- ];
-
useEffect(() => {
if (variants && Array.isArray(variants) && variants.length > 0) {
const appVariantsFromResponse = variants.map((item: any, index: number) => ({
@@ -44,16 +42,15 @@ export default function Evaluations() {
name: item.variant_name,
endpoint: item.variant_name
}));
-
setAppVariants(appVariantsFromResponse);
-
}
-
}, []);
useEffect(() => {
- loadDatasetsList();
- }, []);
+ if (!isDatasetsLoadingError && datasets) {
+ setDatasetsList(datasets);
+ }
+ }, [datasets, isDatasetsLoadingError]);
useEffect(() => {
if (newEvaluationEnvironment) {
@@ -62,7 +59,6 @@ export default function Evaluations() {
}
}, [newEvaluationEnvironment]);
-
const { variants, isLoading, isError } = listVariants(app);
if (isError) return
failed to load list of variants
if (isLoading) return loading variants
@@ -128,19 +124,6 @@ export default function Evaluations() {
loadDataset()
};
- const loadDatasetsList = () => {
- fetch('http://localhost/api/datasets', {
- headers: {
- "Content-Type": "application/json",
- }
- })
- .then((res) => res.json())
- .then((data) => {
- console.log(data)
- setDatasetsList(data);
- });
- };
-
const loadDataset = () => {
fetch(`http://localhost/api/datasets/${selectedDataset._id}`, {
headers: {
diff --git a/agenta-web/src/components/Evaluations/dataset-startup-ideas.json b/agenta-web/src/components/Evaluations/dataset-startup-ideas.json
deleted file mode 100644
index 982511205bb..00000000000
--- a/agenta-web/src/components/Evaluations/dataset-startup-ideas.json
+++ /dev/null
@@ -1,42 +0,0 @@
-[
- {
- "startup_name": "FoodieFinder",
- "startup_idea": "An app for discovering local, unique dining experiences."
- },
- {
- "startup_name": "CodeCove",
- "startup_idea": "Online peer-to-peer coding mentorship platform."
- },
- {
- "startup_name": "EcoMovers",
- "startup_idea": "A sustainable logistics company using electric vehicles."
- },
- {
- "startup_name": "PetNet",
- "startup_idea": "A social network for pet owners to share tips and arrange meetups."
- },
- {
- "startup_name": "HealthTrack",
- "startup_idea": "AI-powered health and fitness app that provides personalized workout and nutrition plans."
- },
- {
- "startup_name": "StudyBuddy",
- "startup_idea": "AI-based platform that offers personalized learning paths for students."
- },
- {
- "startup_name": "GreenGrow",
- "startup_idea": "Subscription service for urban gardeners providing seeds, soil, and tips."
- },
- {
- "startup_name": "SpaceSaver",
- "startup_idea": "A marketplace to rent unused storage spaces in private homes."
- },
- {
- "startup_name": "ChefAR",
- "startup_idea": "An augmented reality cooking app that offers real-time culinary assistance."
- },
- {
- "startup_name": "SkillBridge",
- "startup_idea": "Online platform connecting freelancers with local businesses."
- }
-]
\ No newline at end of file
diff --git a/agenta-web/src/services/api.ts b/agenta-web/src/services/api.ts
index 253bb4810ed..7d828529626 100644
--- a/agenta-web/src/services/api.ts
+++ b/agenta-web/src/services/api.ts
@@ -17,10 +17,10 @@ export function listVariants(app_name: string) {
/**
* This function runs a variant and returns the result. It calls the right api endpoint.
- * and take care of specifying the right parameters if needed.
- * @param app_name
- * @param variantName
- * @param inputs
+ * and take care of specifying the right parameters if needed.
+ * @param app_name
+ * @param variantName
+ * @param inputs
* @returns - the result of the variant as a json object
*/
export function runVariant(appName: string, variantName: string, inputs: any) {
@@ -35,9 +35,9 @@ export function runVariant(appName: string, variantName: string, inputs: any) {
/**
* Parses the openapi.json from a variant and returns the parameters as an array of objects.
- * @param app
- * @param variantName
- * @returns
+ * @param app
+ * @param variantName
+ * @returns
*/
export const fetchVariantParameters = async (app: string, variantName: string) => {
try {
@@ -48,4 +48,17 @@ export const fetchVariantParameters = async (app: string, variantName: string) =
} catch (error) {
throw error;
}
+};
+
+/**
+ * Loads the list of datasets
+ * @returns
+ */
+export const loadDatasetsList = () => {
+ const { data, error } = useSWR(`${API_BASE_URL}/api/datasets`, fetcher)
+ return {
+ datasets: data,
+ isDatasetsLoading: !error && !data,
+ isDatasetsLoadingError: error
+ }
};
\ No newline at end of file