@langwatch/server 3.1.0-beta.21 → 3.1.0-beta.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/langevals/evaluators/topic_clustering/langevals_topic_clustering/__init__.py +36 -0
- package/langevals/evaluators/topic_clustering/langevals_topic_clustering/_logger.py +165 -0
- package/langevals/evaluators/topic_clustering/langevals_topic_clustering/batch_clustering.py +153 -0
- package/langevals/evaluators/topic_clustering/langevals_topic_clustering/build_response.py +77 -0
- package/langevals/evaluators/topic_clustering/langevals_topic_clustering/constants.py +7 -0
- package/langevals/evaluators/topic_clustering/langevals_topic_clustering/incremental_clustering.py +325 -0
- package/langevals/evaluators/topic_clustering/langevals_topic_clustering/topic_naming.py +432 -0
- package/langevals/evaluators/topic_clustering/langevals_topic_clustering/types.py +42 -0
- package/langevals/evaluators/topic_clustering/langevals_topic_clustering/utils.py +191 -0
- package/langevals/evaluators/topic_clustering/pyproject.toml +52 -0
- package/langevals/evaluators/topic_clustering/tests/test_topic_clustering.py +239 -0
- package/langevals/evaluators/topic_clustering/tests/test_topic_clustering_integration.py +97 -0
- package/langevals/evaluators/topic_clustering/tests/test_topic_naming.py +72 -0
- package/langevals/langevals/pytest_plugins/pass_rate_plugin.py +7 -1
- package/langevals/langevals/server.py +28 -0
- package/langevals/pyproject.toml +3 -0
- package/langevals/uv.lock +119 -20
- package/langwatch/dist/client/assets/{AnnotationsTable-BDAkYaz6.js → AnnotationsTable-uS_9SQ-g.js} +2 -2
- package/langwatch/dist/client/assets/{BatchEvaluationSummary-DMaQM_VB.js → BatchEvaluationSummary-DtFd8yKJ.js} +2 -2
- package/langwatch/dist/client/assets/{BudgetEditDrawer-CHaqmdIl.js → BudgetEditDrawer-CHEPz0hH.js} +2 -2
- package/langwatch/dist/client/assets/{ChartCard-D14PUg_d.js → ChartCard-s5fMPo7b.js} +2 -2
- package/langwatch/dist/client/assets/{ChatWindow-CRDnlP-Q.js → ChatWindow-C0XSteVJ.js} +2 -2
- package/langwatch/dist/client/assets/ChatWindow-DFEmNXQL.js +1 -0
- package/langwatch/dist/client/assets/{ConfirmDialog-CXIhncvW.js → ConfirmDialog-M94yLNvP.js} +2 -2
- package/langwatch/dist/client/assets/{ContactSalesBlock-CijLBwRC.js → ContactSalesBlock-CnnuZ8iI.js} +2 -2
- package/langwatch/dist/client/assets/{DSPyExperiment-B1YOL2m8.js → DSPyExperiment-CMA6lrlx.js} +2 -2
- package/langwatch/dist/client/assets/{FilterDisplay-BB0xWrLn.js → FilterDisplay-0S3NqCkq.js} +2 -2
- package/langwatch/dist/client/assets/{FormatMoney-w9vr_h0X.js → FormatMoney-CCygtAHg.js} +2 -2
- package/langwatch/dist/client/assets/{FoundryDrawer-CdJDXtpz.js → FoundryDrawer-B35xZ26C.js} +2 -2
- package/langwatch/dist/client/assets/{GatewayErrorPanel-DvE9U2dS.js → GatewayErrorPanel-BsaYQEie.js} +2 -2
- package/langwatch/dist/client/assets/{GatewayLayout-lv1p_6B5.js → GatewayLayout-LvwwrwMf.js} +2 -2
- package/langwatch/dist/client/assets/{GraphsLayout-BJ68J9e-.js → GraphsLayout-DJ-HI9N1.js} +2 -2
- package/langwatch/dist/client/assets/{GroupBindingInputRow-DebZBCnD.js → GroupBindingInputRow-CV-fBkX9.js} +2 -2
- package/langwatch/dist/client/assets/{MessagesTable-B6lYde-x.js → MessagesTable-9taaKCOZ.js} +2 -2
- package/langwatch/dist/client/assets/{NavigationFooter-CiOVzDUh.js → NavigationFooter-Dzvauw3l.js} +2 -2
- package/langwatch/dist/client/assets/{NoDataInfoBlock-quSW_MRm.js → NoDataInfoBlock-CLKl_wlX.js} +2 -2
- package/langwatch/dist/client/assets/{OpsPageShell-DJ1WlI6-.js → OpsPageShell-C_mTziRS.js} +2 -2
- package/langwatch/dist/client/assets/{OptimizationStudio-BlozXjcN.js → OptimizationStudio-D2zpsmJj.js} +8 -12
- package/langwatch/dist/client/assets/{PreconditionsField-BOfcWvmZ.js → PreconditionsField-WXB8kcTK.js} +2 -2
- package/langwatch/dist/client/assets/{SettingsLayout-CLCGxMAe.js → SettingsLayout--1gdEuhv.js} +2 -2
- package/langwatch/dist/client/assets/{SubscriptionPage-J8b2Zaj6.js → SubscriptionPage-B0ox_4kM.js} +2 -2
- package/langwatch/dist/client/assets/{VirtualKeySecretReveal-DR1VDLy7.js → VirtualKeySecretReveal-CRbI1dKQ.js} +2 -2
- package/langwatch/dist/client/assets/{WithPermissionGuard-DD8uo3UK.js → WithPermissionGuard-B4Jo8E5-.js} +2 -2
- package/langwatch/dist/client/assets/{__...path__-BZVaIayJ.js → __...path__-BF2zkD84.js} +2 -2
- package/langwatch/dist/client/assets/{_experiment_-B1aT-wS3.js → _experiment_-D02aoVQk.js} +2 -2
- package/langwatch/dist/client/assets/{_id_-oI_eq-I_.js → _id_-Ch8YmTiM.js} +2 -2
- package/langwatch/dist/client/assets/{_id_-DAqPuO73.js → _id_-D6ZvwHpH.js} +2 -2
- package/langwatch/dist/client/assets/{_id_-DUngklVb.js → _id_-DOC1ZkBm.js} +2 -2
- package/langwatch/dist/client/assets/{_id_-jFDAfbob.js → _id_-DfWwW6_N.js} +2 -2
- package/langwatch/dist/client/assets/{_id_-BKBrWGG0.js → _id_-DxUo4W7J.js} +2 -2
- package/langwatch/dist/client/assets/_not-found-DDh108-i.js +1 -0
- package/langwatch/dist/client/assets/{_project_-Bt1tayHB.js → _project_-_UUt5Ar9.js} +2 -2
- package/langwatch/dist/client/assets/{_runId_-CfvnDt5H.js → _runId_-Dimwzp48.js} +2 -2
- package/langwatch/dist/client/assets/_slug_-BMvKBwS_.js +2 -0
- package/langwatch/dist/client/assets/{_slug_-DZAdl0QS.js → _slug_-CE6VoDSC.js} +2 -2
- package/langwatch/dist/client/assets/{_slug_-DmoWXjKT.js → _slug_-OiOLG1Mv.js} +2 -2
- package/langwatch/dist/client/assets/{_team_-DL_wKSWK.js → _team_-DKvmwO_5.js} +2 -2
- package/langwatch/dist/client/assets/{_workflow_-DcMXLPUe.js → _workflow_-FkilKiB-.js} +3 -3
- package/langwatch/dist/client/assets/{_workflow_-NI9bac7d.js → _workflow_-gJZppg3h.js} +2 -2
- package/langwatch/dist/client/assets/{access-audit-CFwNwusI.js → access-audit-xcUVYMMT.js} +2 -2
- package/langwatch/dist/client/assets/{agents-Di4XRwcn.js → agents-D32g91cu.js} +2 -2
- package/langwatch/dist/client/assets/{all-C273mlDB.js → all-vnREzDZj.js} +2 -2
- package/langwatch/dist/client/assets/{analytics-CEAcSf6B.js → analytics-DP6Y4Feh.js} +2 -2
- package/langwatch/dist/client/assets/{annotation-scores-CHfn4LQp.js → annotation-scores-CjD4CEB6.js} +2 -2
- package/langwatch/dist/client/assets/{annotations-CHZQrha6.js → annotations-1rVXiDRQ.js} +2 -2
- package/langwatch/dist/client/assets/{api-keys-BT7HExHM.js → api-keys-BJpKyuaz.js} +2 -2
- package/langwatch/dist/client/assets/{audit-log-BGk-51Dt.js → audit-log-BdUdZjxp.js} +2 -2
- package/langwatch/dist/client/assets/{authentication-DvwXfkp-.js → authentication-8mQB00CC.js} +2 -2
- package/langwatch/dist/client/assets/{authorize-tXpHrWyw.js → authorize-BpUueMNW.js} +2 -2
- package/langwatch/dist/client/assets/{authorize-CRu9xlpU.js → authorize-CbNBtmxW.js} +2 -2
- package/langwatch/dist/client/assets/{automations-CjDvz9Ak.js → automations-34KMkRxd.js} +2 -2
- package/langwatch/dist/client/assets/{billing-plans-FUqEPN62.js → billing-plans-BUQp08MI.js} +2 -2
- package/langwatch/dist/client/assets/{budgets-BV6_RHrs.js → budgets-CdelE8Hv.js} +2 -2
- package/langwatch/dist/client/assets/{cache-rules-CtYA79E_.js → cache-rules-D2m1QlNJ.js} +2 -2
- package/langwatch/dist/client/assets/choose-C0LdeUiH.js +2 -0
- package/langwatch/dist/client/assets/{command-bar-CaJygoez.js → command-bar-DUK45yin.js} +7 -9
- package/langwatch/dist/client/assets/custom-hBq2K4FJ.js +1 -0
- package/langwatch/dist/client/assets/{datasets-vLWpH84_.js → datasets-ErNNhmjg.js} +2 -2
- package/langwatch/dist/client/assets/{dejaview-DwVR3RGg.js → dejaview-BaD4_v90.js} +2 -2
- package/langwatch/dist/client/assets/{dist-SwV3YZv3.js → dist-Cds4Mqhj.js} +4 -6
- package/langwatch/dist/client/assets/{edit-CyxsmQmW.js → edit-DpT8ejBV.js} +2 -2
- package/langwatch/dist/client/assets/{evaluations-BfgeZMph.js → evaluations-BdQ2Dm2r.js} +2 -2
- package/langwatch/dist/client/assets/{evaluations-HSQIMvbX.js → evaluations-C90I4VAr.js} +2 -2
- package/langwatch/dist/client/assets/{evaluators-DLHVvnrh.js → evaluators-ig_ugRLt.js} +2 -2
- package/langwatch/dist/client/assets/{foundry-Ckq0WjPU.js → foundry-B-X_80pD.js} +2 -2
- package/langwatch/dist/client/assets/{gateway-CDSYPZ6w.js → gateway-CS_mtJx-.js} +2 -2
- package/langwatch/dist/client/assets/{groups-CCCRUqPj.js → groups-Bp90ChP3.js} +2 -2
- package/langwatch/dist/client/assets/{index-Bm6z2fM9.js → index-TNQ6uyis.js} +4 -4
- package/langwatch/dist/client/assets/{license-CHOarGWr.js → license-CgnlvyuI.js} +2 -2
- package/langwatch/dist/client/assets/{me-CBya_vXs.js → me-DEqhm_KC.js} +2 -2
- package/langwatch/dist/client/assets/{members-lIFLh-rh.js → members-CUJANDtH.js} +2 -2
- package/langwatch/dist/client/assets/{messages-CG9j8Dz8.js → messages-fQBfCjvp.js} +2 -2
- package/langwatch/dist/client/assets/{metrics-C9pzeaI6.js → metrics-DeIxebpD.js} +2 -2
- package/langwatch/dist/client/assets/{model-costs-Bc5uqjkl.js → model-costs-C1RbgK--.js} +2 -2
- package/langwatch/dist/client/assets/{model-providers-B5UjRgS_.js → model-providers-Pv3ML_-t.js} +2 -2
- package/langwatch/dist/client/assets/{my-queue-BkEfiWyR.js → my-queue-BLre2NMr.js} +2 -2
- package/langwatch/dist/client/assets/{ops-Cc-g-CMn.js → ops-CCw-FJaT.js} +2 -2
- package/langwatch/dist/client/assets/{organization-features-CoIKKHkQ.js → organization-features-rqg-75mI.js} +2 -2
- package/langwatch/dist/client/assets/{organizations-DWcQUTzi.js → organizations-DjCzIHVx.js} +2 -2
- package/langwatch/dist/client/assets/{persistence-CTQ44vGL.js → persistence-BPvHS0F6.js} +2 -2
- package/langwatch/dist/client/assets/{plans-Dq3eFg5K.js → plans-Ch2Ol-Fd.js} +2 -2
- package/langwatch/dist/client/assets/{projections-CTNj1QBM.js → projections-it4FOVjm.js} +2 -2
- package/langwatch/dist/client/assets/{projects-BxM7C87h.js → projects-CjWZFLfn.js} +2 -2
- package/langwatch/dist/client/assets/{prompts-DhXnJT6e.js → prompts-DilmFH_s.js} +2 -2
- package/langwatch/dist/client/assets/{providers-DW7VWdqq.js → providers-tlLT_lTF.js} +2 -2
- package/langwatch/dist/client/assets/{reports-D3QFKhNP.js → reports-vlrcTrLs.js} +2 -2
- package/langwatch/dist/client/assets/{roles-B_0t5DWA.js → roles-DNgi-NQ9.js} +2 -2
- package/langwatch/dist/client/assets/{scenarios-BX3XslU0.js → scenarios-BmG_wDkR.js} +2 -2
- package/langwatch/dist/client/assets/{scim-DDsLO39r.js → scim-BKr1_FHt.js} +2 -2
- package/langwatch/dist/client/assets/{secrets-BvEGwDCy.js → secrets-CU8ocTGv.js} +2 -2
- package/langwatch/dist/client/assets/{settings-9giNiAQQ.js → settings-CDzdoYVK.js} +2 -2
- package/langwatch/dist/client/assets/{setup-HxXKoVKG.js → setup-nEvn2rjN.js} +2 -2
- package/langwatch/dist/client/assets/{subscription-DhyswDze.js → subscription-BPNl_6jF.js} +3 -3
- package/langwatch/dist/client/assets/{subscriptions-Dyyau22a.js → subscriptions-D0G-OE5C.js} +2 -2
- package/langwatch/dist/client/assets/{teams-DRmeAxzf.js → teams-DThgDQvB.js} +2 -2
- package/langwatch/dist/client/assets/{textOverflowHeuristic-JibhpzDV.js → textOverflowHeuristic-DTC8-Ffx.js} +2 -2
- package/langwatch/dist/client/assets/{topic-clustering-Bllfw5rZ.js → topic-clustering-BR2Mbpao.js} +2 -2
- package/langwatch/dist/client/assets/{topics-CpiGYxqb.js → topics-CI8GoNqp.js} +2 -2
- package/langwatch/dist/client/assets/{traceExecutor-CiHXJB0V.js → traceExecutor-CDUGyUaw.js} +2 -2
- package/langwatch/dist/client/assets/{usage-BnsstwBY.js → usage-B4mR7ut_.js} +2 -2
- package/langwatch/dist/client/assets/{usage-CoyGtJoI.js → usage-C8fbffYi.js} +2 -2
- package/langwatch/dist/client/assets/{useAdminResource-SPC5iBHM.js → useAdminResource-SmnnHro6.js} +2 -2
- package/langwatch/dist/client/assets/{useAnnotationQueues-2DKZTC7r.js → useAnnotationQueues-CA6Vk--V.js} +2 -2
- package/langwatch/dist/client/assets/{useAvailableEvaluators-HndTl2LV.js → useAvailableEvaluators-hmbmcRQr.js} +2 -2
- package/langwatch/dist/client/assets/{useDeleteDatasetConfirmation-BgWN6Qqb.js → useDeleteDatasetConfirmation-BCK_zUUe.js} +2 -2
- package/langwatch/dist/client/assets/{useWorkflowStore-e1wFCvo2.js → useWorkflowStore-QUJ3J8X9.js} +2 -2
- package/langwatch/dist/client/assets/{users-C6wjliCC.js → users-CfhanCfR.js} +2 -2
- package/langwatch/dist/client/assets/{users-tF6ZKeV1.js → users-HjuN3o6k.js} +2 -2
- package/langwatch/dist/client/assets/{virtual-keys-BL-65S0B.js → virtual-keys-Bj-MhW66.js} +2 -2
- package/langwatch/dist/client/assets/{wizard-faGkpZDT.js → wizard-dRWCVVx6.js} +2 -2
- package/langwatch/dist/client/assets/{workbench-Oj0s_YR-.js → workbench-CuixH3G1.js} +2 -2
- package/langwatch/dist/client/assets/{workflows-Cu9k-Twu.js → workflows-BT6m4Yu9.js} +2 -2
- package/langwatch/dist/client/index.html +3 -3
- package/langwatch/scripts/seed-dogfood-password.ts +163 -0
- package/langwatch/src/app/api/workflows/post_event/__tests__/post-event-evaluator.integration.test.ts +458 -0
- package/langwatch/src/app/api/workflows/post_event/__tests__/post-event-routing.test.ts +180 -0
- package/langwatch/src/app/api/workflows/post_event/__tests__/post-event.integration.test.ts +274 -0
- package/langwatch/src/app/api/workflows/post_event/post-event.ts +29 -1
- package/langwatch/src/components/agents/AgentCodeEditorDrawer.tsx +4 -5
- package/langwatch/src/components/agents/__tests__/AgentCodeEditorDrawer.integration.test.tsx +40 -0
- package/langwatch/src/components/evaluations/wizard/hooks/evaluation-wizard-store/slices/factories/__tests__/code-execution-node.factory.unit.test.ts +47 -0
- package/langwatch/src/components/evaluations/wizard/hooks/evaluation-wizard-store/slices/factories/code-execution-node.factory.ts +2 -4
- package/langwatch/src/components/experiments/BatchEvaluationV2/BatchEvaluationV2EvaluationResults.tsx +6 -1
- package/langwatch/src/optimization_studio/__tests__/registry.test.ts +29 -1
- package/langwatch/src/optimization_studio/components/Optimize.tsx +17 -3
- package/langwatch/src/optimization_studio/components/properties/AgentPropertiesPanel.tsx +4 -5
- package/langwatch/src/optimization_studio/hooks/workflowStoreCore.ts +17 -6
- package/langwatch/src/optimization_studio/hooks/workflowStoreCore.unit.test.ts +42 -0
- package/langwatch/src/optimization_studio/registry.ts +2 -4
- package/langwatch/src/optimization_studio/server/lambda/index.ts +12 -2
- package/langwatch/src/server/api/routers/workflows.ts +18 -0
- package/langwatch/src/server/evaluations-v3/execution/workflowBuilder.ts +3 -2
- package/langwatch/src/server/evaluations-v3/services/__tests__/experiment-run.service.getRun-null.unit.test.ts +71 -0
- package/langwatch/src/server/evaluations-v3/services/experiment-run.service.ts +18 -9
- package/langwatch/src/server/modelProviders/utils.ts +11 -1
- package/langwatch/src/server/nlpgo/__tests__/nlpgoFetch.integration.test.ts +248 -0
- package/langwatch/src/server/nlpgo/nlpgoFetch.ts +142 -0
- package/langwatch/src/server/routes/__tests__/playground-proxy.integration.test.ts +242 -0
- package/langwatch/src/server/routes/playground.ts +11 -1
- package/langwatch/src/server/routes/workflows.ts +17 -0
- package/langwatch/src/server/topicClustering/topicClustering.ts +33 -8
- package/langwatch/src/server/workflows/runWorkflow.ts +10 -13
- package/langwatch_nlp/langwatch_nlp/topic_clustering/topic_naming.py +39 -32
- package/langwatch_nlp/scripts/entrypoint.sh +67 -0
- package/package.json +1 -1
- package/packages/server/dist/cli.cjs +67 -94
- package/langwatch/dist/client/assets/ChatWindow-DzB-tNlQ.js +0 -1
- package/langwatch/dist/client/assets/_not-found-PEUaWdF3.js +0 -1
- package/langwatch/dist/client/assets/_slug_-C-8AjsjC.js +0 -2
- package/langwatch/dist/client/assets/choose--PBky27o.js +0 -2
- package/langwatch/dist/client/assets/custom-CSiS1liN.js +0 -1
|
@@ -72,7 +72,7 @@ describe("Optimization Studio Registry", () => {
|
|
|
72
72
|
const codeParam = code.parameters?.find((p) => p.identifier === "code");
|
|
73
73
|
|
|
74
74
|
expect(codeParam).toBeDefined();
|
|
75
|
-
expect(codeParam?.value).toContain("def
|
|
75
|
+
expect(codeParam?.value).toContain("def __call__(self, input: str)");
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
it("has code parameter returning output key", () => {
|
|
@@ -82,6 +82,34 @@ describe("Optimization Studio Registry", () => {
|
|
|
82
82
|
expect(codeParam).toBeDefined();
|
|
83
83
|
expect(codeParam?.value).toContain('return {"output":');
|
|
84
84
|
});
|
|
85
|
+
|
|
86
|
+
// Owner directive: the default code-block template must have NO
|
|
87
|
+
// dspy reference whatsoever. The fake-dspy stub still resolves
|
|
88
|
+
// `import dspy` for legacy customer workflows, but new
|
|
89
|
+
// drag-and-drop templates ship as plain Python so future code-block
|
|
90
|
+
// surface stays dspy-free as we move the lambda image off dspy.
|
|
91
|
+
it("default template ships without any dspy reference", () => {
|
|
92
|
+
const codeParam = code.parameters?.find((p) => p.identifier === "code");
|
|
93
|
+
const value = codeParam?.value as string;
|
|
94
|
+
|
|
95
|
+
expect(value).not.toContain("import dspy");
|
|
96
|
+
expect(value).not.toContain("dspy.Module");
|
|
97
|
+
expect(value).not.toContain("(dspy.");
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("default template uses a plain Python class with __call__", () => {
|
|
101
|
+
const codeParam = code.parameters?.find((p) => p.identifier === "code");
|
|
102
|
+
const value = codeParam?.value as string;
|
|
103
|
+
|
|
104
|
+
// Plain class shape: `class Code:` (no parens), entrypoint via
|
|
105
|
+
// Python's idiomatic `__call__` protocol — not torch/dspy's
|
|
106
|
+
// `forward` convention. The runner resolves classes that define
|
|
107
|
+
// `__call__` on the class itself; legacy customer code using
|
|
108
|
+
// `forward` or dspy.Module still resolves via fallback rules.
|
|
109
|
+
expect(value).toMatch(/^class\s+\w+\s*:/m);
|
|
110
|
+
expect(value).toContain("def __call__(self");
|
|
111
|
+
expect(value).not.toContain("def forward");
|
|
112
|
+
});
|
|
85
113
|
});
|
|
86
114
|
|
|
87
115
|
describe("unified naming consistency", () => {
|
|
@@ -57,15 +57,19 @@ const optimizerOptions: {
|
|
|
57
57
|
}));
|
|
58
58
|
|
|
59
59
|
export function Optimize() {
|
|
60
|
+
// All hooks MUST run before any conditional return — see the "Rules of
|
|
61
|
+
// Hooks". The flag-gated early return below requires every hook used in
|
|
62
|
+
// this component to be called above it.
|
|
60
63
|
const { open, onToggle, onClose, setOpen } = useDisclosure();
|
|
61
64
|
|
|
62
65
|
const { project } = useOrganizationTeamProject();
|
|
63
66
|
const { optimizationState } = useWorkflowStore(({ state }) => ({
|
|
64
67
|
optimizationState: state.optimization,
|
|
65
68
|
}));
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
const engineMode = api.workflow.engineMode.useQuery(
|
|
70
|
+
{ projectId: project?.id ?? "" },
|
|
71
|
+
{ enabled: !!project?.id, staleTime: 60_000 },
|
|
72
|
+
);
|
|
69
73
|
const form = useForm<OptimizeForm>({
|
|
70
74
|
defaultValues: {
|
|
71
75
|
version: "",
|
|
@@ -75,6 +79,16 @@ export function Optimize() {
|
|
|
75
79
|
},
|
|
76
80
|
});
|
|
77
81
|
|
|
82
|
+
// Hide the Optimize button when the project is on the Go NLP engine.
|
|
83
|
+
// Optimization was DSPy-only and the Go engine intentionally drops DSPy
|
|
84
|
+
// (see specs/nlp-go/feature-flag.feature). Server-side guards reject
|
|
85
|
+
// optimize websocket events too — UI hide is the visible half.
|
|
86
|
+
if (engineMode.data && !engineMode.data.optimizeEnabled) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const isRunning = optimizationState?.status === "running";
|
|
91
|
+
|
|
78
92
|
return (
|
|
79
93
|
<>
|
|
80
94
|
<Tooltip content={isRunning ? "Optimization is running" : ""}>
|
|
@@ -97,10 +97,8 @@ function buildHttpConfig(
|
|
|
97
97
|
// Code Config helpers
|
|
98
98
|
// ---------------------------------------------------------------------------
|
|
99
99
|
|
|
100
|
-
const DEFAULT_CODE = `
|
|
101
|
-
|
|
102
|
-
class Code(dspy.Module):
|
|
103
|
-
def forward(self, input: str):
|
|
100
|
+
const DEFAULT_CODE = `class Code:
|
|
101
|
+
def __call__(self, input: str):
|
|
104
102
|
# Your code goes here
|
|
105
103
|
|
|
106
104
|
return {"output": input.upper()}
|
|
@@ -625,7 +623,8 @@ function DbAgentPanel({
|
|
|
625
623
|
<Field.Root>
|
|
626
624
|
<Field.Label fontSize="sm">Python Code</Field.Label>
|
|
627
625
|
<Text fontSize="xs" color="fg.muted" marginBottom={1}>
|
|
628
|
-
|
|
626
|
+
Define a Python class with a `__call__` method that takes inputs
|
|
627
|
+
and returns outputs.
|
|
629
628
|
</Text>
|
|
630
629
|
<CodeBlockEditor
|
|
631
630
|
code={code}
|
|
@@ -312,9 +312,14 @@ export const updateCodeClassName = (
|
|
|
312
312
|
p.identifier === "code"
|
|
313
313
|
? {
|
|
314
314
|
...p,
|
|
315
|
+
// Match both the new plain-Python default (`class Code:`)
|
|
316
|
+
// and legacy dspy-flavored (`class Code(dspy.Module):`) so
|
|
317
|
+
// renaming preserves whatever base-class clause the customer
|
|
318
|
+
// had — captured in $1 as the parenthesized fragment, empty
|
|
319
|
+
// for plain classes.
|
|
315
320
|
value: (p.value as string).replace(
|
|
316
|
-
/class
|
|
317
|
-
`class ${snakeCaseToPascalCase(newId)}
|
|
321
|
+
/class\s+\w+(\s*\([^)]*\))?\s*:/,
|
|
322
|
+
`class ${snakeCaseToPascalCase(newId)}$1:`,
|
|
318
323
|
),
|
|
319
324
|
}
|
|
320
325
|
: p,
|
|
@@ -349,11 +354,17 @@ export const updateInputFields = (parameters: Field[], inputs: Field[]) => {
|
|
|
349
354
|
|
|
350
355
|
return parameters.map((p) => {
|
|
351
356
|
if (p.identifier === "code") {
|
|
357
|
+
// Match either the new idiomatic-Python entrypoint (`__call__`)
|
|
358
|
+
// or the legacy/torch-style `forward` and preserve whichever the
|
|
359
|
+
// customer's code already uses — silently rewriting a legacy
|
|
360
|
+
// `forward` into `__call__` on field-add would surprise users
|
|
361
|
+
// and break diffs in their commit history.
|
|
352
362
|
let code = (p.value as string).replace(
|
|
353
|
-
/def forward\([\s\S]*?\):/,
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
363
|
+
/def (__call__|forward)\([\s\S]*?\):/,
|
|
364
|
+
(_match, methodName: string) =>
|
|
365
|
+
`def ${methodName}(self, ${inputs
|
|
366
|
+
.map((i) => `${i.identifier}: ${typesMap[i.type]}`)
|
|
367
|
+
.join(", ")}):`,
|
|
357
368
|
);
|
|
358
369
|
if (code.includes(": Any") && !code.includes("from typing import Any")) {
|
|
359
370
|
code = `from typing import Any\n${code}`;
|
|
@@ -4,6 +4,7 @@ import { createStore, type StoreApi } from "zustand";
|
|
|
4
4
|
import {
|
|
5
5
|
removeInvalidEdges,
|
|
6
6
|
store as storeCreator,
|
|
7
|
+
updateInputFields,
|
|
7
8
|
type WorkflowStore,
|
|
8
9
|
} from "./workflowStoreCore";
|
|
9
10
|
|
|
@@ -524,4 +525,45 @@ describe("workflowStoreCore", () => {
|
|
|
524
525
|
});
|
|
525
526
|
});
|
|
526
527
|
});
|
|
528
|
+
|
|
529
|
+
describe("updateInputFields entry-point preservation", () => {
|
|
530
|
+
// The hook fires when a user adds/removes input fields on a code
|
|
531
|
+
// node. It rewrites the entrypoint method's signature in-place.
|
|
532
|
+
// The owner directive on PR #3483 (nlp-go-migration): the new
|
|
533
|
+
// default template uses Python's idiomatic `__call__` instead of
|
|
534
|
+
// torch/dspy's `forward`, but legacy customer code with `forward`
|
|
535
|
+
// must keep working — silently rewriting `forward` to `__call__`
|
|
536
|
+
// on field-add would surprise users and pollute their diffs.
|
|
537
|
+
const codeParam = (value: string) => [
|
|
538
|
+
{ identifier: "code", type: "code" as const, value },
|
|
539
|
+
];
|
|
540
|
+
|
|
541
|
+
it("rewrites __call__ signature when the new default is in use", () => {
|
|
542
|
+
const result = updateInputFields(
|
|
543
|
+
codeParam(`class Code:\n def __call__(self, input: str):\n return {"output": input}\n`),
|
|
544
|
+
[
|
|
545
|
+
{ identifier: "input", type: "str" },
|
|
546
|
+
{ identifier: "context", type: "str" },
|
|
547
|
+
],
|
|
548
|
+
);
|
|
549
|
+
expect(result[0]?.value).toContain(
|
|
550
|
+
"def __call__(self, input: str, context: str):",
|
|
551
|
+
);
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
it("rewrites legacy forward signature without converting it to __call__", () => {
|
|
555
|
+
const result = updateInputFields(
|
|
556
|
+
codeParam(`class Code:\n def forward(self, input: str):\n return {"output": input}\n`),
|
|
557
|
+
[
|
|
558
|
+
{ identifier: "input", type: "str" },
|
|
559
|
+
{ identifier: "context", type: "str" },
|
|
560
|
+
],
|
|
561
|
+
);
|
|
562
|
+
// Method name preserved as-is; only the param list is rewritten.
|
|
563
|
+
expect(result[0]?.value).toContain(
|
|
564
|
+
"def forward(self, input: str, context: str):",
|
|
565
|
+
);
|
|
566
|
+
expect(result[0]?.value).not.toContain("def __call__");
|
|
567
|
+
});
|
|
568
|
+
});
|
|
527
569
|
});
|
|
@@ -75,10 +75,8 @@ const code: Code = {
|
|
|
75
75
|
{
|
|
76
76
|
identifier: "code",
|
|
77
77
|
type: "code",
|
|
78
|
-
value: `
|
|
79
|
-
|
|
80
|
-
class Code(dspy.Module):
|
|
81
|
-
def forward(self, ${defaultInput?.identifier ?? "input"}: str):
|
|
78
|
+
value: `class Code:
|
|
79
|
+
def __call__(self, ${defaultInput?.identifier ?? "input"}: str):
|
|
82
80
|
# Your code goes here
|
|
83
81
|
|
|
84
82
|
return {"${defaultOutput?.identifier ?? "output"}": "Hello world!"}
|
|
@@ -358,12 +358,22 @@ export const invokeLambda = async (
|
|
|
358
358
|
projectId: string,
|
|
359
359
|
event: StudioClientEvent,
|
|
360
360
|
s3CacheKey: string | undefined,
|
|
361
|
+
options: {
|
|
362
|
+
/** Path under the NLP service. Defaults to `/studio/execute` for the
|
|
363
|
+
* legacy Python SSE handler. Set to `/go/studio/execute` to route
|
|
364
|
+
* the same SSE event shape to the Go engine. */
|
|
365
|
+
path?: string;
|
|
366
|
+
/** Extra headers merged after the defaults (e.g. X-LangWatch-Origin). */
|
|
367
|
+
headers?: Record<string, string>;
|
|
368
|
+
} = {},
|
|
361
369
|
): Promise<ReadableStreamDefaultReader<Uint8Array>> => {
|
|
370
|
+
const path = options.path ?? "/studio/execute";
|
|
362
371
|
const payload = {
|
|
363
372
|
body: JSON.stringify(event),
|
|
364
373
|
headers: {
|
|
365
374
|
"Content-Type": "application/json",
|
|
366
375
|
...(s3CacheKey ? { "X-S3-Cache-Key": s3CacheKey } : {}),
|
|
376
|
+
...(options.headers ?? {}),
|
|
367
377
|
},
|
|
368
378
|
};
|
|
369
379
|
|
|
@@ -378,7 +388,7 @@ export const invokeLambda = async (
|
|
|
378
388
|
FunctionName: functionArn,
|
|
379
389
|
InvocationType: "RequestResponse",
|
|
380
390
|
Payload: JSON.stringify({
|
|
381
|
-
rawPath:
|
|
391
|
+
rawPath: path,
|
|
382
392
|
requestContext: {
|
|
383
393
|
http: {
|
|
384
394
|
method: "POST",
|
|
@@ -461,7 +471,7 @@ export const invokeLambda = async (
|
|
|
461
471
|
return webStream.getReader();
|
|
462
472
|
} else {
|
|
463
473
|
const response = await fetch(
|
|
464
|
-
`${process.env.LANGWATCH_NLP_SERVICE}
|
|
474
|
+
`${process.env.LANGWATCH_NLP_SERVICE}${path}`,
|
|
465
475
|
{
|
|
466
476
|
method: "POST",
|
|
467
477
|
...payload,
|
|
@@ -21,6 +21,7 @@ import type { Unpacked } from "../../../utils/types";
|
|
|
21
21
|
import { DatasetService } from "../../datasets/dataset.service";
|
|
22
22
|
import { enforceLicenseLimit } from "../../license-enforcement";
|
|
23
23
|
import { getVercelAIModel } from "../../modelProviders/utils";
|
|
24
|
+
import { isNlpGoEnabled } from "../../nlpgo/nlpgoFetch";
|
|
24
25
|
import { checkProjectPermission, hasProjectPermission } from "../rbac";
|
|
25
26
|
import { createTRPCRouter, protectedProcedure } from "../trpc";
|
|
26
27
|
import { fireWorkflowCreatedNurturing } from "~/../ee/billing/nurturing/hooks/featureAdoption";
|
|
@@ -31,6 +32,23 @@ import { createLogger } from "../../../utils/logger/server";
|
|
|
31
32
|
const autoComputeLogger = createLogger("langwatch:workflows:auto-compute");
|
|
32
33
|
|
|
33
34
|
export const workflowRouter = createTRPCRouter({
|
|
35
|
+
// Returns which NLP engine is active for the current project. Used by the
|
|
36
|
+
// Studio UI to hide the (now-defunct) Optimize button when the project is
|
|
37
|
+
// routed to the Go engine: optimization was DSPy-only, and the Go engine
|
|
38
|
+
// does not include DSPy. The UI rendering the button is the only place
|
|
39
|
+
// that needs this; the studio websocket handlers also enforce the kill
|
|
40
|
+
// server-side. See specs/nlp-go/feature-flag.feature.
|
|
41
|
+
engineMode: protectedProcedure
|
|
42
|
+
.input(z.object({ projectId: z.string() }))
|
|
43
|
+
.use(checkProjectPermission("workflows:view"))
|
|
44
|
+
.query(async ({ input }) => {
|
|
45
|
+
const goEnabled = await isNlpGoEnabled({ projectId: input.projectId });
|
|
46
|
+
return {
|
|
47
|
+
engineMode: goEnabled ? ("go" as const) : ("python" as const),
|
|
48
|
+
optimizeEnabled: !goEnabled,
|
|
49
|
+
};
|
|
50
|
+
}),
|
|
51
|
+
|
|
34
52
|
create: protectedProcedure
|
|
35
53
|
.input(
|
|
36
54
|
z.object({
|
|
@@ -613,8 +613,9 @@ const buildSignatureNodeParameters = (
|
|
|
613
613
|
/**
|
|
614
614
|
* Builds a code node from a TypedAgent with type "code" or "workflow".
|
|
615
615
|
*
|
|
616
|
-
* Code agents contain Python
|
|
617
|
-
* Parameters are passed directly - no LLM config
|
|
616
|
+
* Code agents contain a Python class (with a `__call__` method) that handles
|
|
617
|
+
* its own LLM calls. Parameters are passed directly - no LLM config
|
|
618
|
+
* normalization needed.
|
|
618
619
|
*/
|
|
619
620
|
export const buildCodeNodeFromAgent = (
|
|
620
621
|
nodeId: string,
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pins the eval-v3 "perpetual spinner" UX bug caught during PR #3483
|
|
3
|
+
* dogfood: when a freshly-started eval-v3 run hadn't yet been folded
|
|
4
|
+
* into ClickHouse `experiment_runs`, `getRun` threw a 500 with
|
|
5
|
+
* "ClickHouse is enabled but returned null for getRun — check
|
|
6
|
+
* ClickHouse client configuration". The UI's 1s polling loop then
|
|
7
|
+
* cascaded the error toast every tick AND stayed in skeleton state
|
|
8
|
+
* forever; user couldn't tell whether the run was running, broken, or
|
|
9
|
+
* finished with no results.
|
|
10
|
+
*
|
|
11
|
+
* Root cause is timing: `runOrchestrator → commands.startExperimentRun`
|
|
12
|
+
* dispatches an event-sourcing command that the
|
|
13
|
+
* `experiment-run-processing` pipeline (in workers) folds into
|
|
14
|
+
* `experiment_runs`. There's a window between the orchestrator
|
|
15
|
+
* returning and the row landing in CH. Wrapping that window in a 500
|
|
16
|
+
* confused UX and hid the (more severe) downstream pipeline-stuck
|
|
17
|
+
* cases behind the same error string.
|
|
18
|
+
*
|
|
19
|
+
* Fix: return `null` instead of throwing. The two consumers
|
|
20
|
+
* (`BatchEvaluationV2EvaluationResults` + `useMultiRunData`) already
|
|
21
|
+
* optional-chain on the data, so null surfaces as a clean "loading"
|
|
22
|
+
* state. The UI's poll picks the row up the moment it materialises.
|
|
23
|
+
*/
|
|
24
|
+
import { describe, expect, it, vi } from "vitest";
|
|
25
|
+
import { ExperimentRunService } from "../experiment-run.service";
|
|
26
|
+
|
|
27
|
+
describe("ExperimentRunService.getRun", () => {
|
|
28
|
+
describe("when ClickHouse returns null for the run row", () => {
|
|
29
|
+
it("returns null instead of throwing so the UI can poll without 500-cascade", async () => {
|
|
30
|
+
const service = new ExperimentRunService({} as any);
|
|
31
|
+
// Replace the ClickHouse facade with one that simulates the
|
|
32
|
+
// "not folded yet" window.
|
|
33
|
+
(service as any).clickHouseService = {
|
|
34
|
+
getRun: vi.fn().mockResolvedValue(null),
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const result = await service.getRun({
|
|
38
|
+
projectId: "project_x",
|
|
39
|
+
experimentId: "experiment_y",
|
|
40
|
+
runId: "run_z",
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
expect(result).toBeNull();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe("when ClickHouse returns a populated run row", () => {
|
|
48
|
+
it("forwards the row through unchanged", async () => {
|
|
49
|
+
const populatedRun = {
|
|
50
|
+
experimentId: "experiment_y",
|
|
51
|
+
runId: "run_z",
|
|
52
|
+
projectId: "project_x",
|
|
53
|
+
dataset: [],
|
|
54
|
+
evaluations: [],
|
|
55
|
+
timestamps: { createdAt: 1, updatedAt: 2 },
|
|
56
|
+
};
|
|
57
|
+
const service = new ExperimentRunService({} as any);
|
|
58
|
+
(service as any).clickHouseService = {
|
|
59
|
+
getRun: vi.fn().mockResolvedValue(populatedRun),
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const result = await service.getRun({
|
|
63
|
+
projectId: "project_x",
|
|
64
|
+
experimentId: "experiment_y",
|
|
65
|
+
runId: "run_z",
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
expect(result).toEqual(populatedRun);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -82,13 +82,28 @@ export class ExperimentRunService {
|
|
|
82
82
|
* @param params.projectId - The project ID
|
|
83
83
|
* @param params.experimentId - The experiment ID
|
|
84
84
|
* @param params.runId - The run ID
|
|
85
|
-
* @returns The full experiment run with dataset entries and evaluations
|
|
85
|
+
* @returns The full experiment run with dataset entries and evaluations,
|
|
86
|
+
* or `null` when the run row hasn't materialised yet in ClickHouse.
|
|
87
|
+
*
|
|
88
|
+
* **Why nullable**: the run row is written by the
|
|
89
|
+
* `experiment-run-processing` event-sourcing pipeline (consumed off the
|
|
90
|
+
* fold queue), so there's a window between
|
|
91
|
+
* `runOrchestrator → commands.startExperimentRun()` returning and the
|
|
92
|
+
* row landing in CH. Pre-fix this method threw a 500 in that window
|
|
93
|
+
* and the UI's 1s poll loop stayed in a perpetual spinner with the
|
|
94
|
+
* error toast cascading every tick — caught during PR #3483 dogfood.
|
|
95
|
+
* The two consumers (`BatchEvaluationV2EvaluationResults` +
|
|
96
|
+
* `useMultiRunData`) already optional-chain on `data?.dataset` /
|
|
97
|
+
* `queries[idx]?.data ?? null`, so returning null surfaces as a clean
|
|
98
|
+
* "loading" state until the next refetch picks up the materialised row.
|
|
99
|
+
* `listRuns` is unaffected (it reads aggregated CH data via a
|
|
100
|
+
* different query path that already coalesces empties to `{}`).
|
|
86
101
|
*/
|
|
87
102
|
async getRun(params: {
|
|
88
103
|
projectId: string;
|
|
89
104
|
experimentId: string;
|
|
90
105
|
runId: string;
|
|
91
|
-
}): Promise<ExperimentRunWithItems> {
|
|
106
|
+
}): Promise<ExperimentRunWithItems | null> {
|
|
92
107
|
return this.tracer.withActiveSpan(
|
|
93
108
|
"ExperimentRunService.getRun",
|
|
94
109
|
{
|
|
@@ -100,13 +115,7 @@ export class ExperimentRunService {
|
|
|
100
115
|
async (span) => {
|
|
101
116
|
span.setAttribute("backend", "clickhouse");
|
|
102
117
|
|
|
103
|
-
|
|
104
|
-
if (result === null) {
|
|
105
|
-
throw new Error(
|
|
106
|
-
"ClickHouse is enabled but returned null for getRun — check ClickHouse client configuration",
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
return result;
|
|
118
|
+
return this.clickHouseService.getRun(params);
|
|
110
119
|
},
|
|
111
120
|
);
|
|
112
121
|
}
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
prepareLitellmParams,
|
|
7
7
|
} from "../api/routers/modelProviders.utils";
|
|
8
8
|
import { prisma } from "../db";
|
|
9
|
+
import { nlpgoProxyBaseURL } from "../nlpgo/nlpgoFetch";
|
|
9
10
|
import type { MaybeStoredModelProvider } from "./registry";
|
|
10
11
|
|
|
11
12
|
export const getVercelAIModel = async (projectId: string, model?: string) => {
|
|
@@ -52,10 +53,19 @@ export const getVercelAIModel = async (projectId: string, model?: string) => {
|
|
|
52
53
|
]),
|
|
53
54
|
);
|
|
54
55
|
|
|
56
|
+
// FF-gated: Go playground proxy when release_nlp_go_engine_enabled is
|
|
57
|
+
// on, legacy LiteLLM proxy otherwise. Same wire shape (x-litellm-*
|
|
58
|
+
// headers + OpenAI body) — the Go side reads x-litellm-* via the
|
|
59
|
+
// gatewayproxy package and dispatches in-process; the Python side
|
|
60
|
+
// does what it did before.
|
|
61
|
+
const baseURL = await nlpgoProxyBaseURL({
|
|
62
|
+
projectId,
|
|
63
|
+
baseURL: env.LANGWATCH_NLP_SERVICE!,
|
|
64
|
+
});
|
|
55
65
|
const vercelProvider = createOpenAICompatible({
|
|
56
66
|
name: `${providerKey}`,
|
|
57
67
|
apiKey: litellmParams.api_key,
|
|
58
|
-
baseURL
|
|
68
|
+
baseURL,
|
|
59
69
|
headers,
|
|
60
70
|
});
|
|
61
71
|
|