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
const convertedBlockOptions = turnIntoParams.customMapping
? turnIntoParams.customMapping(block.options)
const convertedBlockOptions = turnIntoParams.transform
? turnIntoParams.transform(block.options)
: block.options
try {
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({
name: 'Create Chat Message',
auth,
@ -83,12 +88,14 @@ export const createChatMessage = createAction({
turnableInto: [
{
blockType: 'mistral',
transform: transformToChatCompletionOptions,
},
{
blockType: 'openai',
transform: transformToChatCompletionOptions,
},
{ blockType: 'open-router' },
{ blockType: 'together-ai' },
{ blockType: 'open-router', transform: transformToChatCompletionOptions },
{ blockType: 'together-ai', transform: transformToChatCompletionOptions },
],
getSetVariableIds: ({ responseMapping }) =>
responseMapping?.map((res) => res.variableId).filter(isDefined) ?? [],

View File

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

View File

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

View File

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

View File

@ -22,7 +22,13 @@ export const createChatCompletion = createAction({
blockType: 'open-router',
},
{ blockType: 'mistral' },
{ blockType: 'anthropic' },
{
blockType: 'anthropic',
transform: (options) => ({
...options,
action: 'Create Chat Message',
}),
},
],
getSetVariableIds: getChatCompletionSetVarIds,
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.
*/
customMapping?: (options: T) => any
transform?: (options: T) => any
}
export type ActionDefinition<