2
0

⬆️ Upgrade AI SDK (#1641)

This commit is contained in:
Baptiste Arnaud
2024-07-15 14:32:42 +02:00
committed by GitHub
parent a4fb8b6d10
commit 043f0054b0
60 changed files with 2183 additions and 1683 deletions

View File

@ -27,7 +27,6 @@
"options": {
"credentialsId": "clvqq3hey0007pub4almxnhk2",
"action": "Ask Assistant",
"assistantId": "asst_jy7aW39QWtAcVDrLOBr2JSWo",
"threadVariableId": "vf5gxmpqddsy4qugev6o0qs5c",
"message": "{{User last message}}",
"responseMapping": [{ "variableId": "vn8h1gigkjwv40godw2hrgclh" }]

View File

@ -297,7 +297,7 @@ export const FilmIcon = (props: IconProps) => (
</Icon>
)
export const WebhookIcon = (props: IconProps) => (
export const ThunderIcon = (props: IconProps) => (
<Icon viewBox="0 0 24 24" {...featherIconsBaseProps} {...props}>
<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"></polygon>
</Icon>

View File

@ -1,5 +1,5 @@
import { WebhookIcon } from '@/components/icons'
import { ThunderIcon } from '@/components/icons'
import { IconProps } from '@chakra-ui/react'
import React from 'react'
export const HttpRequestIcon = (props: IconProps) => <WebhookIcon {...props} />
export const HttpRequestIcon = (props: IconProps) => <ThunderIcon {...props} />

View File

@ -1,6 +1,6 @@
import { useColorModeValue } from '@chakra-ui/react'
import React from 'react'
import { FlagIcon, SendEmailIcon, WebhookIcon } from '@/components/icons'
import { FlagIcon, SendEmailIcon, ThunderIcon } from '@/components/icons'
import { WaitIcon } from '@/features/blocks/logic/wait/components/WaitIcon'
import { ScriptIcon } from '@/features/blocks/logic/script/components/ScriptIcon'
import { JumpIcon } from '@/features/blocks/logic/jump/components/JumpIcon'
@ -103,7 +103,7 @@ export const BlockIcon = ({ type, mt }: BlockIconProps): JSX.Element => {
case IntegrationBlockType.GOOGLE_ANALYTICS:
return <GoogleAnalyticsLogo mt={mt} />
case IntegrationBlockType.WEBHOOK:
return <WebhookIcon mt={mt} />
return <ThunderIcon mt={mt} />
case IntegrationBlockType.ZAPIER:
return <ZapierLogo mt={mt} />
case IntegrationBlockType.MAKE_COM:

View File

@ -1,19 +1,50 @@
import { SetVariableLabel } from '@/components/SetVariableLabel'
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
import { Stack, Text } from '@chakra-ui/react'
import { Flex, Stack, Text, Tooltip } from '@chakra-ui/react'
import { useForgedBlock } from '../hooks/useForgedBlock'
import { ForgedBlock } from '@typebot.io/forge-repository/types'
import { BlockIndices } from '@typebot.io/schemas'
import { useMemo } from 'react'
import { BubbleBlockType } from '@typebot.io/schemas/features/blocks/bubbles/constants'
import { ThunderIcon } from '@/components/icons'
type Props = {
block: ForgedBlock
indices: BlockIndices
}
export const ForgedBlockNodeContent = ({ block }: Props) => {
export const ForgedBlockNodeContent = ({ block, indices }: Props) => {
const { blockDef, actionDef } = useForgedBlock(
block.type,
block.options?.action
)
const { typebot } = useTypebot()
const isStreamingNextBlock = useMemo(() => {
if (!actionDef?.run?.stream?.getStreamVariableId) return false
const variable = typebot?.variables.find(
(variable) =>
variable.id ===
actionDef.run!.stream!.getStreamVariableId(block.options)
)
if (!variable) return false
const nextBlock =
typebot?.groups[indices.groupIndex]?.blocks[indices.blockIndex + 1]
return (
nextBlock?.type === BubbleBlockType.TEXT &&
nextBlock.content?.richText?.length === 1 &&
nextBlock.content.richText[0].type === 'p' &&
nextBlock.content.richText[0].children.length === 1 &&
nextBlock.content.richText[0].children[0].text === `{{${variable.name}}}`
)
}, [
actionDef?.run,
block.options,
indices.blockIndex,
indices.groupIndex,
typebot?.groups,
typebot?.variables,
])
const setVariableIds = actionDef?.getSetVariableIds?.(block.options) ?? []
const isConfigured =
@ -32,6 +63,23 @@ export const ForgedBlockNodeContent = ({ block }: Props) => {
variableId={variableId}
/>
))}
{isStreamingNextBlock && (
<Tooltip label="Text bubble content will be streamed">
<Flex
rounded="full"
p="1"
bgColor="gray.100"
color="purple.500"
borderWidth={1}
pos="absolute"
bottom="-15px"
left="118px"
zIndex={10}
>
<ThunderIcon fontSize="sm" />
</Flex>
</Tooltip>
)}
</Stack>
)
}

View File

@ -30,6 +30,21 @@ import { getZodInnerSchema } from '../../helpers/getZodInnerSchema'
import { TagsInput } from '@/components/TagsInput'
import { PrimitiveList } from '@/components/PrimitiveList'
const parseEnumItems = (
schema: z.ZodTypeAny,
layout?: ZodLayoutMetadata<ZodTypeAny>
) => {
const values = layout?.hiddenItems
? schema._def.values.filter((v: string) => !layout.hiddenItems?.includes(v))
: schema._def.values
if (layout?.toLabels)
return values.map((v: string) => ({
label: layout.toLabels!(v),
value: v,
}))
return values
}
const mdComponents = {
a: ({ href, children }) => (
<a
@ -134,13 +149,7 @@ export const ZodFieldLayout = ({
<DropdownList
currentItem={data ?? layout?.defaultValue}
onItemSelect={onDataChange}
items={
layout?.hiddenItems
? innerSchema._def.values.filter(
(v: any) => !layout.hiddenItems.includes(v)
)
: innerSchema._def.values
}
items={parseEnumItems(innerSchema, layout)}
label={layout?.label}
helperText={
layout?.helperText ? (

View File

@ -155,7 +155,7 @@ export const BlockNodeContent = ({
return <ZemanticAiNodeBody options={block.options} />
}
default: {
return <ForgedBlockNodeContent block={block} />
return <ForgedBlockNodeContent block={block} indices={indices} />
}
}
}

View File

@ -1,4 +1,4 @@
import { WebhookIcon } from '@/components/icons'
import { ThunderIcon } from '@/components/icons'
import { useUser } from '@/features/account/hooks/useUser'
import { useEditor } from '@/features/editor/providers/EditorProvider'
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
@ -18,7 +18,7 @@ export const WebPreview = () => {
const handleNewLogs = (logs: ContinueChatResponse['logs']) => {
logs?.forEach((log) => {
showToast({
icon: <WebhookIcon />,
icon: <ThunderIcon />,
status: log.status as 'success' | 'error' | 'info',
title: log.status === 'error' ? 'An error occured' : undefined,
description: log.description,

View File

@ -239,6 +239,12 @@
},
"queryParamsStr": {
"type": "string"
},
"areControlsDisplayed": {
"type": "boolean"
},
"isAutoplayEnabled": {
"type": "boolean"
}
}
}
@ -695,6 +701,30 @@
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"variableId": {
"type": "string"
},
"isExecutedOnClient": {
"type": "boolean"
},
"type": {
"type": "string",
"enum": [
"Pop",
"Shift"
]
},
"saveItemInVariableId": {
"type": "string"
}
},
"required": [
"type"
]
}
]
}
@ -4578,6 +4608,12 @@
},
"queryParamsStr": {
"type": "string"
},
"areControlsDisplayed": {
"type": "boolean"
},
"isAutoplayEnabled": {
"type": "boolean"
}
}
}
@ -5034,6 +5070,30 @@
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"variableId": {
"type": "string"
},
"isExecutedOnClient": {
"type": "boolean"
},
"type": {
"type": "string",
"enum": [
"Pop",
"Shift"
]
},
"saveItemInVariableId": {
"type": "string"
}
},
"required": [
"type"
]
}
]
}
@ -8054,6 +8114,12 @@
},
"queryParamsStr": {
"type": "string"
},
"areControlsDisplayed": {
"type": "boolean"
},
"isAutoplayEnabled": {
"type": "boolean"
}
}
}
@ -8510,6 +8576,30 @@
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"variableId": {
"type": "string"
},
"isExecutedOnClient": {
"type": "boolean"
},
"type": {
"type": "string",
"enum": [
"Pop",
"Shift"
]
},
"saveItemInVariableId": {
"type": "string"
}
},
"required": [
"type"
]
}
]
}
@ -16612,6 +16702,12 @@
},
"queryParamsStr": {
"type": "string"
},
"areControlsDisplayed": {
"type": "boolean"
},
"isAutoplayEnabled": {
"type": "boolean"
}
}
}
@ -17065,6 +17161,30 @@
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"variableId": {
"type": "string"
},
"isExecutedOnClient": {
"type": "boolean"
},
"type": {
"type": "string",
"enum": [
"Pop",
"Shift"
]
},
"saveItemInVariableId": {
"type": "string"
}
},
"required": [
"type"
]
}
]
}
@ -19905,6 +20025,149 @@
]
}
},
"tools": {
"type": "array",
"items": {
"oneOf": [
{
"type": "object",
"properties": {}
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"function"
]
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"parameters": {
"type": "array",
"items": {
"oneOf": [
{
"type": "object",
"properties": {}
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"string"
]
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"required": {
"type": "boolean"
}
},
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"number"
]
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"required": {
"type": "boolean"
}
},
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"boolean"
]
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"required": {
"type": "boolean"
}
},
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"enum"
]
},
"values": {
"type": "array",
"items": {
"type": "string"
}
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"required": {
"type": "boolean"
}
},
"required": [
"type"
]
}
]
}
},
"code": {
"type": "string"
}
},
"required": [
"type"
]
}
]
}
},
"responseMapping": {
"type": "array",
"items": {
@ -20169,6 +20432,7 @@
"model": {
"type": "string",
"enum": [
"claude-3-5-sonnet-20240620",
"claude-3-opus-20240229",
"claude-3-sonnet-20240229",
"claude-3-haiku-20240307",
@ -20246,6 +20510,149 @@
]
}
},
"tools": {
"type": "array",
"items": {
"oneOf": [
{
"type": "object",
"properties": {}
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"function"
]
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"parameters": {
"type": "array",
"items": {
"oneOf": [
{
"type": "object",
"properties": {}
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"string"
]
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"required": {
"type": "boolean"
}
},
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"number"
]
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"required": {
"type": "boolean"
}
},
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"boolean"
]
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"required": {
"type": "boolean"
}
},
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"enum"
]
},
"values": {
"type": "array",
"items": {
"type": "string"
}
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"required": {
"type": "boolean"
}
},
"required": [
"type"
]
}
]
}
},
"code": {
"type": "string"
}
},
"required": [
"type"
]
}
]
}
},
"systemMessage": {
"type": "string"
},
@ -20302,6 +20709,7 @@
"model": {
"type": "string",
"enum": [
"claude-3-5-sonnet-20240620",
"claude-3-opus-20240229",
"claude-3-sonnet-20240229",
"claude-3-haiku-20240307",
@ -22927,6 +23335,12 @@
},
"queryParamsStr": {
"type": "string"
},
"areControlsDisplayed": {
"type": "boolean"
},
"isAutoplayEnabled": {
"type": "boolean"
}
}
}
@ -23383,6 +23797,30 @@
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"variableId": {
"type": "string"
},
"isExecutedOnClient": {
"type": "boolean"
},
"type": {
"type": "string",
"enum": [
"Pop",
"Shift"
]
},
"saveItemInVariableId": {
"type": "string"
}
},
"required": [
"type"
]
}
]
}
@ -25772,6 +26210,12 @@
},
"queryParamsStr": {
"type": "string"
},
"areControlsDisplayed": {
"type": "boolean"
},
"isAutoplayEnabled": {
"type": "boolean"
}
}
}
@ -26228,6 +26672,30 @@
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"variableId": {
"type": "string"
},
"isExecutedOnClient": {
"type": "boolean"
},
"type": {
"type": "string",
"enum": [
"Pop",
"Shift"
]
},
"saveItemInVariableId": {
"type": "string"
}
},
"required": [
"type"
]
}
]
}

