diff --git a/.taskfiles/backend.yml b/.taskfiles/backend.yml index 3bf6504468..8a7f6c622c 100644 --- a/.taskfiles/backend.yml +++ b/.taskfiles/backend.yml @@ -23,6 +23,7 @@ tasks: vars: PORT: '{{.PORT}}' AIENGINE_URL: '{{.AIENGINE_URL}}' + AIENGINE_ENABLED: '{{.AIENGINE_ENABLED}}' AIENGINE_TIMEOUTSECONDS: '{{.AIENGINE_TIMEOUTSECONDS}}' dev:proprietary: @@ -31,13 +32,14 @@ tasks: vars: PORT: '{{.PORT | default "8080"}}' AIENGINE_URL: '{{.AIENGINE_URL | default ""}}' + AIENGINE_ENABLED: '{{.AIENGINE_ENABLED | default "false"}}' AIENGINE_TIMEOUTSECONDS: '{{.AIENGINE_TIMEOUTSECONDS | default "120"}}' env: SERVER_PORT: '{{.PORT}}' cmds: - - cmd: '{{if .AIENGINE_URL}}AIENGINE_URL={{.AIENGINE_URL}} AIENGINE_ENABLED=true AIENGINE_TIMEOUTSECONDS={{.AIENGINE_TIMEOUTSECONDS}} {{end}}cmd /c ".\gradlew.bat :stirling-pdf:bootRun"' + - cmd: '{{if .AIENGINE_URL}}AIENGINE_URL={{.AIENGINE_URL}} AIENGINE_ENABLED={{.AIENGINE_ENABLED}} AIENGINE_TIMEOUTSECONDS={{.AIENGINE_TIMEOUTSECONDS}} {{end}}cmd /c ".\gradlew.bat :stirling-pdf:bootRun"' platforms: [windows] - - cmd: '{{if .AIENGINE_URL}}AIENGINE_URL={{.AIENGINE_URL}} AIENGINE_ENABLED=true AIENGINE_TIMEOUTSECONDS={{.AIENGINE_TIMEOUTSECONDS}} {{end}}./gradlew :stirling-pdf:bootRun' + - cmd: '{{if .AIENGINE_URL}}AIENGINE_URL={{.AIENGINE_URL}} AIENGINE_ENABLED={{.AIENGINE_ENABLED}} AIENGINE_TIMEOUTSECONDS={{.AIENGINE_TIMEOUTSECONDS}} {{end}}./gradlew :stirling-pdf:bootRun' platforms: [linux, darwin] dev:bundled: @@ -60,12 +62,13 @@ tasks: # Override to "" to run the pure `saas` profile against your own SAAS_DB_*. PROFILES: '{{.PROFILES | default "dev"}}' AIENGINE_URL: '{{.AIENGINE_URL | default ""}}' + AIENGINE_ENABLED: '{{.AIENGINE_ENABLED | default "false"}}' AIENGINE_TIMEOUTSECONDS: '{{.AIENGINE_TIMEOUTSECONDS | default "120"}}' env: SERVER_PORT: '{{.PORT}}' STIRLING_FLAVOR: saas AIENGINE_URL: '{{.AIENGINE_URL}}' - AIENGINE_ENABLED: '{{if .AIENGINE_URL}}true{{else}}false{{end}}' + AIENGINE_ENABLED: '{{.AIENGINE_ENABLED}}' AIENGINE_TIMEOUTSECONDS: '{{.AIENGINE_TIMEOUTSECONDS}}' cmds: - cmd: cmd /c ".\gradlew.bat :stirling-pdf:bootRun {{if .PROFILES}}--args=\"--spring.profiles.include={{.PROFILES}}\"{{end}}" diff --git a/Taskfile.yml b/Taskfile.yml index 335405cf41..a12d455352 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -87,6 +87,7 @@ tasks: vars: PORT: '{{.BACKEND_PORT}}' AIENGINE_URL: 'http://localhost:{{.ENGINE_PORT}}' + AIENGINE_ENABLED: "true" - task: 'frontend:dev:{{.FRONTEND}}' vars: PORT: '{{.FRONTEND_PORT}}' diff --git a/frontend/editor/src/core/services/aiBaseUrl.ts b/frontend/editor/src/core/services/aiBaseUrl.ts index e990b29cf2..fe9ccb183a 100644 --- a/frontend/editor/src/core/services/aiBaseUrl.ts +++ b/frontend/editor/src/core/services/aiBaseUrl.ts @@ -8,5 +8,5 @@ import { getApiBaseUrl } from "@app/services/apiClientConfig"; * the SaaS backend, since the AI engine only runs in the cloud. */ export function getAiBaseUrl(): string { - return getApiBaseUrl(); + return getApiBaseUrl().replace(/\/$/, ""); // Remove trailing slash } diff --git a/frontend/editor/src/prototypes/components/chat/ChatContext.tsx b/frontend/editor/src/prototypes/components/chat/ChatContext.tsx index dd7bd353d6..2f2f5ca095 100644 --- a/frontend/editor/src/prototypes/components/chat/ChatContext.tsx +++ b/frontend/editor/src/prototypes/components/chat/ChatContext.tsx @@ -9,7 +9,7 @@ import { import { useAllFiles, useFileActions } from "@app/contexts/FileContext"; import { generateId } from "@app/utils/generateId"; import apiClient from "@app/services/apiClient"; -import { getApiBaseUrl } from "@app/services/apiClientConfig"; +import { getAiBaseUrl } from "@app/services/aiBaseUrl"; import { getAuthHeaders } from "@app/services/apiClientSetup"; import { createChildStub } from "@app/contexts/file/fileActions"; import { @@ -442,7 +442,7 @@ export function ChatProvider({ children }: { children: ReactNode }) { }); const response = await fetch( - `${getApiBaseUrl()}/api/v1/ai/orchestrate/stream`, + `${getAiBaseUrl()}/api/v1/ai/orchestrate/stream`, { method: "POST", body: formData,