2
0

🐛 (anthropic) Fix turn into other blocks

Closes #1356
This commit is contained in:
Baptiste Arnaud
2024-03-15 14:17:06 +01:00
parent cf739000b5
commit 1202f09802
7 changed files with 40 additions and 9 deletions

View File

@ -185,8 +185,8 @@ export const BlockNode = ({
) => { ) => {
if (!('options' in block) || !block.options) return if (!('options' in block) || !block.options) return
const convertedBlockOptions = turnIntoParams.customMapping const convertedBlockOptions = turnIntoParams.transform
? turnIntoParams.customMapping(block.options) ? turnIntoParams.transform(block.options)
: block.options : block.options
try { try {
updateBlock( updateBlock(

View File

@ -76,6 +76,11 @@ export const options = option.object({
}), }),
}) })
const transformToChatCompletionOptions = (options: any) => ({
...options,
action: 'Create chat completion',
})
export const createChatMessage = createAction({ export const createChatMessage = createAction({
name: 'Create Chat Message', name: 'Create Chat Message',
auth, auth,
@ -83,12 +88,14 @@ export const createChatMessage = createAction({
turnableInto: [ turnableInto: [
{ {
blockType: 'mistral', blockType: 'mistral',
transform: transformToChatCompletionOptions,
}, },
{ {
blockType: 'openai', blockType: 'openai',
transform: transformToChatCompletionOptions,
}, },
{ blockType: 'open-router' }, { blockType: 'open-router', transform: transformToChatCompletionOptions },
{ blockType: 'together-ai' }, { blockType: 'together-ai', transform: transformToChatCompletionOptions },
], ],
getSetVariableIds: ({ responseMapping }) => getSetVariableIds: ({ responseMapping }) =>
responseMapping?.map((res) => res.variableId).filter(isDefined) ?? [], responseMapping?.map((res) => res.variableId).filter(isDefined) ?? [],

View File

@ -75,7 +75,13 @@ export const createChatCompletion = createAction({
blockType: 'together-ai', blockType: 'together-ai',
}, },
{ blockType: 'open-router' }, { blockType: 'open-router' },
{ blockType: 'anthropic' }, {
blockType: 'anthropic',
transform: (options) => ({
...options,
action: 'Create Chat Message',
}),
},
], ],
getSetVariableIds: (options) => getSetVariableIds: (options) =>
options.responseMapping?.map((res) => res.variableId).filter(isDefined) ?? options.responseMapping?.map((res) => res.variableId).filter(isDefined) ??

View File

@ -20,7 +20,13 @@ export const createChatCompletion = createAction({
blockType: 'together-ai', blockType: 'together-ai',
}, },
{ blockType: 'mistral' }, { blockType: 'mistral' },
{ blockType: 'anthropic' }, {
blockType: 'anthropic',
transform: (options) => ({
...options,
action: 'Create Chat Message',
}),
},
], ],
options: parseChatCompletionOptions({ options: parseChatCompletionOptions({
modelFetchId: 'fetchModels', modelFetchId: 'fetchModels',

View File

@ -27,7 +27,13 @@ export const createChatCompletion = createAction({
blockType: 'together-ai', blockType: 'together-ai',
}, },
{ blockType: 'mistral' }, { blockType: 'mistral' },
{ blockType: 'anthropic' }, {
blockType: 'anthropic',
transform: (options) => ({
...options,
action: 'Create Chat Message',
}),
},
], ],
fetchers: [ fetchers: [
{ {

View File

@ -22,7 +22,13 @@ export const createChatCompletion = createAction({
blockType: 'open-router', blockType: 'open-router',
}, },
{ blockType: 'mistral' }, { blockType: 'mistral' },
{ blockType: 'anthropic' }, {
blockType: 'anthropic',
transform: (options) => ({
...options,
action: 'Create Chat Message',
}),
},
], ],
getSetVariableIds: getChatCompletionSetVarIds, getSetVariableIds: getChatCompletionSetVarIds,
run: { run: {

View File

@ -38,7 +38,7 @@ export type TurnableIntoParam<T = {}> = {
/** /**
* If defined will be used to convert the existing block options into the new block options. * If defined will be used to convert the existing block options into the new block options.
*/ */
customMapping?: (options: T) => any transform?: (options: T) => any
} }
export type ActionDefinition< export type ActionDefinition<