✨ Add Zemantic AI Integration block (#752)
Co-authored-by: Baptiste Arnaud <contact@baptiste-arnaud.fr>
This commit is contained in:
@@ -9,4 +9,5 @@ export enum IntegrationBlockType {
|
||||
PABBLY_CONNECT = 'Pabbly',
|
||||
CHATWOOT = 'Chatwoot',
|
||||
PIXEL = 'Pixel',
|
||||
ZEMANTIC_AI = 'Zemantic AI',
|
||||
}
|
||||
|
||||
@@ -9,3 +9,4 @@ export * from './webhook/schemas'
|
||||
export * from './zapier'
|
||||
export * from './pixel/schemas'
|
||||
export * from './pixel/constants'
|
||||
export * from './zemanticAi'
|
||||
|
||||
62
packages/schemas/features/blocks/integrations/zemanticAi.ts
Normal file
62
packages/schemas/features/blocks/integrations/zemanticAi.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { z } from 'zod'
|
||||
import { blockBaseSchema, credentialsBaseSchema } from '../baseSchemas'
|
||||
import { IntegrationBlockType } from './enums'
|
||||
|
||||
export const searchResponseValues = ['Summary', 'Results'] as const
|
||||
|
||||
export const zemanticAiOptionsSchema = z.object({
|
||||
credentialsId: z.string().optional(),
|
||||
projectId: z.string().optional(),
|
||||
systemPrompt: z.string().optional(),
|
||||
prompt: z.string().optional(),
|
||||
query: z.string().optional(),
|
||||
maxResults: z.number().int().optional(),
|
||||
responseMapping: z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
valueToExtract: z.preprocess(
|
||||
(val) => (!val ? 'Summary' : val),
|
||||
z.enum(searchResponseValues)
|
||||
),
|
||||
variableId: z.string().optional(),
|
||||
})
|
||||
),
|
||||
})
|
||||
|
||||
export const zemanticAiBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([IntegrationBlockType.ZEMANTIC_AI]),
|
||||
blockId: z.string().optional(),
|
||||
options: zemanticAiOptionsSchema,
|
||||
})
|
||||
)
|
||||
|
||||
export const zemanticAiCredentialsSchema = z
|
||||
.object({
|
||||
type: z.literal('zemanticAi'),
|
||||
data: z.object({
|
||||
apiKey: z.string(),
|
||||
}),
|
||||
})
|
||||
.merge(credentialsBaseSchema)
|
||||
|
||||
export const zemanticSearchResponseSchema = z.object({
|
||||
results: z.array(
|
||||
z.object({
|
||||
documentId: z.string(),
|
||||
text: z.string(),
|
||||
score: z.number(),
|
||||
})
|
||||
),
|
||||
summary: z.string(),
|
||||
})
|
||||
|
||||
export const zemanticAiDefaultOptions: ZemanticAiOptions = {
|
||||
maxResults: 3,
|
||||
responseMapping: [],
|
||||
}
|
||||
|
||||
export type ZemanticAiResponse = z.infer<typeof zemanticSearchResponseSchema>
|
||||
export type ZemanticAiCredentials = z.infer<typeof zemanticAiCredentialsSchema>
|
||||
export type ZemanticAiOptions = z.infer<typeof zemanticAiOptionsSchema>
|
||||
export type ZemanticAiBlock = z.infer<typeof zemanticAiBlockSchema>
|
||||
@@ -48,6 +48,7 @@ import {
|
||||
import { jumpBlockSchema } from './logic/jump'
|
||||
import { pictureChoiceBlockSchema } from './inputs/pictureChoice'
|
||||
import { Item } from '../items'
|
||||
import { zemanticAiBlockSchema } from './integrations/zemanticAi'
|
||||
|
||||
export type DraggableBlock =
|
||||
| BubbleBlock
|
||||
@@ -127,6 +128,7 @@ export const blockSchema = z.discriminatedUnion('type', [
|
||||
webhookBlockSchema,
|
||||
zapierBlockSchema,
|
||||
pixelBlockSchema,
|
||||
zemanticAiBlockSchema,
|
||||
])
|
||||
|
||||
export type Block = z.infer<typeof blockSchema>
|
||||
|
||||
@@ -4,6 +4,7 @@ import { googleSheetsCredentialsSchema } from './blocks/integrations/googleSheet
|
||||
import { openAICredentialsSchema } from './blocks/integrations/openai'
|
||||
import { smtpCredentialsSchema } from './blocks/integrations/sendEmail'
|
||||
import { whatsAppCredentialsSchema } from './whatsapp'
|
||||
import { zemanticAiCredentialsSchema } from './blocks'
|
||||
|
||||
export const credentialsSchema = z.discriminatedUnion('type', [
|
||||
smtpCredentialsSchema,
|
||||
@@ -11,6 +12,7 @@ export const credentialsSchema = z.discriminatedUnion('type', [
|
||||
stripeCredentialsSchema,
|
||||
openAICredentialsSchema,
|
||||
whatsAppCredentialsSchema,
|
||||
zemanticAiCredentialsSchema,
|
||||
])
|
||||
|
||||
export type Credentials = z.infer<typeof credentialsSchema>
|
||||
|
||||
Reference in New Issue
Block a user