@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
|
@@ -24,6 +24,7 @@ import { prisma } from "../db";
|
|
|
24
24
|
import { esClient, TRACE_INDEX, traceIndexId } from "../elasticsearch";
|
|
25
25
|
import { getProjectEmbeddingsModel } from "../embeddings";
|
|
26
26
|
import { getPayloadSizeHistogram } from "../metrics";
|
|
27
|
+
import { isNlpGoEnabled } from "../nlpgo/nlpgoFetch";
|
|
27
28
|
import type { ElasticSearchTrace, Trace } from "../tracer/types";
|
|
28
29
|
import type {
|
|
29
30
|
BatchClusteringParams,
|
|
@@ -827,11 +828,34 @@ export const storeResults = async (
|
|
|
827
828
|
}
|
|
828
829
|
};
|
|
829
830
|
|
|
831
|
+
/**
|
|
832
|
+
* Resolve which service hosts topic clustering for the given project. When
|
|
833
|
+
* `release_nlp_go_engine_enabled` is on, route to langevals (the new
|
|
834
|
+
* workspace member at langevals/evaluators/topic_clustering — see
|
|
835
|
+
* specs/nlp-go/_shared/contract.md §11). When off, the legacy langwatch_nlp
|
|
836
|
+
* path is used unchanged.
|
|
837
|
+
*
|
|
838
|
+
* Returns `null` if neither endpoint is configured for the resolved engine —
|
|
839
|
+
* caller should warn-and-skip in that case.
|
|
840
|
+
*/
|
|
841
|
+
const resolveTopicClusteringEndpoint = async (
|
|
842
|
+
projectId: string,
|
|
843
|
+
): Promise<{ baseUrl: string; engine: "langevals" | "langwatch_nlp" } | null> => {
|
|
844
|
+
const goEnabled = await isNlpGoEnabled({ projectId });
|
|
845
|
+
if (goEnabled) {
|
|
846
|
+
if (!env.LANGEVALS_ENDPOINT) return null;
|
|
847
|
+
return { baseUrl: env.LANGEVALS_ENDPOINT, engine: "langevals" };
|
|
848
|
+
}
|
|
849
|
+
if (!env.TOPIC_CLUSTERING_SERVICE) return null;
|
|
850
|
+
return { baseUrl: env.TOPIC_CLUSTERING_SERVICE, engine: "langwatch_nlp" };
|
|
851
|
+
};
|
|
852
|
+
|
|
830
853
|
export const fetchTopicsBatchClustering = async (
|
|
831
854
|
projectId: string,
|
|
832
855
|
params: BatchClusteringParams,
|
|
833
856
|
): Promise<TopicClusteringResponse | undefined> => {
|
|
834
|
-
|
|
857
|
+
const endpoint = await resolveTopicClusteringEndpoint(projectId);
|
|
858
|
+
if (!endpoint) {
|
|
835
859
|
logger.warn(
|
|
836
860
|
{ projectId },
|
|
837
861
|
"Topic clustering service URL not set, skipping topic clustering",
|
|
@@ -843,12 +867,12 @@ export const fetchTopicsBatchClustering = async (
|
|
|
843
867
|
getPayloadSizeHistogram("topic_clustering_batch").observe(size);
|
|
844
868
|
|
|
845
869
|
logger.info(
|
|
846
|
-
{ sizeMb: size / 125000, projectId },
|
|
870
|
+
{ sizeMb: size / 125000, projectId, engine: endpoint.engine },
|
|
847
871
|
"uploading traces data for project",
|
|
848
872
|
);
|
|
849
873
|
|
|
850
874
|
const response = await fetchHTTP2(
|
|
851
|
-
`${
|
|
875
|
+
`${endpoint.baseUrl}/topics/batch_clustering`,
|
|
852
876
|
{ method: "POST", json: params },
|
|
853
877
|
);
|
|
854
878
|
|
|
@@ -863,7 +887,7 @@ export const fetchTopicsBatchClustering = async (
|
|
|
863
887
|
/* this is just a safe json parse fallback */
|
|
864
888
|
}
|
|
865
889
|
throw new Error(
|
|
866
|
-
`Failed to fetch topics batch clustering: ${response.statusText}\n\n${body}`,
|
|
890
|
+
`Failed to fetch topics batch clustering (${endpoint.engine}): ${response.statusText}\n\n${body}`,
|
|
867
891
|
);
|
|
868
892
|
}
|
|
869
893
|
|
|
@@ -876,7 +900,8 @@ export const fetchTopicsIncrementalClustering = async (
|
|
|
876
900
|
projectId: string,
|
|
877
901
|
params: IncrementalClusteringParams,
|
|
878
902
|
): Promise<TopicClusteringResponse | undefined> => {
|
|
879
|
-
|
|
903
|
+
const endpoint = await resolveTopicClusteringEndpoint(projectId);
|
|
904
|
+
if (!endpoint) {
|
|
880
905
|
logger.warn(
|
|
881
906
|
{ projectId },
|
|
882
907
|
"Topic clustering service URL not set, skipping topic clustering",
|
|
@@ -888,12 +913,12 @@ export const fetchTopicsIncrementalClustering = async (
|
|
|
888
913
|
getPayloadSizeHistogram("topic_clustering_incremental").observe(size);
|
|
889
914
|
|
|
890
915
|
logger.info(
|
|
891
|
-
{ sizeMb: size / 125000, projectId },
|
|
916
|
+
{ sizeMb: size / 125000, projectId, engine: endpoint.engine },
|
|
892
917
|
"uploading traces data for project",
|
|
893
918
|
);
|
|
894
919
|
|
|
895
920
|
const response = await fetchHTTP2(
|
|
896
|
-
`${
|
|
921
|
+
`${endpoint.baseUrl}/topics/incremental_clustering`,
|
|
897
922
|
{ method: "POST", json: params },
|
|
898
923
|
);
|
|
899
924
|
|
|
@@ -909,7 +934,7 @@ export const fetchTopicsIncrementalClustering = async (
|
|
|
909
934
|
}
|
|
910
935
|
|
|
911
936
|
throw new Error(
|
|
912
|
-
`Failed to fetch topics incremental clustering: ${response.statusText}\n\n${body}`,
|
|
937
|
+
`Failed to fetch topics incremental clustering (${endpoint.engine}): ${response.statusText}\n\n${body}`,
|
|
913
938
|
);
|
|
914
939
|
}
|
|
915
940
|
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import type { Node } from "@xyflow/react";
|
|
2
2
|
import { nanoid } from "nanoid";
|
|
3
3
|
import { addEnvs } from "../../optimization_studio/server/addEnvs";
|
|
4
|
-
import { getProjectLambdaArn } from "../../optimization_studio/server/lambda";
|
|
5
4
|
import type {
|
|
6
5
|
ExecutionStatus,
|
|
7
6
|
Workflow,
|
|
8
7
|
} from "../../optimization_studio/types/dsl";
|
|
9
8
|
import type { StudioClientEvent } from "../../optimization_studio/types/events";
|
|
10
9
|
import { getEntryInputs } from "../../optimization_studio/utils/nodeUtils";
|
|
11
|
-
import {
|
|
10
|
+
import { nlpgoFetch, type NLPOrigin } from "../nlpgo/nlpgoFetch";
|
|
12
11
|
import { getProjectModelProviders } from "../api/routers/modelProviders.utils";
|
|
13
12
|
import { prisma } from "../db";
|
|
14
13
|
import type { SingleEvaluationResult } from "../evaluations/evaluators.generated";
|
|
@@ -118,6 +117,7 @@ export async function runEvaluationWorkflow(
|
|
|
118
117
|
versionId,
|
|
119
118
|
true, // do_not_trace
|
|
120
119
|
false, // run_evaluations - disable evaluators inside the workflow when running as an online evaluation
|
|
120
|
+
"evaluation",
|
|
121
121
|
);
|
|
122
122
|
|
|
123
123
|
// Process the result
|
|
@@ -161,6 +161,7 @@ export async function runWorkflow(
|
|
|
161
161
|
versionId?: string,
|
|
162
162
|
do_not_trace?: boolean,
|
|
163
163
|
run_evaluations?: boolean,
|
|
164
|
+
origin: NLPOrigin = "workflow",
|
|
164
165
|
) {
|
|
165
166
|
const workflow = await prisma.workflow.findUnique({
|
|
166
167
|
where: { id: workflowId, projectId },
|
|
@@ -209,24 +210,20 @@ export async function runWorkflow(
|
|
|
209
210
|
? inputs.do_not_trace
|
|
210
211
|
: false,
|
|
211
212
|
...(typeof run_evaluations === "boolean" && { run_evaluations }),
|
|
212
|
-
origin
|
|
213
|
+
origin,
|
|
213
214
|
},
|
|
214
215
|
};
|
|
215
216
|
|
|
216
217
|
const event = await addEnvs(messageWithoutEnvs, projectId);
|
|
217
|
-
const functionArn = process.env.LANGWATCH_NLP_LAMBDA_CONFIG
|
|
218
|
-
? await getProjectLambdaArn(projectId)
|
|
219
|
-
: process.env.LANGWATCH_NLP_SERVICE!;
|
|
220
218
|
|
|
221
|
-
const response = await
|
|
219
|
+
const response = await nlpgoFetch<{
|
|
222
220
|
result: any;
|
|
223
221
|
status: ExecutionStatus;
|
|
224
|
-
}>(
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
body: JSON.stringify(event),
|
|
222
|
+
}>({
|
|
223
|
+
projectId,
|
|
224
|
+
path: "/studio/execute_sync",
|
|
225
|
+
body: event,
|
|
226
|
+
origin,
|
|
230
227
|
});
|
|
231
228
|
|
|
232
229
|
if (!response.ok) {
|
|
@@ -50,40 +50,44 @@ def generate_topic_names(
|
|
|
50
50
|
else ""
|
|
51
51
|
)
|
|
52
52
|
|
|
53
|
+
messages = [
|
|
54
|
+
{
|
|
55
|
+
"role": "system",
|
|
56
|
+
"content": f'You are a highly knowledgeable assistant tasked with taxonomy for naming topics \
|
|
57
|
+
based on a list of examples. Provide a single, descriptive name for each topic. \
|
|
58
|
+
Avoid using "and" or "&" in the name, try to summarize it with a single concept. \
|
|
59
|
+
Topic names should not be similar to each other, as the data is already organized, \
|
|
60
|
+
the disambiguation between two similar topics should be clear from the name alone.\
|
|
61
|
+
{existing_message}',
|
|
62
|
+
},
|
|
63
|
+
{"role": "user", "content": f"{topic_examples_str}"},
|
|
64
|
+
]
|
|
65
|
+
tools = [
|
|
66
|
+
{
|
|
67
|
+
"type": "function",
|
|
68
|
+
"function": {
|
|
69
|
+
"name": "topicNames",
|
|
70
|
+
"parameters": {
|
|
71
|
+
"type": "object",
|
|
72
|
+
"properties": dict(
|
|
73
|
+
[
|
|
74
|
+
(f"topic_{index}", {"type": "string"})
|
|
75
|
+
for index in range(len(topic_examples))
|
|
76
|
+
]
|
|
77
|
+
),
|
|
78
|
+
},
|
|
79
|
+
"description": 'use this function to name the topics based on the examples provided, avoid using "and" or "&" in the name, try to name it with a single 2-3 words concept.',
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
tool_choice = {"type": "function", "function": {"name": "topicNames"}}
|
|
84
|
+
|
|
53
85
|
try:
|
|
54
86
|
response = litellm.completion(
|
|
55
87
|
temperature=0.0,
|
|
56
|
-
messages=
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"content": f'You are a highly knowledgeable assistant tasked with taxonomy for naming topics \
|
|
60
|
-
based on a list of examples. Provide a single, descriptive name for each topic. \
|
|
61
|
-
Avoid using "and" or "&" in the name, try to summarize it with a single concept. \
|
|
62
|
-
Topic names should not be similar to each other, as the data is already organized, \
|
|
63
|
-
the disambiguation between two similar topics should be clear from the name alone.\
|
|
64
|
-
{existing_message}',
|
|
65
|
-
},
|
|
66
|
-
{"role": "user", "content": f"{topic_examples_str}"},
|
|
67
|
-
],
|
|
68
|
-
tools=[
|
|
69
|
-
{
|
|
70
|
-
"type": "function",
|
|
71
|
-
"function": {
|
|
72
|
-
"name": "topicNames",
|
|
73
|
-
"parameters": {
|
|
74
|
-
"type": "object",
|
|
75
|
-
"properties": dict(
|
|
76
|
-
[
|
|
77
|
-
(f"topic_{index}", {"type": "string"})
|
|
78
|
-
for index in range(len(topic_examples))
|
|
79
|
-
]
|
|
80
|
-
),
|
|
81
|
-
},
|
|
82
|
-
"description": 'use this function to name the topics based on the examples provided, avoid using "and" or "&" in the name, try to name it with a single 2-3 words concept.',
|
|
83
|
-
},
|
|
84
|
-
}
|
|
85
|
-
],
|
|
86
|
-
tool_choice={"type": "function", "function": {"name": "topicNames"}},
|
|
88
|
+
messages=messages,
|
|
89
|
+
tools=tools,
|
|
90
|
+
tool_choice=tool_choice,
|
|
87
91
|
**litellm_params, # type: ignore
|
|
88
92
|
)
|
|
89
93
|
except Exception as e:
|
|
@@ -97,8 +101,11 @@ def generate_topic_names(
|
|
|
97
101
|
)
|
|
98
102
|
|
|
99
103
|
total_cost = completion_cost(response)
|
|
104
|
+
topic_names_dict = json.loads(
|
|
105
|
+
response.choices[0].message.tool_calls[0].function.arguments # type: ignore
|
|
106
|
+
)
|
|
100
107
|
|
|
101
|
-
topic_names: list[str] = list(
|
|
108
|
+
topic_names: list[str] = list(topic_names_dict.values())
|
|
102
109
|
topic_names = topic_names[0 : len(topic_examples)]
|
|
103
110
|
if len(topic_names) != len(topic_examples):
|
|
104
111
|
raise ValueError("topic_names and topic_examples must have the same length.")
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
#
|
|
3
|
+
# Entrypoint for the langwatch_nlp container. Implements the parallel-
|
|
4
|
+
# deployment scheme from specs/nlp-go/_shared/contract.md §3:
|
|
5
|
+
#
|
|
6
|
+
# default: nlpgo (Go) is the front door at $PORT; spawns uvicorn as a
|
|
7
|
+
# child on 127.0.0.1:5561; routes /go/* itself, reverse-
|
|
8
|
+
# proxies everything else to uvicorn.
|
|
9
|
+
#
|
|
10
|
+
# NLPGO_BYPASS=1: emergency lever — skip nlpgo entirely and run uvicorn
|
|
11
|
+
# directly on $PORT. Same external surface, no Go in
|
|
12
|
+
# the path. Use this when nlpgo has a regression and
|
|
13
|
+
# we need to fail back instantly without infra changes.
|
|
14
|
+
#
|
|
15
|
+
# PORT defaults to 8080 (Lambda Adapter expectation). Dev/k8s callers can
|
|
16
|
+
# override (5562 on a pod, etc.).
|
|
17
|
+
|
|
18
|
+
set -e
|
|
19
|
+
|
|
20
|
+
PORT="${PORT:-8080}"
|
|
21
|
+
KEEP_ALIVE="${NLP_UVICORN_KEEP_ALIVE_SECONDS:-4500}"
|
|
22
|
+
|
|
23
|
+
# Bypass-mode invocation is env-overridable so the saas runtime images
|
|
24
|
+
# (Dockerfile.langwatch_nlp.{service,lambda}.runtime in langwatch-saas)
|
|
25
|
+
# can use `python -m uvicorn` instead of `uv run uvicorn` — those images
|
|
26
|
+
# don't ship `uv` in the runtime stage to keep the layer lean. The
|
|
27
|
+
# monorepo lambda image ships uv (it builds with `uv build` in the same
|
|
28
|
+
# image), so the defaults match its shape.
|
|
29
|
+
BYPASS_COMMAND="${NLPGO_BYPASS_COMMAND:-uv}"
|
|
30
|
+
BYPASS_ARGS="${NLPGO_BYPASS_ARGS:---no-cache run --no-sync --no-editable uvicorn langwatch_nlp.main:app --host 0.0.0.0 --timeout-keep-alive $KEEP_ALIVE}"
|
|
31
|
+
|
|
32
|
+
run_uvicorn_only() {
|
|
33
|
+
# The bypass invocation appends --port LAST so the args set above don't
|
|
34
|
+
# have to know what port to bind — the entrypoint owns that.
|
|
35
|
+
# shellcheck disable=SC2086 # word-splitting is intentional here
|
|
36
|
+
exec $BYPASS_COMMAND $BYPASS_ARGS --port "$1"
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if [ "${NLPGO_BYPASS:-0}" = "1" ]; then
|
|
40
|
+
echo "[entrypoint] NLPGO_BYPASS=1 — running uvicorn directly on :$PORT"
|
|
41
|
+
run_uvicorn_only "$PORT"
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
if [ ! -x /usr/local/bin/nlpgo ]; then
|
|
45
|
+
echo "[entrypoint] nlpgo binary missing — falling back to uvicorn on :$PORT"
|
|
46
|
+
run_uvicorn_only "$PORT"
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
# nlpgo binds $PORT and spawns uvicorn at 127.0.0.1:5561 as its child.
|
|
50
|
+
# Configure via SERVER_ADDR (parent) and NLPGO_CHILD_* (uvicorn args).
|
|
51
|
+
export SERVER_ADDR=":$PORT"
|
|
52
|
+
export NLPGO_CHILD_COMMAND="${NLPGO_CHILD_COMMAND:-uv}"
|
|
53
|
+
# Space-separated, NOT comma-separated: services/nlpgo/deps.go's
|
|
54
|
+
# splitArgs() splits on space/tab. Original entrypoint shipped commas
|
|
55
|
+
# (a4de2dc95) which silently broke the uvicorn child on every container
|
|
56
|
+
# start — uv would see "--no-cache,run,..." as a single positional
|
|
57
|
+
# argument and exit 2 before serving anything. Caught smoke-testing
|
|
58
|
+
# the lambda image during the PR #3483 deploy pre-flight: nlpgo started
|
|
59
|
+
# fine, /go/* worked, but the child never came up so anything that
|
|
60
|
+
# fell through to legacy /studio/* /api/* paths got 502. Anchored on
|
|
61
|
+
# spaces here to match the deps.go contract.
|
|
62
|
+
export NLPGO_CHILD_ARGS="${NLPGO_CHILD_ARGS:---no-cache run --no-sync --no-editable uvicorn langwatch_nlp.main:app --host 127.0.0.1 --port 5561 --timeout-keep-alive $KEEP_ALIVE}"
|
|
63
|
+
export NLPGO_CHILD_HEALTH_URL="${NLPGO_CHILD_HEALTH_URL:-http://127.0.0.1:5561/health}"
|
|
64
|
+
export NLPGO_CHILD_UPSTREAM_URL="${NLPGO_CHILD_UPSTREAM_URL:-http://127.0.0.1:5561}"
|
|
65
|
+
|
|
66
|
+
echo "[entrypoint] nlpgo (Go) on :$PORT — uvicorn child via ${NLPGO_CHILD_UPSTREAM_URL}"
|
|
67
|
+
exec /usr/local/bin/nlpgo
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langwatch/server",
|
|
3
|
-
"version": "3.1.0-beta.
|
|
3
|
+
"version": "3.1.0-beta.22",
|
|
4
4
|
"description": "Run LangWatch locally with one command — `npx @langwatch/server`. Complete LangWatch stack: observability, evaluations, AI gateway, agent simulations.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://langwatch.ai",
|