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