@ -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(
|
||||
|
@ -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) ?? [],
|
||||
|
@ -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) ??
|
||||
|
@ -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',
|
||||
|
@ -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: [
|
||||
{
|
||||
|
@ -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: {
|
||||
|
@ -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<
|
||||
|
Reference in New Issue
Block a user