Skip to content

Commit 2129337

Browse files
authored
improvement(langsmith): ugpraded langsmith to use tool names directly in dropdown (#2824)
1 parent 5af72ea commit 2129337

File tree

2 files changed

+35
-40
lines changed

2 files changed

+35
-40
lines changed

.claude/commands/add-block.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,16 @@ Enables AI-assisted field generation.
351351

352352
## Tools Configuration
353353

354-
### Simple Tool Selector
354+
**Preferred:** Use tool names directly as dropdown option IDs to avoid switch cases:
355355
```typescript
356-
tools: {
357-
access: ['service_create', 'service_read', 'service_update'],
358-
config: {
359-
tool: (params) => `service_${params.operation}`,
360-
},
361-
}
356+
// Dropdown options use tool IDs directly
357+
options: [
358+
{ label: 'Create', id: 'service_create' },
359+
{ label: 'Read', id: 'service_read' },
360+
]
361+
362+
// Tool selector just returns the operation value
363+
tool: (params) => params.operation,
362364
```
363365

364366
### With Parameter Transformation

apps/sim/blocks/blocks/langsmith.ts

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ export const LangsmithBlock: BlockConfig<LangsmithResponse> = {
1919
title: 'Operation',
2020
type: 'dropdown',
2121
options: [
22-
{ label: 'Create Run', id: 'create_run' },
23-
{ label: 'Create Runs Batch', id: 'create_runs_batch' },
22+
{ label: 'Create Run', id: 'langsmith_create_run' },
23+
{ label: 'Create Runs Batch', id: 'langsmith_create_runs_batch' },
2424
],
25-
value: () => 'create_run',
25+
value: () => 'langsmith_create_run',
2626
},
2727
{
2828
id: 'apiKey',
@@ -37,15 +37,15 @@ export const LangsmithBlock: BlockConfig<LangsmithResponse> = {
3737
title: 'Run ID',
3838
type: 'short-input',
3939
placeholder: 'Auto-generated if blank',
40-
condition: { field: 'operation', value: 'create_run' },
40+
condition: { field: 'operation', value: 'langsmith_create_run' },
4141
},
4242
{
4343
id: 'name',
4444
title: 'Name',
4545
type: 'short-input',
4646
placeholder: 'Run name',
47-
required: { field: 'operation', value: 'create_run' },
48-
condition: { field: 'operation', value: 'create_run' },
47+
required: { field: 'operation', value: 'langsmith_create_run' },
48+
condition: { field: 'operation', value: 'langsmith_create_run' },
4949
},
5050
{
5151
id: 'run_type',
@@ -61,148 +61,141 @@ export const LangsmithBlock: BlockConfig<LangsmithResponse> = {
6161
{ label: 'Parser', id: 'parser' },
6262
],
6363
value: () => 'chain',
64-
required: { field: 'operation', value: 'create_run' },
65-
condition: { field: 'operation', value: 'create_run' },
64+
required: { field: 'operation', value: 'langsmith_create_run' },
65+
condition: { field: 'operation', value: 'langsmith_create_run' },
6666
},
6767
{
6868
id: 'start_time',
6969
title: 'Start Time',
7070
type: 'short-input',
7171
placeholder: '2025-01-01T12:00:00Z',
72-
condition: { field: 'operation', value: 'create_run' },
72+
condition: { field: 'operation', value: 'langsmith_create_run' },
7373
value: () => new Date().toISOString(),
7474
},
7575
{
7676
id: 'end_time',
7777
title: 'End Time',
7878
type: 'short-input',
7979
placeholder: '2025-01-01T12:00:30Z',
80-
condition: { field: 'operation', value: 'create_run' },
80+
condition: { field: 'operation', value: 'langsmith_create_run' },
8181
mode: 'advanced',
8282
},
8383
{
8484
id: 'inputs',
8585
title: 'Inputs',
8686
type: 'code',
8787
placeholder: '{"input":"value"}',
88-
condition: { field: 'operation', value: 'create_run' },
88+
condition: { field: 'operation', value: 'langsmith_create_run' },
8989
mode: 'advanced',
9090
},
9191
{
9292
id: 'outputs',
9393
title: 'Outputs',
9494
type: 'code',
9595
placeholder: '{"output":"value"}',
96-
condition: { field: 'operation', value: 'create_run' },
96+
condition: { field: 'operation', value: 'langsmith_create_run' },
9797
mode: 'advanced',
9898
},
9999
{
100100
id: 'extra',
101101
title: 'Metadata',
102102
type: 'code',
103103
placeholder: '{"ls_model":"gpt-4"}',
104-
condition: { field: 'operation', value: 'create_run' },
104+
condition: { field: 'operation', value: 'langsmith_create_run' },
105105
mode: 'advanced',
106106
},
107107
{
108108
id: 'tags',
109109
title: 'Tags',
110110
type: 'code',
111111
placeholder: '["production","workflow"]',
112-
condition: { field: 'operation', value: 'create_run' },
112+
condition: { field: 'operation', value: 'langsmith_create_run' },
113113
mode: 'advanced',
114114
},
115115
{
116116
id: 'parent_run_id',
117117
title: 'Parent Run ID',
118118
type: 'short-input',
119119
placeholder: 'Parent run identifier',
120-
condition: { field: 'operation', value: 'create_run' },
120+
condition: { field: 'operation', value: 'langsmith_create_run' },
121121
mode: 'advanced',
122122
},
123123
{
124124
id: 'trace_id',
125125
title: 'Trace ID',
126126
type: 'short-input',
127127
placeholder: 'Auto-generated if blank',
128-
condition: { field: 'operation', value: 'create_run' },
128+
condition: { field: 'operation', value: 'langsmith_create_run' },
129129
mode: 'advanced',
130130
},
131131
{
132132
id: 'session_id',
133133
title: 'Session ID',
134134
type: 'short-input',
135135
placeholder: 'Session identifier',
136-
condition: { field: 'operation', value: 'create_run' },
136+
condition: { field: 'operation', value: 'langsmith_create_run' },
137137
mode: 'advanced',
138138
},
139139
{
140140
id: 'session_name',
141141
title: 'Session Name',
142142
type: 'short-input',
143143
placeholder: 'Session name',
144-
condition: { field: 'operation', value: 'create_run' },
144+
condition: { field: 'operation', value: 'langsmith_create_run' },
145145
mode: 'advanced',
146146
},
147147
{
148148
id: 'status',
149149
title: 'Status',
150150
type: 'short-input',
151151
placeholder: 'success',
152-
condition: { field: 'operation', value: 'create_run' },
152+
condition: { field: 'operation', value: 'langsmith_create_run' },
153153
mode: 'advanced',
154154
},
155155
{
156156
id: 'error',
157157
title: 'Error',
158158
type: 'long-input',
159159
placeholder: 'Error message',
160-
condition: { field: 'operation', value: 'create_run' },
160+
condition: { field: 'operation', value: 'langsmith_create_run' },
161161
mode: 'advanced',
162162
},
163163
{
164164
id: 'dotted_order',
165165
title: 'Dotted Order',
166166
type: 'short-input',
167167
placeholder: 'Defaults to <YYYYMMDDTHHMMSSffffff>Z<id>',
168-
condition: { field: 'operation', value: 'create_run' },
168+
condition: { field: 'operation', value: 'langsmith_create_run' },
169169
mode: 'advanced',
170170
},
171171
{
172172
id: 'events',
173173
title: 'Events',
174174
type: 'code',
175175
placeholder: '[{"event":"token","value":1}]',
176-
condition: { field: 'operation', value: 'create_run' },
176+
condition: { field: 'operation', value: 'langsmith_create_run' },
177177
mode: 'advanced',
178178
},
179179
{
180180
id: 'post',
181181
title: 'Post Runs',
182182
type: 'code',
183183
placeholder: '[{"id":"...","name":"...","run_type":"chain","start_time":"..."}]',
184-
condition: { field: 'operation', value: 'create_runs_batch' },
184+
condition: { field: 'operation', value: 'langsmith_create_runs_batch' },
185185
},
186186
{
187187
id: 'patch',
188188
title: 'Patch Runs',
189189
type: 'code',
190190
placeholder: '[{"id":"...","name":"...","run_type":"chain","start_time":"..."}]',
191-
condition: { field: 'operation', value: 'create_runs_batch' },
191+
condition: { field: 'operation', value: 'langsmith_create_runs_batch' },
192192
mode: 'advanced',
193193
},
194194
],
195195
tools: {
196196
access: ['langsmith_create_run', 'langsmith_create_runs_batch'],
197197
config: {
198-
tool: (params) => {
199-
switch (params.operation) {
200-
case 'create_runs_batch':
201-
return 'langsmith_create_runs_batch'
202-
default:
203-
return 'langsmith_create_run'
204-
}
205-
},
198+
tool: (params) => params.operation,
206199
params: (params) => {
207200
const parseJsonValue = (value: unknown, label: string) => {
208201
if (value === undefined || value === null || value === '') {
@@ -220,7 +213,7 @@ export const LangsmithBlock: BlockConfig<LangsmithResponse> = {
220213
return value
221214
}
222215

223-
if (params.operation === 'create_runs_batch') {
216+
if (params.operation === 'langsmith_create_runs_batch') {
224217
const post = parseJsonValue(params.post, 'post runs')
225218
const patch = parseJsonValue(params.patch, 'patch runs')
226219

0 commit comments

Comments
 (0)