From 6540d4a546a3db5c54fc59fd59195ce4c85e5134 Mon Sep 17 00:00:00 2001 From: Kaosiso Ezealigo Date: Wed, 29 Nov 2023 10:31:38 +0100 Subject: [PATCH 1/5] chore: conditional to check if env var is undefined --- agenta-web/src/lib/helpers/utils.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/agenta-web/src/lib/helpers/utils.ts b/agenta-web/src/lib/helpers/utils.ts index 25442d9d20..aa206fff89 100644 --- a/agenta-web/src/lib/helpers/utils.ts +++ b/agenta-web/src/lib/helpers/utils.ts @@ -228,3 +228,13 @@ export const safeParse = (str: string, fallback: any = "") => { return fallback } } + +export const getAgentaApiUrl = () => { + const apiUrl = process.env.NEXT_PUBLIC_AGENTA_API_URL + + if (!apiUrl && typeof window !== "undefined") { + return `${window.location.protocol}//${window.location.hostname}` + } + + return apiUrl +} From e935d8561bb896ca9aaeeae81058f9ee29cdd395 Mon Sep 17 00:00:00 2001 From: Kaosiso Ezealigo Date: Wed, 29 Nov 2023 10:31:49 +0100 Subject: [PATCH 2/5] modifies url --- .../components/Evaluations/Evaluations.tsx | 4 +- .../Evaluations/HumanEvaluationResult.tsx | 8 +- agenta-web/src/lib/services/api.ts | 134 +++++++----------- .../apps/[app_id]/testsets/new/api/index.tsx | 5 +- .../[app_id]/testsets/new/endpoint/index.tsx | 9 +- .../[app_id]/testsets/new/upload/index.tsx | 13 +- 6 files changed, 72 insertions(+), 101 deletions(-) diff --git a/agenta-web/src/components/Evaluations/Evaluations.tsx b/agenta-web/src/components/Evaluations/Evaluations.tsx index ac7388d137..65a10bdac9 100644 --- a/agenta-web/src/components/Evaluations/Evaluations.tsx +++ b/agenta-web/src/components/Evaluations/Evaluations.tsx @@ -20,7 +20,7 @@ import { useLoadTestsetsList, fetchCustomEvaluations, } from "@/lib/services/api" -import {dynamicComponent, getApikeys, isDemo} from "@/lib/helpers/utils" +import {dynamicComponent, getAgentaApiUrl, getApikeys, isDemo} from "@/lib/helpers/utils" import {useRouter} from "next/router" import {Variant, Parameter, GenericObject, SingleCustomEvaluation} from "@/lib/Types" import {EvaluationType} from "@/lib/enums" @@ -357,7 +357,7 @@ export default function Evaluations() { evaluationTypeSettings.regex_pattern = "" evaluationTypeSettings.regex_should_match = true } else if (selectedEvaluationType === EvaluationType.auto_webhook_test) { - evaluationTypeSettings.webhook_url = `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/evaluations/webhook_example_fake` + evaluationTypeSettings.webhook_url = `${getAgentaApiUrl()}/api/evaluations/webhook_example_fake` } const evaluationTableId = await createNewEvaluation({ diff --git a/agenta-web/src/components/Evaluations/HumanEvaluationResult.tsx b/agenta-web/src/components/Evaluations/HumanEvaluationResult.tsx index 8cf74202de..68f6fcc625 100644 --- a/agenta-web/src/components/Evaluations/HumanEvaluationResult.tsx +++ b/agenta-web/src/components/Evaluations/HumanEvaluationResult.tsx @@ -10,7 +10,7 @@ import {createUseStyles} from "react-jss" import {formatDate} from "@/lib/helpers/dateTimeHelper" import {useAppTheme} from "../Layout/ThemeContextProvider" import {getVotesPercentage} from "@/lib/helpers/evaluate" -import {EvaluationTypeLabels, isDemo} from "@/lib/helpers/utils" +import {EvaluationTypeLabels, getAgentaApiUrl, isDemo} from "@/lib/helpers/utils" interface VariantVotesData { number_of_votes: number @@ -98,13 +98,11 @@ export default function HumanEvaluationResult() { } const fetchEvaluations = async () => { try { - fetchData( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/evaluations/?app_id=${app_id}`, - ) + fetchData(`${getAgentaApiUrl()}/api/evaluations/?app_id=${app_id}`) .then((response) => { const fetchPromises = response.map((item: EvaluationResponseType) => { return fetchData( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/evaluations/${item.id}/results/`, + `${getAgentaApiUrl()}/api/evaluations/${item.id}/results/`, ) .then((results) => { if (item.evaluation_type === EvaluationType.human_a_b_testing) { diff --git a/agenta-web/src/lib/services/api.ts b/agenta-web/src/lib/services/api.ts index cd9c11c070..781d6c3e32 100644 --- a/agenta-web/src/lib/services/api.ts +++ b/agenta-web/src/lib/services/api.ts @@ -24,7 +24,7 @@ import { fromEvaluationScenarioResponseToEvaluationScenario, } from "../transformers" import {EvaluationFlow, EvaluationType} from "../enums" -import {delay, removeKeys} from "../helpers/utils" +import {delay, getAgentaApiUrl, removeKeys} from "../helpers/utils" import {useProfileData} from "@/contexts/profile.context" /** * Raw interface for the parameters parsed from the openapi.json @@ -36,10 +36,9 @@ export async function fetchVariants( appId: string, ignoreAxiosError: boolean = false, ): Promise { - const response = await axios.get( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/apps/${appId}/variants/`, - {_ignoreError: ignoreAxiosError} as any, - ) + const response = await axios.get(`${getAgentaApiUrl()}/api/apps/${appId}/variants/`, { + _ignoreError: ignoreAxiosError, + } as any) if (response.data && Array.isArray(response.data) && response.data.length > 0) { return response.data.map((variant: Record) => { @@ -63,10 +62,9 @@ export async function fetchVariants( } export function restartAppVariantContainer(variantId: string) { - return axios.post( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/containers/restart_container/`, - {variant_id: variantId}, - ) + return axios.post(`${getAgentaApiUrl()}/api/containers/restart_container/`, { + variant_id: variantId, + }) } /** @@ -188,7 +186,7 @@ export const getAppContainerURL = async ( ): Promise => { try { // Null-check for the environment variable - if (!process.env.NEXT_PUBLIC_AGENTA_API_URL) { + if (!getAgentaApiUrl()) { throw new Error("Environment variable NEXT_PUBLIC_AGENTA_API_URL is not set.") } @@ -202,7 +200,7 @@ export const getAppContainerURL = async ( } // Retrieve container URL from backend - const url = `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/containers/container_url/` + const url = `${getAgentaApiUrl()}/api/containers/container_url/` const response = await axios.get(url, {params: {variant_id: variantId, base_id: baseId}}) if (response.status === 200 && response.data && response.data.uri) { // Cache the URL before returning @@ -226,7 +224,7 @@ export async function saveNewVariant( newConfigName: string, parameters: Parameter[], ) { - await axios.post(`${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/variants/from-base/`, { + await axios.post(`${getAgentaApiUrl()}/api/variants/from-base/`, { base_id: baseId, new_variant_name: newVariantName, new_config_name: newConfigName, @@ -237,24 +235,21 @@ export async function saveNewVariant( } export async function updateVariantParams(variantId: string, parameters: Parameter[]) { - await axios.put( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/variants/${variantId}/parameters/`, - { - parameters: parameters.reduce((acc, param) => { - return {...acc, [param.name]: param.default} - }, {}), - }, - ) + await axios.put(`${getAgentaApiUrl()}/api/variants/${variantId}/parameters/`, { + parameters: parameters.reduce((acc, param) => { + return {...acc, [param.name]: param.default} + }, {}), + }) } export async function removeApp(appId: string) { - await axios.delete(`${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/apps/${appId}/`, { + await axios.delete(`${getAgentaApiUrl()}/api/apps/${appId}/`, { data: {app_id: appId}, }) } export async function removeVariant(variantId: string) { - await axios.delete(`${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/variants/${variantId}/`) + await axios.delete(`${getAgentaApiUrl()}/api/variants/${variantId}/`) } /** @@ -263,7 +258,7 @@ export async function removeVariant(variantId: string) { */ export const useLoadTestsetsList = (appId: string) => { const {data, error, mutate, isLoading} = useSWR( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/testsets/?app_id=${appId}`, + `${getAgentaApiUrl()}/api/testsets/?app_id=${appId}`, fetcher, {revalidateOnFocus: false}, ) @@ -277,38 +272,30 @@ export const useLoadTestsetsList = (appId: string) => { } export async function createNewTestset(appId: string, testsetName: string, testsetData: any) { - const response = await axios.post( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/testsets/${appId}/`, - { - name: testsetName, - csvdata: testsetData, - }, - ) + const response = await axios.post(`${getAgentaApiUrl()}/api/testsets/${appId}/`, { + name: testsetName, + csvdata: testsetData, + }) return response } export async function updateTestset(testsetId: String, testsetName: string, testsetData: any) { - const response = await axios.put( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/testsets/${testsetId}/`, - { - name: testsetName, - csvdata: testsetData, - }, - ) + const response = await axios.put(`${getAgentaApiUrl()}/api/testsets/${testsetId}/`, { + name: testsetName, + csvdata: testsetData, + }) return response } export const loadTestset = async (testsetId: string) => { - const response = await axios.get( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/testsets/${testsetId}/`, - ) + const response = await axios.get(`${getAgentaApiUrl()}/api/testsets/${testsetId}/`) return response.data } export const deleteTestsets = async (ids: string[]) => { const response = await axios({ method: "delete", - url: `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/testsets/`, + url: `${getAgentaApiUrl()}/api/testsets/`, data: {testset_ids: ids}, }) return response.data @@ -316,7 +303,7 @@ export const deleteTestsets = async (ids: string[]) => { export const loadEvaluations = async (appId: string) => { return await axios - .get(`${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/evaluations/?app_id=${appId}`) + .get(`${getAgentaApiUrl()}/api/evaluations/?app_id=${appId}`) .then((responseData) => { const evaluations = responseData.data.map((item: EvaluationResponseType) => { return fromEvaluationResponseToEvaluation(item) @@ -328,7 +315,7 @@ export const loadEvaluations = async (appId: string) => { export const loadEvaluation = async (evaluationId: string) => { return await axios - .get(`${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/evaluations/${evaluationId}/`) + .get(`${getAgentaApiUrl()}/api/evaluations/${evaluationId}/`) .then((responseData) => { return fromEvaluationResponseToEvaluation(responseData.data) }) @@ -337,7 +324,7 @@ export const loadEvaluation = async (evaluationId: string) => { export const deleteEvaluations = async (ids: string[]) => { const response = await axios({ method: "delete", - url: `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/evaluations/`, + url: `${getAgentaApiUrl()}/api/evaluations/`, data: {evaluations_ids: ids}, }) return response.data @@ -348,9 +335,7 @@ export const loadEvaluationsScenarios = async ( evaluation: Evaluation, ) => { return await axios - .get( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/evaluations/${evaluationTableId}/evaluation_scenarios/`, - ) + .get(`${getAgentaApiUrl()}/api/evaluations/${evaluationTableId}/evaluation_scenarios/`) .then((responseData) => { const evaluationsRows = responseData.data.map((item: any) => { return fromEvaluationScenarioResponseToEvaluationScenario(item, evaluation) @@ -396,19 +381,14 @@ export const createNewEvaluation = async ( status: EvaluationFlow.EVALUATION_INITIALIZED, } - const response = await axios.post( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/evaluations/`, - data, - {_ignoreError: ignoreAxiosError} as any, - ) + const response = await axios.post(`${getAgentaApiUrl()}/api/evaluations/`, data, { + _ignoreError: ignoreAxiosError, + } as any) return response.data.id } export const updateEvaluation = async (evaluationId: string, data: GenericObject) => { - const response = await axios.put( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/evaluations/${evaluationId}/`, - data, - ) + const response = await axios.put(`${getAgentaApiUrl()}/api/evaluations/${evaluationId}/`, data) return response.data } @@ -419,7 +399,7 @@ export const updateEvaluationScenario = async ( evaluationType: EvaluationType, ) => { const response = await axios.put( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/evaluations/${evaluationTableId}/evaluation_scenario/${evaluationScenarioId}/${evaluationType}/`, + `${getAgentaApiUrl()}/api/evaluations/${evaluationTableId}/evaluation_scenario/${evaluationScenarioId}/${evaluationType}/`, data, ) return response.data @@ -427,7 +407,7 @@ export const updateEvaluationScenario = async ( export const postEvaluationScenario = async (evaluationTableId: string, data: GenericObject) => { const response = await axios.post( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/evaluations/${evaluationTableId}/evaluation_scenario/`, + `${getAgentaApiUrl()}/api/evaluations/${evaluationTableId}/evaluation_scenario/`, data, ) return response.data @@ -438,7 +418,7 @@ export const evaluateAICritiqueForEvalScenario = async ( ignoreAxiosError: boolean = false, ) => { const response = await axios.post( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/evaluations/evaluation_scenario/ai_critique/`, + `${getAgentaApiUrl()}/api/evaluations/evaluation_scenario/ai_critique/`, data, {_ignoreError: ignoreAxiosError} as any, ) @@ -447,14 +427,14 @@ export const evaluateAICritiqueForEvalScenario = async ( export const fetchEvaluationResults = async (evaluationId: string) => { const response = await axios.get( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/evaluations/${evaluationId}/results/`, + `${getAgentaApiUrl()}/api/evaluations/${evaluationId}/results/`, ) return response.data } export const fetchEvaluationScenarioResults = async (evaluation_scenario_id: string) => { const response = await axios.get( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/evaluations/evaluation_scenario/${evaluation_scenario_id}/score/`, + `${getAgentaApiUrl()}/api/evaluations/evaluation_scenario/${evaluation_scenario_id}/score/`, ) return response } @@ -464,7 +444,7 @@ export const saveCustomCodeEvaluation = async ( ignoreAxiosError: boolean = false, ) => { const response = await axios.post( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/evaluations/custom_evaluation/`, + `${getAgentaApiUrl()}/api/evaluations/custom_evaluation/`, payload, {_ignoreError: ignoreAxiosError} as any, ) @@ -477,7 +457,7 @@ export const editCustomEvaluationDetail = async ( ignoreAxiosError: boolean = false, ) => { const response = await axios.put( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/evaluations/custom_evaluation/${id}`, + `${getAgentaApiUrl()}/api/evaluations/custom_evaluation/${id}`, payload, {_ignoreError: ignoreAxiosError} as any, ) @@ -486,7 +466,7 @@ export const editCustomEvaluationDetail = async ( export const fetchCustomEvaluations = async (app_id: string, ignoreAxiosError: boolean = false) => { const response = await axios.get( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/evaluations/custom_evaluation/list/${app_id}/`, + `${getAgentaApiUrl()}/api/evaluations/custom_evaluation/list/${app_id}/`, {_ignoreError: ignoreAxiosError} as any, ) return response @@ -497,7 +477,7 @@ export const fetchCustomEvaluationDetail = async ( ignoreAxiosError: boolean = false, ) => { const response = await axios.get( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/evaluations/custom_evaluation/${id}/`, + `${getAgentaApiUrl()}/api/evaluations/custom_evaluation/${id}/`, {_ignoreError: ignoreAxiosError} as any, ) return response.data @@ -508,7 +488,7 @@ export const fetchCustomEvaluationNames = async ( ignoreAxiosError: boolean = false, ) => { const response = await axios.get( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/evaluations/custom_evaluation/${app_id}/names/`, + `${getAgentaApiUrl()}/api/evaluations/custom_evaluation/${app_id}/names/`, {_ignoreError: ignoreAxiosError} as any, ) return response @@ -519,7 +499,7 @@ export const executeCustomEvaluationCode = async ( ignoreAxiosError: boolean = false, ) => { const response = await axios.post( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/evaluations/custom_evaluation/execute/${payload.evaluation_id}/`, + `${getAgentaApiUrl()}/api/evaluations/custom_evaluation/execute/${payload.evaluation_id}/`, payload, {_ignoreError: ignoreAxiosError} as any, ) @@ -532,7 +512,7 @@ export const updateEvaluationScenarioScore = async ( ignoreAxiosError: boolean = false, ) => { const response = await axios.put( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/evaluations/evaluation_scenario/${evaluation_scenario_id}/score/`, + `${getAgentaApiUrl()}/api/evaluations/evaluation_scenario/${evaluation_scenario_id}/score/`, {score}, {_ignoreError: ignoreAxiosError} as any, ) @@ -542,7 +522,7 @@ export const updateEvaluationScenarioScore = async ( export const useApps = () => { const {selectedOrg} = useProfileData() const {data, error, isLoading, mutate} = useSWR( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/apps/?org_id=${selectedOrg?.id}`, + `${getAgentaApiUrl()}/api/apps/?org_id=${selectedOrg?.id}`, selectedOrg?.id ? fetcher : () => {}, //doon't fetch if org is not selected ) @@ -555,21 +535,19 @@ export const useApps = () => { } export const getProfile = async (ignoreAxiosError: boolean = false) => { - return axios.get(`${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/profile/`, { + return axios.get(`${getAgentaApiUrl()}/api/profile/`, { _ignoreError: ignoreAxiosError, } as any) } export const getOrgsList = async (ignoreAxiosError: boolean = false) => { - return axios.get(`${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/organizations/`, { + return axios.get(`${getAgentaApiUrl()}/api/organizations/`, { _ignoreError: ignoreAxiosError, } as any) } export const getTemplates = async () => { - const response = await axios.get( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/containers/templates/`, - ) + const response = await axios.get(`${getAgentaApiUrl()}/api/containers/templates/`) return response.data } @@ -578,7 +556,7 @@ export const createAppFromTemplate = async ( ignoreAxiosError: boolean = false, ) => { const response = await axios.post( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/apps/app_and_variant_from_template/`, + `${getAgentaApiUrl()}/api/apps/app_and_variant_from_template/`, templateObj, {_ignoreError: ignoreAxiosError} as any, ) @@ -685,9 +663,7 @@ export const createAndStartTemplate = async ({ } export const fetchEnvironments = async (appId: string): Promise => { - const response = await fetch( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/apps/${appId}/environments/`, - ) + const response = await fetch(`${getAgentaApiUrl()}/api/apps/${appId}/environments/`) if (response.status !== 200) { throw new Error("Failed to fetch environments") @@ -698,7 +674,7 @@ export const fetchEnvironments = async (appId: string): Promise = } export const publishVariant = async (variantId: string, environmentName: string) => { - await axios.post(`${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/environments/deploy/`, { + await axios.post(`${getAgentaApiUrl()}/api/environments/deploy/`, { environment_name: environmentName, variant_id: variantId, }) diff --git a/agenta-web/src/pages/apps/[app_id]/testsets/new/api/index.tsx b/agenta-web/src/pages/apps/[app_id]/testsets/new/api/index.tsx index 2db038e753..43c03465b1 100644 --- a/agenta-web/src/pages/apps/[app_id]/testsets/new/api/index.tsx +++ b/agenta-web/src/pages/apps/[app_id]/testsets/new/api/index.tsx @@ -10,6 +10,7 @@ import tsCodeUpload from "../../../../../../code_snippets/testsets/create_with_u import {Typography} from "antd" import {useRouter} from "next/router" import {createUseStyles} from "react-jss" +import {getAgentaApiUrl} from "@/lib/helpers/utils" const useStyles = createUseStyles({ title: { @@ -22,8 +23,8 @@ export default function NewTestsetWithAPI() { const router = useRouter() const appId = router.query.app_id as string - const uploadURI = `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/testsets/upload` - const jsonURI = `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/testsets/${appId}` + const uploadURI = `${getAgentaApiUrl()}/api/testsets/upload` + const jsonURI = `${getAgentaApiUrl()}/api/testsets/${appId}` const params = `{ "name": "testset_name",}` diff --git a/agenta-web/src/pages/apps/[app_id]/testsets/new/endpoint/index.tsx b/agenta-web/src/pages/apps/[app_id]/testsets/new/endpoint/index.tsx index 887652e6e8..673706a4d6 100644 --- a/agenta-web/src/pages/apps/[app_id]/testsets/new/endpoint/index.tsx +++ b/agenta-web/src/pages/apps/[app_id]/testsets/new/endpoint/index.tsx @@ -1,4 +1,5 @@ import axios from "@/lib/helpers/axiosConfig" +import {getAgentaApiUrl} from "@/lib/helpers/utils" import {Alert, Button, Form, Input, Spin, Typography, message} from "antd" import {useRouter} from "next/router" import {useState} from "react" @@ -47,11 +48,9 @@ export default function ImportTestsetFromEndpoint() { try { // TODO: move to api.ts - await axios.post( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/testsets/endpoint/`, - formData, - {headers: {"Content-Type": "multipart/form-data"}}, - ) + await axios.post(`${getAgentaApiUrl()}/api/testsets/endpoint/`, formData, { + headers: {"Content-Type": "multipart/form-data"}, + }) router.push(`/apps/${appId}/testsets`) } catch (_) { // Errors will be handled by Axios interceptor diff --git a/agenta-web/src/pages/apps/[app_id]/testsets/new/upload/index.tsx b/agenta-web/src/pages/apps/[app_id]/testsets/new/upload/index.tsx index 4092746fe6..0b53090c67 100644 --- a/agenta-web/src/pages/apps/[app_id]/testsets/new/upload/index.tsx +++ b/agenta-web/src/pages/apps/[app_id]/testsets/new/upload/index.tsx @@ -4,6 +4,7 @@ import {useState} from "react" import axios from "@/lib/helpers/axiosConfig" import {useRouter} from "next/router" import {createUseStyles} from "react-jss" +import {getAgentaApiUrl} from "@/lib/helpers/utils" const useStyles = createUseStyles({ fileFormatBtn: { @@ -50,15 +51,11 @@ export default function AddANewTestset() { try { setUploadLoading(true) // TODO: move to api.ts - await axios.post( - `${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/testsets/upload/`, - formData, - { - headers: { - "Content-Type": "multipart/form-data", - }, + await axios.post(`${getAgentaApiUrl()}/api/testsets/upload/`, formData, { + headers: { + "Content-Type": "multipart/form-data", }, - ) + }) form.resetFields() router.push(`/apps/${appId}/testsets`) } finally { From 930cf4eeb77e79118fd44544d35b99ac02136c0d Mon Sep 17 00:00:00 2001 From: Akrem Abayed Date: Thu, 30 Nov 2023 16:28:18 +0100 Subject: [PATCH 3/5] add on workflow dispatch to docker --- .github/workflows/docker.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 186f6e22cd..c366c4007d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,6 +1,7 @@ name: Build and Publish Docker Images -on: +on: + workflow_dispatch: push: branches: - main @@ -33,7 +34,7 @@ jobs: registry: ghcr.io username: ${{ env.REPOSITORY_USERNAME }} password: ${{ secrets.DOCKER_GITHUB_SECRETS }} - + - name: Build, tag and push Backend image to Github Container Registry id: build-backend-image run: | From eec139f3515b9ee90aeaa03d92f6f8ad458d7e51 Mon Sep 17 00:00:00 2001 From: Akrem Abayed Date: Thu, 30 Nov 2023 16:33:39 +0100 Subject: [PATCH 4/5] put back original file --- .github/workflows/docker.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c366c4007d..186f6e22cd 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,7 +1,6 @@ name: Build and Publish Docker Images -on: - workflow_dispatch: +on: push: branches: - main @@ -34,7 +33,7 @@ jobs: registry: ghcr.io username: ${{ env.REPOSITORY_USERNAME }} password: ${{ secrets.DOCKER_GITHUB_SECRETS }} - + - name: Build, tag and push Backend image to Github Container Registry id: build-backend-image run: | From 4c8dec97449a52f803d55e366b191c4d5c4241af Mon Sep 17 00:00:00 2001 From: Kaosiso Ezealigo Date: Tue, 5 Dec 2023 11:53:19 +0100 Subject: [PATCH 5/5] format fix --- .../apps/[app_id]/testsets/new/upload/index.tsx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/agenta-web/src/pages/apps/[app_id]/testsets/new/upload/index.tsx b/agenta-web/src/pages/apps/[app_id]/testsets/new/upload/index.tsx index 3bde8435dc..29f7c47337 100644 --- a/agenta-web/src/pages/apps/[app_id]/testsets/new/upload/index.tsx +++ b/agenta-web/src/pages/apps/[app_id]/testsets/new/upload/index.tsx @@ -59,17 +59,13 @@ export default function AddANewTestset() { try { setUploadLoading(true) // TODO: move to api.ts - await axios.post( - `${getAgentaApiUrl()}/api/testsets/upload/`, - formData, - { - headers: { - "Content-Type": "multipart/form-data", - }, - //@ts-ignore - _ignoreError: true, + await axios.post(`${getAgentaApiUrl()}/api/testsets/upload/`, formData, { + headers: { + "Content-Type": "multipart/form-data", }, - ) + //@ts-ignore + _ignoreError: true, + }) form.resetFields() router.push(`/apps/${appId}/testsets`) } catch (e: any) {