UNPKG

@coursebuilder/core

Version:

Core package for Course Builder

149 lines (146 loc) 5.86 kB
import * as inngest from 'inngest'; import * as ai from 'ai'; import { z } from 'zod'; import { L as LlmProviderConfig, c as CourseBuilderAdapter } from '../../adapters-BjQ3VSch.js'; import { PartyProviderConfig } from '../../providers/partykit.js'; import { User } from '../../schemas/user-schema.js'; import { CoreInngestTrigger, CoreInngestHandler } from '../create-inngest-middleware.js'; import { ChatCompletionRequestMessage } from '../util/streaming-chat-prompt-executor.js'; import '@auth/core/adapters'; import '../../schemas/coupon-schema.js'; import '../../schemas/merchant-coupon-schema.js'; import '../../schemas/merchant-customer-schema.js'; import '../../schemas/merchant-product-schema.js'; import '../../schemas/price-schema.js'; import '../../schemas/product-schema.js'; import '../../schemas/purchase-schema.js'; import '../../schemas/purchase-user-transfer-schema.js'; import '../../schemas/resource-progress-schema.js'; import '../../schemas/video-resource.js'; import '../../schemas/upgradable-product-schema.js'; import '../../schemas/merchant-charge-schema.js'; import '../../schemas/merchant-price-schema.js'; import '../../schemas/content-resource-schema.js'; import '../../schemas/merchant-account-schema.js'; import '../../schemas/merchant-session.js'; import '../../schemas/merchant-subscription.js'; import '../../schemas/organization-member.js'; import '../../schemas/organization-schema.js'; import '../../schemas/subscription.js'; import '@auth/core'; import '@auth/core/providers/nodemailer'; import 'cookie'; import 'stripe'; import '../../lib/utils/logger.js'; import '@auth/core/providers'; import '../../schemas/subscriber-schema.js'; import '../../providers/slack.js'; import '../../schemas/purchase-info.js'; import '../../schemas/subscription-info.js'; declare const ChatResourceSchema: z.ZodObject<{ id: z.ZodString; type: z.ZodString; updatedAt: z.ZodNullable<z.ZodString>; createdAt: z.ZodNullable<z.ZodString>; title: z.ZodOptional<z.ZodNullable<z.ZodString>>; body: z.ZodOptional<z.ZodNullable<z.ZodString>>; transcript: z.ZodOptional<z.ZodNullable<z.ZodString>>; wordLevelSrt: z.ZodOptional<z.ZodNullable<z.ZodString>>; resources: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>; }, "strip", z.ZodTypeAny, { type: string; id: string; createdAt: string | null; updatedAt: string | null; resources?: any[] | undefined; body?: string | null | undefined; title?: string | null | undefined; transcript?: string | null | undefined; wordLevelSrt?: string | null | undefined; }, { type: string; id: string; createdAt: string | null; updatedAt: string | null; resources?: any[] | undefined; body?: string | null | undefined; title?: string | null | undefined; transcript?: string | null | undefined; wordLevelSrt?: string | null | undefined; }>; type ChatResource = z.infer<typeof ChatResourceSchema>; declare const RESOURCE_CHAT_REQUEST_EVENT = "resource/chat-request-event"; type ResourceChat = { name: typeof RESOURCE_CHAT_REQUEST_EVENT; data: { resourceId: string; messages: ChatCompletionRequestMessage[]; promptId?: string; selectedWorkflow: string; model?: string; }; user: Record<string, any>; }; declare const resourceChatConfig: { id: string; name: string; rateLimit: { key: string; limit: number; period: `${number}m`; }; }; declare const resourceChatTrigger: CoreInngestTrigger; declare enum ChatCompletionRequestMessageRoleEnum { System = "system", User = "user", Assistant = "assistant", Tool = "tool" } /** * TODO: Cancellation conditions need to be added $$ */ declare const resourceChatHandler: CoreInngestHandler; /** * loads the workflow from sanity based on the trigger and then executes the workflow using the `resource` as * input that is parsed by liquid into the prompt * * This treats the system prompt as "special" from the loaded workflow since it is added to the beginning of the prompt * in the chat context, but additional steps are executed as normal * * @param step * @param workflowTrigger * @param resourceId * @param messages * @param resource * @param currentFeedback */ declare function resourceChatWorkflowExecutor({ step, workflowTrigger, resourceId, messages, resource, user, openaiProvider, partyProvider, db, model, }: { openaiProvider: LlmProviderConfig; partyProvider: PartyProviderConfig; db: CourseBuilderAdapter; resource: ChatResource; step: any; workflowTrigger: string; resourceId: string; messages: ChatCompletionRequestMessage[]; user: User; model?: string; }): Promise<ai.CoreMessage[]>; declare const resourceChat: { config: { id: string; name: string; rateLimit: { key: string; limit: number; period: `${number}m`; }; }; trigger: { event: "video/srt-ready" | "video/transcript-ready-event" | "resource/chat-request-event" | "video/status-check" | "video/video-uploaded" | "video-resource/created" | "mux/web-hook-event" | "stripe/checkout-session-completed" | "stripe/customer-subscription-created" | "stripe/customer-subscription-updated" | "stripe/invoice-payment-succeeded" | "commerce/update-purchase-status" | "commerce/new-purchase-created" | "commerce/new-subscription-created" | "commerce/full-price-coupon-redeemed" | "commerce/refund-processed"; if?: string | undefined; } & Partial<Record<"cron", never>>; handler: inngest.Handler.Any; }; export { ChatCompletionRequestMessageRoleEnum, type ChatResource, ChatResourceSchema, RESOURCE_CHAT_REQUEST_EVENT, type ResourceChat, resourceChat, resourceChatConfig, resourceChatHandler, resourceChatTrigger, resourceChatWorkflowExecutor };