Skip to content

Commit

Permalink
🧑‍💻 (forge) Pass creds and variables to web parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Sep 19, 2024
1 parent dc870fc commit f613ce3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/bot-engine/forge/executeForgedBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ export const executeForgedBlock = async (
clientSideActions.push({
type: 'codeToExecute',
codeToExecute: action?.run?.web?.parseFunction({
credentials: credentialsData ?? {},
options: parsedOptions,
variables,
logs: logsStore,
}),
})
}
Expand All @@ -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,
}),
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions packages/forge/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit f613ce3

Please sign in to comment.