Skip to content

Commit

Permalink
馃悰 (anthropic) Fix turn into other blocks
Browse files Browse the repository at this point in the history
Closes #1356
  • Loading branch information
baptisteArno committed Mar 15, 2024
1 parent cf73900 commit 1202f09
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
11 changes: 9 additions & 2 deletions packages/forge/blocks/anthropic/actions/createChatMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,26 @@ export const options = option.object({
}),
})

const transformToChatCompletionOptions = (options: any) => ({
...options,
action: 'Create chat completion',
})

export const createChatMessage = createAction({
name: 'Create Chat Message',
auth,
options,
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) ?? [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) ??
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion packages/forge/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand Down

0 comments on commit 1202f09

Please sign in to comment.