@@ -25,6 +25,7 @@ export const executeGoogleSheetBlock = async (
|
||||
})
|
||||
case GoogleSheetsAction.GET:
|
||||
return getRow(state, {
|
||||
blockId: block.id,
|
||||
options: block.options,
|
||||
outgoingEdgeId: block.outgoingEdgeId,
|
||||
})
|
||||
|
||||
@@ -14,9 +14,14 @@ import { updateVariablesInSession } from '@typebot.io/variables/updateVariablesI
|
||||
export const getRow = async (
|
||||
state: SessionState,
|
||||
{
|
||||
blockId,
|
||||
outgoingEdgeId,
|
||||
options,
|
||||
}: { outgoingEdgeId?: string; options: GoogleSheetsGetOptions }
|
||||
}: {
|
||||
blockId: string
|
||||
outgoingEdgeId?: string
|
||||
options: GoogleSheetsGetOptions
|
||||
}
|
||||
): Promise<ExecuteIntegrationResponse> => {
|
||||
const logs: ChatLog[] = []
|
||||
const { variables } = state.typebotsQueue[0].typebot
|
||||
@@ -79,10 +84,15 @@ export const getRow = async (
|
||||
[]
|
||||
)
|
||||
if (!newVariables) return { outgoingEdgeId }
|
||||
const newSessionState = updateVariablesInSession(state)(newVariables)
|
||||
const { updatedState, newSetVariableHistory } = updateVariablesInSession({
|
||||
state,
|
||||
newVariables,
|
||||
currentBlockId: blockId,
|
||||
})
|
||||
return {
|
||||
outgoingEdgeId,
|
||||
newSessionState,
|
||||
newSessionState: updatedState,
|
||||
newSetVariableHistory,
|
||||
}
|
||||
} catch (err) {
|
||||
logs.push({
|
||||
|
||||
@@ -107,12 +107,16 @@ export const createSpeechOpenAI = async (
|
||||
mimeType: 'audio/mpeg',
|
||||
})
|
||||
|
||||
newSessionState = updateVariablesInSession(newSessionState)([
|
||||
{
|
||||
...saveUrlInVariable,
|
||||
value: url,
|
||||
},
|
||||
])
|
||||
newSessionState = updateVariablesInSession({
|
||||
newVariables: [
|
||||
{
|
||||
...saveUrlInVariable,
|
||||
value: url,
|
||||
},
|
||||
],
|
||||
state: newSessionState,
|
||||
currentBlockId: undefined,
|
||||
}).updatedState
|
||||
|
||||
return {
|
||||
startTimeShouldBeUpdated: true,
|
||||
|
||||
@@ -22,7 +22,6 @@ import {
|
||||
defaultOpenAIOptions,
|
||||
} from '@typebot.io/schemas/features/blocks/integrations/openai/constants'
|
||||
import { BubbleBlockType } from '@typebot.io/schemas/features/blocks/bubbles/constants'
|
||||
import { isPlaneteScale } from '@typebot.io/lib/isPlanetScale'
|
||||
|
||||
export const createChatCompletionOpenAI = async (
|
||||
state: SessionState,
|
||||
@@ -68,9 +67,11 @@ export const createChatCompletionOpenAI = async (
|
||||
typebot.variables
|
||||
)(options.messages)
|
||||
if (variablesTransformedToList.length > 0)
|
||||
newSessionState = updateVariablesInSession(state)(
|
||||
variablesTransformedToList
|
||||
)
|
||||
newSessionState = updateVariablesInSession({
|
||||
state,
|
||||
newVariables: variablesTransformedToList,
|
||||
currentBlockId: undefined,
|
||||
}).updatedState
|
||||
|
||||
const temperature = parseVariableNumber(typebot.variables)(
|
||||
options.advancedSettings?.temperature
|
||||
|
||||
@@ -42,7 +42,11 @@ export const resumeChatCompletion =
|
||||
return newVariables
|
||||
}, [])
|
||||
if (newVariables && newVariables.length > 0)
|
||||
newSessionState = updateVariablesInSession(newSessionState)(newVariables)
|
||||
newSessionState = updateVariablesInSession({
|
||||
newVariables,
|
||||
state: newSessionState,
|
||||
currentBlockId: undefined,
|
||||
}).updatedState
|
||||
return {
|
||||
outgoingEdgeId,
|
||||
newSessionState,
|
||||
|
||||
@@ -70,10 +70,15 @@ export const resumeWebhookExecution = ({
|
||||
}
|
||||
}, [])
|
||||
if (newVariables && newVariables.length > 0) {
|
||||
const newSessionState = updateVariablesInSession(state)(newVariables)
|
||||
const { updatedState, newSetVariableHistory } = updateVariablesInSession({
|
||||
newVariables,
|
||||
state,
|
||||
currentBlockId: block.id,
|
||||
})
|
||||
return {
|
||||
outgoingEdgeId: block.outgoingEdgeId,
|
||||
newSessionState,
|
||||
newSessionState: updatedState,
|
||||
newSetVariableHistory,
|
||||
logs,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ export const executeZemanticAiBlock = async (
|
||||
block: ZemanticAiBlock
|
||||
): Promise<ExecuteIntegrationResponse> => {
|
||||
let newSessionState = state
|
||||
let setVariableHistory = []
|
||||
|
||||
if (!block.options?.credentialsId)
|
||||
return {
|
||||
@@ -82,24 +83,34 @@ export const executeZemanticAiBlock = async (
|
||||
|
||||
for (const r of block.options.responseMapping || []) {
|
||||
const variable = typebot.variables.find(byId(r.variableId))
|
||||
let newVariables = []
|
||||
switch (r.valueToExtract) {
|
||||
case 'Summary':
|
||||
if (isDefined(variable) && !isEmpty(res.summary)) {
|
||||
newSessionState = updateVariablesInSession(newSessionState)([
|
||||
{ ...variable, value: res.summary },
|
||||
])
|
||||
newVariables.push({ ...variable, value: res.summary })
|
||||
}
|
||||
break
|
||||
case 'Results':
|
||||
if (isDefined(variable) && res.results.length) {
|
||||
newSessionState = updateVariablesInSession(newSessionState)([
|
||||
{ ...variable, value: JSON.stringify(res.results) },
|
||||
])
|
||||
newVariables.push({
|
||||
...variable,
|
||||
value: JSON.stringify(res.results),
|
||||
})
|
||||
}
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
if (newVariables.length > 0) {
|
||||
const { newSetVariableHistory, updatedState } =
|
||||
updateVariablesInSession({
|
||||
newVariables,
|
||||
state: newSessionState,
|
||||
currentBlockId: block.id,
|
||||
})
|
||||
newSessionState = updatedState
|
||||
setVariableHistory.push(...newSetVariableHistory)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
@@ -112,6 +123,7 @@ export const executeZemanticAiBlock = async (
|
||||
description: 'Could not execute Zemantic AI request',
|
||||
},
|
||||
],
|
||||
newSetVariableHistory: setVariableHistory,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user