View File

@ -3523,6 +3523,12 @@
},
"queryParamsStr": {
"type": "string"
},
"areControlsDisplayed": {
"type": "boolean"
},
"isAutoplayEnabled": {
"type": "boolean"
}
}
}
@ -3979,6 +3985,30 @@
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"variableId": {
"type": "string"
},
"isExecutedOnClient": {
"type": "boolean"
},
"type": {
"type": "string",
"enum": [
"Pop",
"Shift"
]
},
"saveItemInVariableId": {
"type": "string"
}
},
"required": [
"type"
]
}
]
}
@ -7706,6 +7736,12 @@
},
"queryParamsStr": {
"type": "string"
},
"areControlsDisplayed": {
"type": "boolean"
},
"isAutoplayEnabled": {
"type": "boolean"
}
}
}
@ -8159,6 +8195,30 @@
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"variableId": {
"type": "string"
},
"isExecutedOnClient": {
"type": "boolean"
},
"type": {
"type": "string",
"enum": [
"Pop",
"Shift"
]
},
"saveItemInVariableId": {
"type": "string"
}
},
"required": [
"type"
]
}
]
}
@ -10999,6 +11059,149 @@
]
}
},
"tools": {
"type": "array",
"items": {
"oneOf": [
{
"type": "object",
"properties": {}
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"function"
]
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"parameters": {
"type": "array",
"items": {
"oneOf": [
{
"type": "object",
"properties": {}
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"string"
]
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"required": {
"type": "boolean"
}
},
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"number"
]
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"required": {
"type": "boolean"
}
},
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"boolean"
]
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"required": {
"type": "boolean"
}
},
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"enum"
]
},
"values": {
"type": "array",
"items": {
"type": "string"
}
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"required": {
"type": "boolean"
}
},
"required": [
"type"
]
}
]
}
},
"code": {
"type": "string"
}
},
"required": [
"type"
]
}
]
}
},
"responseMapping": {
"type": "array",
"items": {
@ -11263,6 +11466,7 @@
"model": {
"type": "string",
"enum": [
"claude-3-5-sonnet-20240620",
"claude-3-opus-20240229",
"claude-3-sonnet-20240229",
"claude-3-haiku-20240307",
@ -11340,6 +11544,149 @@
]
}
},
"tools": {
"type": "array",
"items": {
"oneOf": [
{
"type": "object",
"properties": {}
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"function"
]
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"parameters": {
"type": "array",
"items": {
"oneOf": [
{
"type": "object",
"properties": {}
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"string"
]
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"required": {
"type": "boolean"
}
},
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"number"
]
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"required": {
"type": "boolean"
}
},
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"boolean"
]
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"required": {
"type": "boolean"
}
},
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"enum"
]
},
"values": {
"type": "array",
"items": {
"type": "string"
}
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"required": {
"type": "boolean"
}
},
"required": [
"type"
]
}
]
}
},
"code": {
"type": "string"
}
},
"required": [
"type"
]
}
]
}
},
"systemMessage": {
"type": "string"
},
@ -11396,6 +11743,7 @@
"model": {
"type": "string",
"enum": [
"claude-3-5-sonnet-20240620",
"claude-3-opus-20240229",
"claude-3-sonnet-20240229",
"claude-3-haiku-20240307",
@ -12892,6 +13240,12 @@
},
"queryParamsStr": {
"type": "string"
},
"areControlsDisplayed": {
"type": "boolean"
},
"isAutoplayEnabled": {
"type": "boolean"
}
}
}

View File

@ -21,7 +21,7 @@
"@typebot.io/js": "workspace:*",
"@typebot.io/nextjs": "workspace:*",
"@typebot.io/prisma": "workspace:*",
"ai": "3.2.1",
"ai": "3.2.22",
"bot-engine": "workspace:*",
"cors": "2.8.5",
"google-spreadsheet": "4.1.1",