🧑‍💻 (forge) Pass creds and variables to web parsers
Some checks failed
Create Tag / create-tag (push) Has been cancelled

This commit is contained in:
Baptiste Arnaud 2024-09-19 11:09:40 +02:00
parent dc870fcfad
commit f613ce366b
No known key found for this signature in database
3 changed files with 25 additions and 1 deletions

View File

@ -136,7 +136,10 @@ export const executeForgedBlock = async (
clientSideActions.push({
type: 'codeToExecute',
codeToExecute: action?.run?.web?.parseFunction({
credentials: credentialsData ?? {},
options: parsedOptions,
variables,
logs: logsStore,
}),
})
}
@ -151,14 +154,23 @@ export const executeForgedBlock = async (
type: 'custom-embed',
content: {
url: action.run.web.displayEmbedBubble.parseUrl({
credentials: credentialsData ?? {},
options: parsedOptions,
variables,
logs: logsStore,
}),
initFunction: action.run.web.displayEmbedBubble.parseInitFunction({
credentials: credentialsData ?? {},
options: parsedOptions,
variables,
logs: logsStore,
}),
waitForEventFunction:
action.run.web.displayEmbedBubble.waitForEvent?.parseFunction?.({
credentials: credentialsData ?? {},
options: parsedOptions,
variables,
logs: logsStore,
}),
},
}

View File

@ -123,7 +123,7 @@ export const createChatMessage = createAction({
getSetVariableIds: ({ responseMapping }) =>
responseMapping?.map((res) => res.variableId).filter(isDefined) ?? [],
run: {
server: async ({ credentials: { apiKey }, options, variables, logs }) => {
server: async ({ credentials: { apiKey }, options, variables }) => {
const modelName = options.model ?? defaultAnthropicOptions.model
const model = createAnthropic({
apiKey,

View File

@ -79,22 +79,34 @@ export type ActionDefinition<
* Used to determine the URL to be displayed as a text bubble in runtimes where the code can't be executed. (i.e. WhatsApp)
*/
parseUrl: (params: {
credentials: CredentialsFromAuthDef<A>
options: z.infer<BaseOptions> & z.infer<Options>
variables: VariableStore
logs: LogsStore
}) => string | undefined
waitForEvent?: {
getSaveVariableId?: (
options: z.infer<BaseOptions> & z.infer<Options>
) => string | undefined
parseFunction: (params: {
credentials: CredentialsFromAuthDef<A>
options: z.infer<BaseOptions> & z.infer<Options>
variables: VariableStore
logs: LogsStore
}) => FunctionToExecute
}
parseInitFunction: (params: {
credentials: CredentialsFromAuthDef<A>
options: z.infer<BaseOptions> & z.infer<Options>
variables: VariableStore
logs: LogsStore
}) => FunctionToExecute
}
parseFunction?: (params: {
credentials: CredentialsFromAuthDef<A>
options: z.infer<BaseOptions> & z.infer<Options>
variables: VariableStore
logs: LogsStore
}) => FunctionToExecute
}
}