improvement(langsmith): ugpraded langsmith to use tool names directly in dropdown (#2824)

This commit is contained in:
Waleed
2026-01-14 18:46:06 -08:00
committed by GitHub
parent 5af72ea22f
commit 212933746e
2 changed files with 35 additions and 40 deletions

View File

@@ -351,14 +351,16 @@ Enables AI-assisted field generation.
## Tools Configuration
### Simple Tool Selector
**Preferred:** Use tool names directly as dropdown option IDs to avoid switch cases:
```typescript
tools: {
access: ['service_create', 'service_read', 'service_update'],
config: {
tool: (params) => `service_${params.operation}`,
},
}
// Dropdown options use tool IDs directly
options: [
{ label: 'Create', id: 'service_create' },
{ label: 'Read', id: 'service_read' },
]
// Tool selector just returns the operation value
tool: (params) => params.operation,
```
### With Parameter Transformation

View File

@@ -19,10 +19,10 @@ export const LangsmithBlock: BlockConfig<LangsmithResponse> = {
title: 'Operation',
type: 'dropdown',
options: [
{ label: 'Create Run', id: 'create_run' },
{ label: 'Create Runs Batch', id: 'create_runs_batch' },
{ label: 'Create Run', id: 'langsmith_create_run' },
{ label: 'Create Runs Batch', id: 'langsmith_create_runs_batch' },
],
value: () => 'create_run',
value: () => 'langsmith_create_run',
},
{
id: 'apiKey',
@@ -37,15 +37,15 @@ export const LangsmithBlock: BlockConfig<LangsmithResponse> = {
title: 'Run ID',
type: 'short-input',
placeholder: 'Auto-generated if blank',
condition: { field: 'operation', value: 'create_run' },
condition: { field: 'operation', value: 'langsmith_create_run' },
},
{
id: 'name',
title: 'Name',
type: 'short-input',
placeholder: 'Run name',
required: { field: 'operation', value: 'create_run' },
condition: { field: 'operation', value: 'create_run' },
required: { field: 'operation', value: 'langsmith_create_run' },
condition: { field: 'operation', value: 'langsmith_create_run' },
},
{
id: 'run_type',
@@ -61,15 +61,15 @@ export const LangsmithBlock: BlockConfig<LangsmithResponse> = {
{ label: 'Parser', id: 'parser' },
],
value: () => 'chain',
required: { field: 'operation', value: 'create_run' },
condition: { field: 'operation', value: 'create_run' },
required: { field: 'operation', value: 'langsmith_create_run' },
condition: { field: 'operation', value: 'langsmith_create_run' },
},
{
id: 'start_time',
title: 'Start Time',
type: 'short-input',
placeholder: '2025-01-01T12:00:00Z',
condition: { field: 'operation', value: 'create_run' },
condition: { field: 'operation', value: 'langsmith_create_run' },
value: () => new Date().toISOString(),
},
{
@@ -77,7 +77,7 @@ export const LangsmithBlock: BlockConfig<LangsmithResponse> = {
title: 'End Time',
type: 'short-input',
placeholder: '2025-01-01T12:00:30Z',
condition: { field: 'operation', value: 'create_run' },
condition: { field: 'operation', value: 'langsmith_create_run' },
mode: 'advanced',
},
{
@@ -85,7 +85,7 @@ export const LangsmithBlock: BlockConfig<LangsmithResponse> = {
title: 'Inputs',
type: 'code',
placeholder: '{"input":"value"}',
condition: { field: 'operation', value: 'create_run' },
condition: { field: 'operation', value: 'langsmith_create_run' },
mode: 'advanced',
},
{
@@ -93,7 +93,7 @@ export const LangsmithBlock: BlockConfig<LangsmithResponse> = {
title: 'Outputs',
type: 'code',
placeholder: '{"output":"value"}',
condition: { field: 'operation', value: 'create_run' },
condition: { field: 'operation', value: 'langsmith_create_run' },
mode: 'advanced',
},
{
@@ -101,7 +101,7 @@ export const LangsmithBlock: BlockConfig<LangsmithResponse> = {
title: 'Metadata',
type: 'code',
placeholder: '{"ls_model":"gpt-4"}',
condition: { field: 'operation', value: 'create_run' },
condition: { field: 'operation', value: 'langsmith_create_run' },
mode: 'advanced',
},
{
@@ -109,7 +109,7 @@ export const LangsmithBlock: BlockConfig<LangsmithResponse> = {
title: 'Tags',
type: 'code',
placeholder: '["production","workflow"]',
condition: { field: 'operation', value: 'create_run' },
condition: { field: 'operation', value: 'langsmith_create_run' },
mode: 'advanced',
},
{
@@ -117,7 +117,7 @@ export const LangsmithBlock: BlockConfig<LangsmithResponse> = {
title: 'Parent Run ID',
type: 'short-input',
placeholder: 'Parent run identifier',
condition: { field: 'operation', value: 'create_run' },
condition: { field: 'operation', value: 'langsmith_create_run' },
mode: 'advanced',
},
{
@@ -125,7 +125,7 @@ export const LangsmithBlock: BlockConfig<LangsmithResponse> = {
title: 'Trace ID',
type: 'short-input',
placeholder: 'Auto-generated if blank',
condition: { field: 'operation', value: 'create_run' },
condition: { field: 'operation', value: 'langsmith_create_run' },
mode: 'advanced',
},
{
@@ -133,7 +133,7 @@ export const LangsmithBlock: BlockConfig<LangsmithResponse> = {
title: 'Session ID',
type: 'short-input',
placeholder: 'Session identifier',
condition: { field: 'operation', value: 'create_run' },
condition: { field: 'operation', value: 'langsmith_create_run' },
mode: 'advanced',
},
{
@@ -141,7 +141,7 @@ export const LangsmithBlock: BlockConfig<LangsmithResponse> = {
title: 'Session Name',
type: 'short-input',
placeholder: 'Session name',
condition: { field: 'operation', value: 'create_run' },
condition: { field: 'operation', value: 'langsmith_create_run' },
mode: 'advanced',
},
{
@@ -149,7 +149,7 @@ export const LangsmithBlock: BlockConfig<LangsmithResponse> = {
title: 'Status',
type: 'short-input',
placeholder: 'success',
condition: { field: 'operation', value: 'create_run' },
condition: { field: 'operation', value: 'langsmith_create_run' },
mode: 'advanced',
},
{
@@ -157,7 +157,7 @@ export const LangsmithBlock: BlockConfig<LangsmithResponse> = {
title: 'Error',
type: 'long-input',
placeholder: 'Error message',
condition: { field: 'operation', value: 'create_run' },
condition: { field: 'operation', value: 'langsmith_create_run' },
mode: 'advanced',
},
{
@@ -165,7 +165,7 @@ export const LangsmithBlock: BlockConfig<LangsmithResponse> = {
title: 'Dotted Order',
type: 'short-input',
placeholder: 'Defaults to <YYYYMMDDTHHMMSSffffff>Z<id>',
condition: { field: 'operation', value: 'create_run' },
condition: { field: 'operation', value: 'langsmith_create_run' },
mode: 'advanced',
},
{
@@ -173,7 +173,7 @@ export const LangsmithBlock: BlockConfig<LangsmithResponse> = {
title: 'Events',
type: 'code',
placeholder: '[{"event":"token","value":1}]',
condition: { field: 'operation', value: 'create_run' },
condition: { field: 'operation', value: 'langsmith_create_run' },
mode: 'advanced',
},
{
@@ -181,28 +181,21 @@ export const LangsmithBlock: BlockConfig<LangsmithResponse> = {
title: 'Post Runs',
type: 'code',
placeholder: '[{"id":"...","name":"...","run_type":"chain","start_time":"..."}]',
condition: { field: 'operation', value: 'create_runs_batch' },
condition: { field: 'operation', value: 'langsmith_create_runs_batch' },
},
{
id: 'patch',
title: 'Patch Runs',
type: 'code',
placeholder: '[{"id":"...","name":"...","run_type":"chain","start_time":"..."}]',
condition: { field: 'operation', value: 'create_runs_batch' },
condition: { field: 'operation', value: 'langsmith_create_runs_batch' },
mode: 'advanced',
},
],
tools: {
access: ['langsmith_create_run', 'langsmith_create_runs_batch'],
config: {
tool: (params) => {
switch (params.operation) {
case 'create_runs_batch':
return 'langsmith_create_runs_batch'
default:
return 'langsmith_create_run'
}
},
tool: (params) => params.operation,
params: (params) => {
const parseJsonValue = (value: unknown, label: string) => {
if (value === undefined || value === null || value === '') {
@@ -220,7 +213,7 @@ export const LangsmithBlock: BlockConfig<LangsmithResponse> = {
return value
}
if (params.operation === 'create_runs_batch') {
if (params.operation === 'langsmith_create_runs_batch') {
const post = parseJsonValue(params.post, 'post runs')
const patch = parseJsonValue(params.patch, 'patch runs')