🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat(preview): enable cloud AI features on PR previews (#15264)
Lysander Kiesela3589a424855
diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.ymlindex f82e1e4e8a..35e3b55934 100644--- a/.github/workflows/preview-build.yml+++ b/.github/workflows/preview-build.yml@@ -152,7 +152,10 @@ jobs:image: ${{ needs.meta.outputs.web_image }}dockerfile: web/Dockerfile# web disables sign-up on previews; worker has no such arg.- extra_build_args: --build-arg NEXT_PUBLIC_SIGN_UP_DISABLED=true+ # The cloud region must be baked at build time (NEXT_PUBLIC_* is+ # inlined into the client bundle) so previews render the cloud-only+ # AI features; the worker reads it from runtime env instead.+ extra_build_args: --build-arg NEXT_PUBLIC_SIGN_UP_DISABLED=true --build-arg NEXT_PUBLIC_LANGFUSE_CLOUD_REGION=DEV- target: workerimage: ${{ needs.meta.outputs.worker_image }}dockerfile: worker/Dockerfilediff --git a/packages/shared/scripts/seeder/seed-postgres.ts b/packages/shared/scripts/seeder/seed-postgres.tsindex e0901eda77..21595c5a84 100644--- a/packages/shared/scripts/seeder/seed-postgres.ts+++ b/packages/shared/scripts/seeder/seed-postgres.ts@@ -108,6 +108,7 @@ async function main() {where: { id: seedOrgId },update: {name: "Seed Org",+ aiFeaturesEnabled: true,cloudConfig: {plan: "Team",},@@ -136,6 +137,12 @@ async function main() {});await upsertInAppAgentSystemPrompt(project1.id);+ // Skip on examples/load: those paths seed this prompt via generatePrompts+ // (SEED_PROMPT_VERSIONS), whose upsert takes the create branch against a+ // pre-existing row and violates the (projectId, name, version) constraint.+ if (environment !== "examples" && environment !== "load") {+ await upsertNaturalLanguageFilterPrompt(project1.id);+ }// Realistic support chat scenarioawait createSupportChatSession(project1);@@ -832,6 +839,42 @@ async function upsertInAppAgentSystemPrompt(projectId: string) {});}+// The legacy natural-language filter feature fetches this prompt from the+// AI-features project at runtime; on self-referential deployments (previews)+// that project is llm-app, so it must exist on the default seed path too.+const NATURAL_LANGUAGE_FILTER_PROMPT_NAME = "get-filter-conditions-from-query";++async function upsertNaturalLanguageFilterPrompt(projectId: string) {+ const seedPrompt = SEED_PROMPT_VERSIONS.find(+ (p) => p.name === NATURAL_LANGUAGE_FILTER_PROMPT_NAME,+ );+ if (!seedPrompt) return;++ await prisma.prompt.upsert({+ where: {+ projectId_name_version: {+ projectId,+ name: seedPrompt.name,+ version: seedPrompt.version,+ },+ },+ create: {+ projectId,+ createdBy: seedPrompt.createdBy,+ prompt: seedPrompt.prompt,+ name: seedPrompt.name,+ type: seedPrompt.type ?? "text",+ version: seedPrompt.version,+ labels: seedPrompt.labels,+ },+ update: {+ prompt: seedPrompt.prompt,+ type: seedPrompt.type ?? "text",+ labels: seedPrompt.labels,+ },+ });+}+export const PROMPT_IDS: string[] = [];async function generatePrompts(project: Project) {diff --git a/web/src/features/natural-language-filters/server/utils.ts b/web/src/features/natural-language-filters/server/utils.tsindex d0f0e1941f..e7ddab1026 100644--- a/web/src/features/natural-language-filters/server/utils.ts+++ b/web/src/features/natural-language-filters/server/utils.ts@@ -1,6 +1,7 @@import { Langfuse } from "langfuse";import { type FilterCondition, singleFilter } from "@langfuse/shared";import { z } from "zod";+import { getProductBaseUrl } from "@/src/utils/base-url";let langfuseClient: Langfuse | null = null;@@ -43,7 +44,10 @@ export function getLangfuseClient(langfuseClient = new Langfuse({publicKey,secretKey,- baseUrl,+ // Without LANGFUSE_AI_FEATURES_HOST the SDK would default to+ // cloud.langfuse.com; self-referential deployments (e.g. PR previews)+ // must talk to themselves instead.+ baseUrl: baseUrl ?? getProductBaseUrl().toString(),enabled: enabled ?? true,});}