@m5kdev/backend 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/lib/posthog.d.ts +0 -1
- package/dist/src/lib/sentry.d.ts +0 -1
- package/dist/src/modules/access/access.repository.d.ts +0 -1
- package/dist/src/modules/access/access.service.d.ts +0 -1
- package/dist/src/modules/access/access.test.d.ts +0 -1
- package/dist/src/modules/access/access.utils.d.ts +0 -1
- package/dist/src/modules/ai/ai.db.d.ts +0 -1
- package/dist/src/modules/ai/ai.prompt.d.ts +0 -1
- package/dist/src/modules/ai/ai.repository.d.ts +0 -1
- package/dist/src/modules/ai/ai.router.d.ts +0 -1
- package/dist/src/modules/ai/ai.service.d.ts +0 -1
- package/dist/src/modules/ai/ai.trpc.d.ts +5 -42
- package/dist/src/modules/ai/ai.trpc.js +5 -5
- package/dist/src/modules/ai/ideogram/ideogram.constants.d.ts +0 -1
- package/dist/src/modules/ai/ideogram/ideogram.dto.d.ts +0 -1
- package/dist/src/modules/ai/ideogram/ideogram.prompt.d.ts +0 -1
- package/dist/src/modules/ai/ideogram/ideogram.repository.d.ts +0 -1
- package/dist/src/modules/ai/ideogram/ideogram.service.d.ts +0 -1
- package/dist/src/modules/auth/auth.db.d.ts +0 -1
- package/dist/src/modules/auth/auth.dto.d.ts +7 -8
- package/dist/src/modules/auth/auth.lib.d.ts +8 -9
- package/dist/src/modules/auth/auth.middleware.d.ts +0 -1
- package/dist/src/modules/auth/auth.repository.d.ts +0 -1
- package/dist/src/modules/auth/auth.service.d.ts +0 -1
- package/dist/src/modules/auth/auth.trpc.d.ts +52 -89
- package/dist/src/modules/auth/auth.trpc.js +55 -53
- package/dist/src/modules/auth/auth.utils.d.ts +0 -1
- package/dist/src/modules/base/base.abstract.d.ts +0 -1
- package/dist/src/modules/base/base.dto.d.ts +2 -3
- package/dist/src/modules/base/base.grants.d.ts +0 -1
- package/dist/src/modules/base/base.grants.test.d.ts +0 -1
- package/dist/src/modules/base/base.repository.d.ts +0 -1
- package/dist/src/modules/base/base.service.d.ts +2 -4
- package/dist/src/modules/base/base.types.d.ts +0 -1
- package/dist/src/modules/billing/billing.db.d.ts +0 -1
- package/dist/src/modules/billing/billing.repository.d.ts +0 -1
- package/dist/src/modules/billing/billing.router.d.ts +0 -1
- package/dist/src/modules/billing/billing.service.d.ts +0 -1
- package/dist/src/modules/billing/billing.trpc.d.ts +6 -43
- package/dist/src/modules/billing/billing.trpc.js +7 -7
- package/dist/src/modules/clay/clay.repository.d.ts +0 -1
- package/dist/src/modules/clay/clay.service.d.ts +0 -1
- package/dist/src/modules/connect/connect.db.d.ts +0 -1
- package/dist/src/modules/connect/connect.dto.d.ts +8 -9
- package/dist/src/modules/connect/connect.linkedin.d.ts +0 -1
- package/dist/src/modules/connect/connect.oauth.d.ts +0 -1
- package/dist/src/modules/connect/connect.repository.d.ts +3 -4
- package/dist/src/modules/connect/connect.router.d.ts +0 -1
- package/dist/src/modules/connect/connect.service.d.ts +6 -7
- package/dist/src/modules/connect/connect.trpc.d.ts +9 -46
- package/dist/src/modules/connect/connect.trpc.js +7 -7
- package/dist/src/modules/connect/connect.types.d.ts +0 -1
- package/dist/src/modules/crypto/crypto.db.d.ts +0 -1
- package/dist/src/modules/crypto/crypto.repository.d.ts +0 -1
- package/dist/src/modules/crypto/crypto.service.d.ts +0 -1
- package/dist/src/modules/email/email.service.d.ts +0 -1
- package/dist/src/modules/file/file.repository.d.ts +0 -1
- package/dist/src/modules/file/file.router.d.ts +0 -1
- package/dist/src/modules/file/file.service.d.ts +0 -1
- package/dist/src/modules/recurrence/recurrence.db.d.ts +0 -1
- package/dist/src/modules/recurrence/recurrence.repository.d.ts +0 -1
- package/dist/src/modules/recurrence/recurrence.service.d.ts +0 -1
- package/dist/src/modules/recurrence/recurrence.trpc.d.ts +11 -48
- package/dist/src/modules/recurrence/recurrence.trpc.js +17 -17
- package/dist/src/modules/social/social.dto.d.ts +0 -1
- package/dist/src/modules/social/social.linkedin.d.ts +0 -1
- package/dist/src/modules/social/social.linkedin.test.d.ts +0 -1
- package/dist/src/modules/social/social.service.d.ts +0 -1
- package/dist/src/modules/social/social.types.d.ts +0 -1
- package/dist/src/modules/tag/tag.db.d.ts +0 -1
- package/dist/src/modules/tag/tag.dto.d.ts +0 -1
- package/dist/src/modules/tag/tag.repository.d.ts +0 -1
- package/dist/src/modules/tag/tag.service.d.ts +0 -1
- package/dist/src/modules/tag/tag.trpc.d.ts +10 -47
- package/dist/src/modules/tag/tag.trpc.js +15 -15
- package/dist/src/modules/utils/applyPagination.d.ts +0 -1
- package/dist/src/modules/utils/applySorting.d.ts +0 -1
- package/dist/src/modules/utils/getConditionsFromFilters.d.ts +0 -1
- package/dist/src/modules/video/video.service.d.ts +0 -1
- package/dist/src/modules/webhook/webhook.constants.d.ts +0 -1
- package/dist/src/modules/webhook/webhook.db.d.ts +0 -1
- package/dist/src/modules/webhook/webhook.dto.d.ts +0 -1
- package/dist/src/modules/webhook/webhook.repository.d.ts +0 -1
- package/dist/src/modules/webhook/webhook.router.d.ts +0 -1
- package/dist/src/modules/webhook/webhook.service.d.ts +0 -1
- package/dist/src/modules/workflow/workflow.db.d.ts +0 -1
- package/dist/src/modules/workflow/workflow.repository.d.ts +0 -1
- package/dist/src/modules/workflow/workflow.service.d.ts +0 -1
- package/dist/src/modules/workflow/workflow.trpc.d.ts +6 -43
- package/dist/src/modules/workflow/workflow.trpc.js +7 -7
- package/dist/src/modules/workflow/workflow.types.d.ts +0 -1
- package/dist/src/modules/workflow/workflow.utils.d.ts +0 -1
- package/dist/src/test/stubs/utils.d.ts +0 -1
- package/dist/src/trpc/context.d.ts +4 -5
- package/dist/src/trpc/index.d.ts +0 -1
- package/dist/src/trpc/procedures.d.ts +24 -25
- package/dist/src/trpc/utils.d.ts +0 -1
- package/dist/src/types.d.ts +61 -209
- package/dist/src/types.js +4 -5
- package/dist/src/utils/errors.d.ts +0 -1
- package/dist/src/utils/logger.d.ts +0 -1
- package/dist/src/utils/posthog.d.ts +0 -1
- package/dist/src/utils/trpc.d.ts +58 -0
- package/dist/src/utils/trpc.js +63 -0
- package/dist/src/utils/types.d.ts +0 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -8
- package/.cursor/rules/backend.mdc +0 -70
- package/.turbo/turbo-build.log +0 -5
- package/.turbo/turbo-check-types.log +0 -5
- package/.turbo/turbo-lint$colon$fix.log +0 -255
- package/CHANGELOG.md +0 -37
- package/dist/src/lib/posthog.d.ts.map +0 -1
- package/dist/src/lib/sentry.d.ts.map +0 -1
- package/dist/src/modules/access/access.repository.d.ts.map +0 -1
- package/dist/src/modules/access/access.service.d.ts.map +0 -1
- package/dist/src/modules/access/access.test.d.ts.map +0 -1
- package/dist/src/modules/access/access.utils.d.ts.map +0 -1
- package/dist/src/modules/ai/ai.db.d.ts.map +0 -1
- package/dist/src/modules/ai/ai.prompt.d.ts.map +0 -1
- package/dist/src/modules/ai/ai.repository.d.ts.map +0 -1
- package/dist/src/modules/ai/ai.router.d.ts.map +0 -1
- package/dist/src/modules/ai/ai.service.d.ts.map +0 -1
- package/dist/src/modules/ai/ai.trpc.d.ts.map +0 -1
- package/dist/src/modules/ai/ideogram/ideogram.constants.d.ts.map +0 -1
- package/dist/src/modules/ai/ideogram/ideogram.dto.d.ts.map +0 -1
- package/dist/src/modules/ai/ideogram/ideogram.prompt.d.ts.map +0 -1
- package/dist/src/modules/ai/ideogram/ideogram.repository.d.ts.map +0 -1
- package/dist/src/modules/ai/ideogram/ideogram.service.d.ts.map +0 -1
- package/dist/src/modules/auth/auth.db.d.ts.map +0 -1
- package/dist/src/modules/auth/auth.dto.d.ts.map +0 -1
- package/dist/src/modules/auth/auth.lib.d.ts.map +0 -1
- package/dist/src/modules/auth/auth.middleware.d.ts.map +0 -1
- package/dist/src/modules/auth/auth.repository.d.ts.map +0 -1
- package/dist/src/modules/auth/auth.service.d.ts.map +0 -1
- package/dist/src/modules/auth/auth.trpc.d.ts.map +0 -1
- package/dist/src/modules/auth/auth.utils.d.ts.map +0 -1
- package/dist/src/modules/base/base.abstract.d.ts.map +0 -1
- package/dist/src/modules/base/base.dto.d.ts.map +0 -1
- package/dist/src/modules/base/base.grants.d.ts.map +0 -1
- package/dist/src/modules/base/base.grants.test.d.ts.map +0 -1
- package/dist/src/modules/base/base.repository.d.ts.map +0 -1
- package/dist/src/modules/base/base.service.d.ts.map +0 -1
- package/dist/src/modules/base/base.types.d.ts.map +0 -1
- package/dist/src/modules/billing/billing.db.d.ts.map +0 -1
- package/dist/src/modules/billing/billing.repository.d.ts.map +0 -1
- package/dist/src/modules/billing/billing.router.d.ts.map +0 -1
- package/dist/src/modules/billing/billing.service.d.ts.map +0 -1
- package/dist/src/modules/billing/billing.trpc.d.ts.map +0 -1
- package/dist/src/modules/clay/clay.repository.d.ts.map +0 -1
- package/dist/src/modules/clay/clay.service.d.ts.map +0 -1
- package/dist/src/modules/connect/connect.db.d.ts.map +0 -1
- package/dist/src/modules/connect/connect.dto.d.ts.map +0 -1
- package/dist/src/modules/connect/connect.linkedin.d.ts.map +0 -1
- package/dist/src/modules/connect/connect.oauth.d.ts.map +0 -1
- package/dist/src/modules/connect/connect.repository.d.ts.map +0 -1
- package/dist/src/modules/connect/connect.router.d.ts.map +0 -1
- package/dist/src/modules/connect/connect.service.d.ts.map +0 -1
- package/dist/src/modules/connect/connect.trpc.d.ts.map +0 -1
- package/dist/src/modules/connect/connect.types.d.ts.map +0 -1
- package/dist/src/modules/crypto/crypto.db.d.ts.map +0 -1
- package/dist/src/modules/crypto/crypto.repository.d.ts.map +0 -1
- package/dist/src/modules/crypto/crypto.service.d.ts.map +0 -1
- package/dist/src/modules/email/email.service.d.ts.map +0 -1
- package/dist/src/modules/file/file.repository.d.ts.map +0 -1
- package/dist/src/modules/file/file.router.d.ts.map +0 -1
- package/dist/src/modules/file/file.service.d.ts.map +0 -1
- package/dist/src/modules/recurrence/recurrence.db.d.ts.map +0 -1
- package/dist/src/modules/recurrence/recurrence.repository.d.ts.map +0 -1
- package/dist/src/modules/recurrence/recurrence.service.d.ts.map +0 -1
- package/dist/src/modules/recurrence/recurrence.trpc.d.ts.map +0 -1
- package/dist/src/modules/social/social.dto.d.ts.map +0 -1
- package/dist/src/modules/social/social.linkedin.d.ts.map +0 -1
- package/dist/src/modules/social/social.linkedin.test.d.ts.map +0 -1
- package/dist/src/modules/social/social.service.d.ts.map +0 -1
- package/dist/src/modules/social/social.types.d.ts.map +0 -1
- package/dist/src/modules/tag/tag.db.d.ts.map +0 -1
- package/dist/src/modules/tag/tag.dto.d.ts.map +0 -1
- package/dist/src/modules/tag/tag.repository.d.ts.map +0 -1
- package/dist/src/modules/tag/tag.service.d.ts.map +0 -1
- package/dist/src/modules/tag/tag.trpc.d.ts.map +0 -1
- package/dist/src/modules/utils/applyPagination.d.ts.map +0 -1
- package/dist/src/modules/utils/applySorting.d.ts.map +0 -1
- package/dist/src/modules/utils/getConditionsFromFilters.d.ts.map +0 -1
- package/dist/src/modules/video/video.service.d.ts.map +0 -1
- package/dist/src/modules/webhook/webhook.constants.d.ts.map +0 -1
- package/dist/src/modules/webhook/webhook.db.d.ts.map +0 -1
- package/dist/src/modules/webhook/webhook.dto.d.ts.map +0 -1
- package/dist/src/modules/webhook/webhook.repository.d.ts.map +0 -1
- package/dist/src/modules/webhook/webhook.router.d.ts.map +0 -1
- package/dist/src/modules/webhook/webhook.service.d.ts.map +0 -1
- package/dist/src/modules/workflow/workflow.db.d.ts.map +0 -1
- package/dist/src/modules/workflow/workflow.repository.d.ts.map +0 -1
- package/dist/src/modules/workflow/workflow.service.d.ts.map +0 -1
- package/dist/src/modules/workflow/workflow.trpc.d.ts.map +0 -1
- package/dist/src/modules/workflow/workflow.types.d.ts.map +0 -1
- package/dist/src/modules/workflow/workflow.utils.d.ts.map +0 -1
- package/dist/src/test/stubs/utils.d.ts.map +0 -1
- package/dist/src/trpc/context.d.ts.map +0 -1
- package/dist/src/trpc/index.d.ts.map +0 -1
- package/dist/src/trpc/procedures.d.ts.map +0 -1
- package/dist/src/trpc/utils.d.ts.map +0 -1
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/utils/errors.d.ts.map +0 -1
- package/dist/src/utils/logger.d.ts.map +0 -1
- package/dist/src/utils/posthog.d.ts.map +0 -1
- package/dist/src/utils/types.d.ts.map +0 -1
- package/jest.config.ts +0 -19
- package/src/lib/posthog.ts +0 -5
- package/src/lib/sentry.ts +0 -8
- package/src/modules/access/access.repository.ts +0 -36
- package/src/modules/access/access.service.ts +0 -81
- package/src/modules/access/access.test.ts +0 -216
- package/src/modules/access/access.utils.ts +0 -46
- package/src/modules/ai/ai.db.ts +0 -38
- package/src/modules/ai/ai.prompt.ts +0 -47
- package/src/modules/ai/ai.repository.ts +0 -53
- package/src/modules/ai/ai.router.ts +0 -148
- package/src/modules/ai/ai.service.ts +0 -310
- package/src/modules/ai/ai.trpc.ts +0 -22
- package/src/modules/ai/ideogram/ideogram.constants.ts +0 -170
- package/src/modules/ai/ideogram/ideogram.dto.ts +0 -64
- package/src/modules/ai/ideogram/ideogram.prompt.ts +0 -858
- package/src/modules/ai/ideogram/ideogram.repository.ts +0 -39
- package/src/modules/ai/ideogram/ideogram.service.ts +0 -14
- package/src/modules/auth/auth.db.ts +0 -224
- package/src/modules/auth/auth.dto.ts +0 -47
- package/src/modules/auth/auth.lib.ts +0 -349
- package/src/modules/auth/auth.middleware.ts +0 -62
- package/src/modules/auth/auth.repository.ts +0 -672
- package/src/modules/auth/auth.service.ts +0 -261
- package/src/modules/auth/auth.trpc.ts +0 -208
- package/src/modules/auth/auth.utils.ts +0 -117
- package/src/modules/base/base.abstract.ts +0 -62
- package/src/modules/base/base.dto.ts +0 -206
- package/src/modules/base/base.grants.test.ts +0 -861
- package/src/modules/base/base.grants.ts +0 -199
- package/src/modules/base/base.repository.ts +0 -433
- package/src/modules/base/base.service.ts +0 -154
- package/src/modules/base/base.types.ts +0 -7
- package/src/modules/billing/billing.db.ts +0 -27
- package/src/modules/billing/billing.repository.ts +0 -328
- package/src/modules/billing/billing.router.ts +0 -77
- package/src/modules/billing/billing.service.ts +0 -177
- package/src/modules/billing/billing.trpc.ts +0 -17
- package/src/modules/clay/clay.repository.ts +0 -29
- package/src/modules/clay/clay.service.ts +0 -61
- package/src/modules/connect/connect.db.ts +0 -32
- package/src/modules/connect/connect.dto.ts +0 -44
- package/src/modules/connect/connect.linkedin.ts +0 -70
- package/src/modules/connect/connect.oauth.ts +0 -288
- package/src/modules/connect/connect.repository.ts +0 -65
- package/src/modules/connect/connect.router.ts +0 -76
- package/src/modules/connect/connect.service.ts +0 -171
- package/src/modules/connect/connect.trpc.ts +0 -26
- package/src/modules/connect/connect.types.ts +0 -27
- package/src/modules/crypto/crypto.db.ts +0 -15
- package/src/modules/crypto/crypto.repository.ts +0 -13
- package/src/modules/crypto/crypto.service.ts +0 -57
- package/src/modules/email/email.service.ts +0 -222
- package/src/modules/file/file.repository.ts +0 -95
- package/src/modules/file/file.router.ts +0 -108
- package/src/modules/file/file.service.ts +0 -186
- package/src/modules/recurrence/recurrence.db.ts +0 -79
- package/src/modules/recurrence/recurrence.repository.ts +0 -70
- package/src/modules/recurrence/recurrence.service.ts +0 -105
- package/src/modules/recurrence/recurrence.trpc.ts +0 -82
- package/src/modules/social/social.dto.ts +0 -22
- package/src/modules/social/social.linkedin.test.ts +0 -277
- package/src/modules/social/social.linkedin.ts +0 -593
- package/src/modules/social/social.service.ts +0 -112
- package/src/modules/social/social.types.ts +0 -43
- package/src/modules/tag/tag.db.ts +0 -41
- package/src/modules/tag/tag.dto.ts +0 -18
- package/src/modules/tag/tag.repository.ts +0 -222
- package/src/modules/tag/tag.service.ts +0 -48
- package/src/modules/tag/tag.trpc.ts +0 -62
- package/src/modules/uploads/0581796b-8845-420d-bd95-cd7de79f6d37.webm +0 -0
- package/src/modules/uploads/33b1e649-6727-4bd0-94d0-a0b363646865.webm +0 -0
- package/src/modules/uploads/49a8c4c0-54d7-4c94-bef4-c93c029f9ed0.webm +0 -0
- package/src/modules/uploads/50e31e38-a2f0-47ca-8b7d-2d7fcad9267d.webm +0 -0
- package/src/modules/uploads/72ac8cf9-c3a7-4cd8-8a78-6d8e137a4c7e.webm +0 -0
- package/src/modules/uploads/75293649-d966-46cd-a675-67518958ae9c.png +0 -0
- package/src/modules/uploads/88b7b867-ce15-4891-bf73-81305a7de1f7.wav +0 -0
- package/src/modules/uploads/a5d6fee8-6a59-42c6-9d4a-ac8a3c5e7245.webm +0 -0
- package/src/modules/uploads/c13a9785-ca5a-4983-af30-b338ed76d370.webm +0 -0
- package/src/modules/uploads/caa1a5a7-71ba-4381-902d-7e2cafdf6dcb.webm +0 -0
- package/src/modules/uploads/cbeb0b81-374d-445b-914b-40ace7c8e031.webm +0 -0
- package/src/modules/uploads/d626aa82-b10f-493f-aee7-87bfb3361dfc.webm +0 -0
- package/src/modules/uploads/d7de4c16-de0c-495d-9612-e72260a6ecca.png +0 -0
- package/src/modules/uploads/e532e38a-6421-400e-8a5f-8e7bc8ce411b.wav +0 -0
- package/src/modules/uploads/e86ec867-6adf-4c51-84e0-00b0836625e8.webm +0 -0
- package/src/modules/utils/applyPagination.ts +0 -13
- package/src/modules/utils/applySorting.ts +0 -21
- package/src/modules/utils/getConditionsFromFilters.ts +0 -216
- package/src/modules/video/video.service.ts +0 -89
- package/src/modules/webhook/webhook.constants.ts +0 -9
- package/src/modules/webhook/webhook.db.ts +0 -15
- package/src/modules/webhook/webhook.dto.ts +0 -9
- package/src/modules/webhook/webhook.repository.ts +0 -68
- package/src/modules/webhook/webhook.router.ts +0 -29
- package/src/modules/webhook/webhook.service.ts +0 -78
- package/src/modules/workflow/workflow.db.ts +0 -29
- package/src/modules/workflow/workflow.repository.ts +0 -171
- package/src/modules/workflow/workflow.service.ts +0 -56
- package/src/modules/workflow/workflow.trpc.ts +0 -26
- package/src/modules/workflow/workflow.types.ts +0 -30
- package/src/modules/workflow/workflow.utils.ts +0 -259
- package/src/test/stubs/utils.ts +0 -2
- package/src/trpc/context.ts +0 -21
- package/src/trpc/index.ts +0 -3
- package/src/trpc/procedures.ts +0 -43
- package/src/trpc/utils.ts +0 -20
- package/src/types.ts +0 -22
- package/src/utils/errors.ts +0 -148
- package/src/utils/logger.ts +0 -8
- package/src/utils/posthog.ts +0 -43
- package/src/utils/types.ts +0 -5
- package/tsconfig.json +0 -21
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type AiEmbeddingModel,
|
|
3
|
-
type AiModel,
|
|
4
|
-
OPENAI_TEXT_EMBEDDING_3_SMALL,
|
|
5
|
-
} from "@m5kdev/commons/modules/ai/ai.constants";
|
|
6
|
-
import { arrayToPseudoXML } from "@m5kdev/commons/modules/ai/ai.utils";
|
|
7
|
-
import type { Mastra } from "@mastra/core";
|
|
8
|
-
import { RequestContext } from "@mastra/core/request-context";
|
|
9
|
-
import type { FullOutput, MastraModelOutput } from "@mastra/core/stream";
|
|
10
|
-
import { MDocument } from "@mastra/rag";
|
|
11
|
-
import type { OpenRouterProvider } from "@openrouter/ai-sdk-provider";
|
|
12
|
-
import { embed, embedMany, generateObject, generateText } from "ai";
|
|
13
|
-
import { err, ok } from "neverthrow";
|
|
14
|
-
import type Replicate from "replicate";
|
|
15
|
-
import type { ZodType, z } from "zod";
|
|
16
|
-
import type { AiUsageRepository, AiUsageRow } from "#modules/ai/ai.repository";
|
|
17
|
-
import type {
|
|
18
|
-
IdeogramV3GenerateInput,
|
|
19
|
-
IdeogramV3GenerateOutput,
|
|
20
|
-
} from "#modules/ai/ideogram/ideogram.dto";
|
|
21
|
-
import type { IdeogramService } from "#modules/ai/ideogram/ideogram.service";
|
|
22
|
-
import type { User } from "#modules/auth/auth.lib";
|
|
23
|
-
import type { ServerResultAsync } from "#modules/base/base.dto";
|
|
24
|
-
import { BaseService } from "#modules/base/base.service";
|
|
25
|
-
|
|
26
|
-
type MastraAgent = ReturnType<Mastra["getAgent"]>;
|
|
27
|
-
type MastraAgentGenerateOptions = Parameters<MastraAgent["generate"]>[1];
|
|
28
|
-
type MessageListInput = { role: "user" | "assistant" | "system"; content: string }[];
|
|
29
|
-
|
|
30
|
-
export class AIService<MastraInstance extends Mastra> extends BaseService<
|
|
31
|
-
{ aiUsage?: AiUsageRepository },
|
|
32
|
-
{ ideogram?: IdeogramService }
|
|
33
|
-
> {
|
|
34
|
-
helpers = {
|
|
35
|
-
arrayToPseudoXML,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
mastra?: MastraInstance;
|
|
39
|
-
openrouter?: OpenRouterProvider;
|
|
40
|
-
replicate?: Replicate;
|
|
41
|
-
|
|
42
|
-
constructor(
|
|
43
|
-
repositories: { aiUsage?: AiUsageRepository },
|
|
44
|
-
services: { ideogram?: IdeogramService },
|
|
45
|
-
libs: { mastra?: MastraInstance; openrouter?: OpenRouterProvider; replicate?: Replicate }
|
|
46
|
-
) {
|
|
47
|
-
super(repositories, services);
|
|
48
|
-
this.mastra = libs.mastra;
|
|
49
|
-
this.openrouter = libs.openrouter;
|
|
50
|
-
this.replicate = libs.replicate;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
getMastra(): MastraInstance {
|
|
54
|
-
if (!this.mastra) {
|
|
55
|
-
throw new Error("Mastra is not available");
|
|
56
|
-
}
|
|
57
|
-
return this.mastra;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
prepareModel(model: AiModel): any {
|
|
61
|
-
if (!this.openrouter) {
|
|
62
|
-
throw new Error("OpenRouter is not configured");
|
|
63
|
-
}
|
|
64
|
-
const openrouterModel = this.openrouter.chat(model);
|
|
65
|
-
return openrouterModel;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
prepareEmbeddingModel(model: AiEmbeddingModel): any {
|
|
69
|
-
if (!this.openrouter) {
|
|
70
|
-
throw new Error("OpenRouter is not configured");
|
|
71
|
-
}
|
|
72
|
-
const openrouterModel = this.openrouter.textEmbeddingModel(model);
|
|
73
|
-
return openrouterModel;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async agentUse(
|
|
77
|
-
agent: string,
|
|
78
|
-
options: MastraAgentGenerateOptions & { prompt?: string; messages?: MessageListInput },
|
|
79
|
-
ctx?: { user: User; model?: string }
|
|
80
|
-
): ServerResultAsync<Awaited<ReturnType<MastraModelOutput<any>["getFullOutput"]>>> {
|
|
81
|
-
return this.throwableAsync(async () => {
|
|
82
|
-
this.logger.info("AGENT USE");
|
|
83
|
-
const { prompt, messages, ...rest } = options;
|
|
84
|
-
const payload = messages || prompt;
|
|
85
|
-
if (!payload) return this.error("BAD_REQUEST", "No prompt or messages provided");
|
|
86
|
-
const requestContext = options.requestContext ?? new RequestContext();
|
|
87
|
-
|
|
88
|
-
if (ctx?.user) {
|
|
89
|
-
requestContext.set("userId", ctx.user.id);
|
|
90
|
-
}
|
|
91
|
-
if (ctx?.model) {
|
|
92
|
-
requestContext.set("model", ctx.model);
|
|
93
|
-
}
|
|
94
|
-
const mAgent = this.getMastra().getAgent(agent);
|
|
95
|
-
|
|
96
|
-
const result = await mAgent.generate(payload as any, {
|
|
97
|
-
...rest,
|
|
98
|
-
requestContext: rest.requestContext ?? requestContext,
|
|
99
|
-
});
|
|
100
|
-
this.logger.info("AGENT USE DONE");
|
|
101
|
-
if (this.repository.aiUsage) {
|
|
102
|
-
const createUsageResult = await this.repository.aiUsage.create({
|
|
103
|
-
userId: ctx?.user?.id,
|
|
104
|
-
model: ctx?.model ?? "unknown",
|
|
105
|
-
provider: "openrouter",
|
|
106
|
-
feature: agent,
|
|
107
|
-
traceId: result.traceId,
|
|
108
|
-
inputTokens: result.usage.inputTokens,
|
|
109
|
-
outputTokens: result.usage.outputTokens,
|
|
110
|
-
totalTokens: result.usage.totalTokens,
|
|
111
|
-
cost: (result?.providerMetadata?.openrouter?.usage as any)?.cost ?? 0,
|
|
112
|
-
});
|
|
113
|
-
if (createUsageResult.isErr()) return err(createUsageResult.error);
|
|
114
|
-
}
|
|
115
|
-
this.logger.info("AGENT USE CREATED USAGE");
|
|
116
|
-
return ok(result);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
async agentText(
|
|
121
|
-
agent: string,
|
|
122
|
-
options: MastraAgentGenerateOptions & { prompt?: string; messages?: MessageListInput },
|
|
123
|
-
ctx?: { user: User; model?: string }
|
|
124
|
-
): ServerResultAsync<string> {
|
|
125
|
-
const result = await this.agentUse(agent, options, ctx);
|
|
126
|
-
if (result.isErr())
|
|
127
|
-
return this.error("SERVICE_UNAVAILABLE", "AI: Agent text failed", { cause: result.error });
|
|
128
|
-
return ok(result.value.text);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
async agentTextResult(
|
|
132
|
-
agent: string,
|
|
133
|
-
options: MastraAgentGenerateOptions & { prompt?: string; messages?: MessageListInput },
|
|
134
|
-
ctx?: { user: User; model?: string }
|
|
135
|
-
): ServerResultAsync<FullOutput<any>> {
|
|
136
|
-
const result = await this.agentUse(agent, options, ctx);
|
|
137
|
-
if (result.isErr()) return err(result.error);
|
|
138
|
-
return ok(result.value);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
async agentObject<T extends ZodType<any>>(
|
|
142
|
-
agent: string,
|
|
143
|
-
options: MastraAgentGenerateOptions & {
|
|
144
|
-
schema: T;
|
|
145
|
-
prompt?: string;
|
|
146
|
-
messages?: MessageListInput;
|
|
147
|
-
},
|
|
148
|
-
ctx?: { user: User; model?: string }
|
|
149
|
-
): ServerResultAsync<z.infer<T>> {
|
|
150
|
-
const { schema, ...rest } = options;
|
|
151
|
-
const result = await this.agentUse(agent, { ...rest, structuredOutput: { schema } }, ctx);
|
|
152
|
-
if (result.isErr())
|
|
153
|
-
return this.error("SERVICE_UNAVAILABLE", "AI: Agent object failed", { cause: result.error });
|
|
154
|
-
return ok(result.value.object as z.infer<T>);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
async agentObjectResult<T extends ZodType<any>>(
|
|
158
|
-
agent: string,
|
|
159
|
-
options: MastraAgentGenerateOptions & {
|
|
160
|
-
schema: T;
|
|
161
|
-
prompt?: string;
|
|
162
|
-
messages?: MessageListInput;
|
|
163
|
-
},
|
|
164
|
-
ctx?: { user: User; model?: string }
|
|
165
|
-
): ServerResultAsync<FullOutput<any> & { object: z.infer<T> }> {
|
|
166
|
-
this.logger.info("AGENT OBJECT RESULT");
|
|
167
|
-
const { schema, ...rest } = options;
|
|
168
|
-
const result = await this.agentUse(agent, { ...rest, structuredOutput: { schema } }, ctx);
|
|
169
|
-
if (result.isErr()) return err(result.error);
|
|
170
|
-
this.logger.info("AGENT OBJECT RESULT DONE");
|
|
171
|
-
return ok({ ...result.value, object: result.value.object as z.infer<T> });
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
async embedDocument(
|
|
175
|
-
value: string,
|
|
176
|
-
options?: Parameters<ReturnType<typeof MDocument.fromText>["chunk"]>[0],
|
|
177
|
-
type: "text" | "markdown" | "html" | "json" = "text",
|
|
178
|
-
model: AiEmbeddingModel = OPENAI_TEXT_EMBEDDING_3_SMALL
|
|
179
|
-
): ServerResultAsync<{ embeddings: number[][]; chunks: { text: string }[] }> {
|
|
180
|
-
return this.throwableAsync(async () => {
|
|
181
|
-
if (type === "text") {
|
|
182
|
-
const doc = MDocument.fromText(value);
|
|
183
|
-
const chunks = await doc.chunk(
|
|
184
|
-
options ?? {
|
|
185
|
-
strategy: "recursive",
|
|
186
|
-
maxSize: 512,
|
|
187
|
-
overlap: 50,
|
|
188
|
-
separators: ["\n"],
|
|
189
|
-
}
|
|
190
|
-
);
|
|
191
|
-
const embeddings = await this.embedMany(chunks, model);
|
|
192
|
-
if (embeddings.isErr()) return err(embeddings.error);
|
|
193
|
-
return ok({ embeddings: embeddings.value.embeddings, chunks });
|
|
194
|
-
}
|
|
195
|
-
return this.error("BAD_REQUEST", "Unsupported document type");
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
async embed(
|
|
200
|
-
text: string,
|
|
201
|
-
model: AiEmbeddingModel = OPENAI_TEXT_EMBEDDING_3_SMALL
|
|
202
|
-
): ServerResultAsync<{ embedding: number[] }> {
|
|
203
|
-
return this.throwableAsync(async () => {
|
|
204
|
-
const result = await embed({
|
|
205
|
-
model: this.prepareEmbeddingModel(model),
|
|
206
|
-
value: text,
|
|
207
|
-
});
|
|
208
|
-
return ok(result);
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
async embedMany(
|
|
213
|
-
chunks: { text: string }[],
|
|
214
|
-
model: AiEmbeddingModel = OPENAI_TEXT_EMBEDDING_3_SMALL
|
|
215
|
-
): ServerResultAsync<{ embeddings: number[][] }> {
|
|
216
|
-
return this.throwableAsync(async () => {
|
|
217
|
-
const result = await embedMany({
|
|
218
|
-
model: this.prepareEmbeddingModel(model),
|
|
219
|
-
values: chunks.map((chunk) => chunk.text),
|
|
220
|
-
});
|
|
221
|
-
return ok(result);
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
async generateText(
|
|
226
|
-
params: Omit<Parameters<typeof generateText>[0], "model"> & {
|
|
227
|
-
model: AiModel;
|
|
228
|
-
removeMDash?: boolean;
|
|
229
|
-
}
|
|
230
|
-
): ServerResultAsync<string> {
|
|
231
|
-
return this.throwableAsync(async () => {
|
|
232
|
-
const { removeMDash = true, model, ...rest } = params;
|
|
233
|
-
const result = await generateText({ ...rest, model: this.prepareModel(model) });
|
|
234
|
-
return ok(removeMDash ? result.text.replace(/\u2013|\u2014/g, "-") : result.text);
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
async generateObject<T extends ZodType>(
|
|
239
|
-
params: Omit<Parameters<typeof generateObject<T>>[0], "model" | "schema"> & {
|
|
240
|
-
model: AiModel;
|
|
241
|
-
schema: T;
|
|
242
|
-
}
|
|
243
|
-
): ServerResultAsync<z.infer<T>> {
|
|
244
|
-
return this.throwableAsync(async () => {
|
|
245
|
-
const model = this.prepareModel(params.model);
|
|
246
|
-
const result = await generateObject({
|
|
247
|
-
...params,
|
|
248
|
-
model,
|
|
249
|
-
schema: params.schema,
|
|
250
|
-
});
|
|
251
|
-
return ok(result.object as z.infer<T>);
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
async generateReplicate(
|
|
256
|
-
model: Parameters<Replicate["run"]>[0],
|
|
257
|
-
options: Parameters<Replicate["run"]>[1]
|
|
258
|
-
): ServerResultAsync<object> {
|
|
259
|
-
return this.throwableAsync(async () => {
|
|
260
|
-
if (!this.replicate) {
|
|
261
|
-
return this.error("INTERNAL_SERVER_ERROR", "Replicate is not configured");
|
|
262
|
-
}
|
|
263
|
-
try {
|
|
264
|
-
return ok(await this.replicate.run(model, options));
|
|
265
|
-
} catch (error) {
|
|
266
|
-
return this.error("INTERNAL_SERVER_ERROR", undefined, { cause: error });
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
async generateTranscript(
|
|
272
|
-
file_url: string
|
|
273
|
-
): ServerResultAsync<{ text: string; metadata: unknown }> {
|
|
274
|
-
const output = await this.generateReplicate(
|
|
275
|
-
"thomasmol/whisper-diarization:1495a9cddc83b2203b0d8d3516e38b80fd1572ebc4bc5700ac1da56a9b3ed886",
|
|
276
|
-
{
|
|
277
|
-
input: {
|
|
278
|
-
file_url,
|
|
279
|
-
},
|
|
280
|
-
}
|
|
281
|
-
);
|
|
282
|
-
|
|
283
|
-
if (output.isErr()) return err(output.error);
|
|
284
|
-
|
|
285
|
-
try {
|
|
286
|
-
const { segments } = output.value as { segments: { text: string }[] };
|
|
287
|
-
return ok({ text: segments.map((segment) => segment.text).join(""), metadata: segments });
|
|
288
|
-
} catch (error) {
|
|
289
|
-
return this.error("INTERNAL_SERVER_ERROR", undefined, { cause: error });
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
async generateIdeogram(
|
|
294
|
-
input: IdeogramV3GenerateInput
|
|
295
|
-
): ServerResultAsync<IdeogramV3GenerateOutput> {
|
|
296
|
-
if (!this.service.ideogram) {
|
|
297
|
-
return this.error("INTERNAL_SERVER_ERROR", "Ideogram service is not available");
|
|
298
|
-
}
|
|
299
|
-
return this.service.ideogram.generate(input);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
async getUsage(
|
|
303
|
-
userId: string
|
|
304
|
-
): ServerResultAsync<Pick<AiUsageRow, "inputTokens" | "outputTokens" | "totalTokens" | "cost">> {
|
|
305
|
-
if (!this.repository.aiUsage) {
|
|
306
|
-
return this.error("INTERNAL_SERVER_ERROR", "AI usage repository is not available");
|
|
307
|
-
}
|
|
308
|
-
return this.repository.aiUsage.getUsage(userId);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Mastra } from "@mastra/core";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import type { AIService } from "#modules/ai/ai.service";
|
|
4
|
-
import { adminProcedure, handleTRPCResult, router } from "#trpc";
|
|
5
|
-
|
|
6
|
-
export function createAITRPC<MastraInstance extends Mastra>(aiService: AIService<MastraInstance>) {
|
|
7
|
-
return router({
|
|
8
|
-
getUserUsage: adminProcedure
|
|
9
|
-
.input(z.object({ userId: z.string() }))
|
|
10
|
-
.output(
|
|
11
|
-
z.object({
|
|
12
|
-
inputTokens: z.number().nullable(),
|
|
13
|
-
outputTokens: z.number().nullable(),
|
|
14
|
-
totalTokens: z.number().nullable(),
|
|
15
|
-
cost: z.number().nullable(),
|
|
16
|
-
})
|
|
17
|
-
)
|
|
18
|
-
.query(async ({ input }) => {
|
|
19
|
-
return handleTRPCResult(await aiService.getUsage(input.userId));
|
|
20
|
-
}),
|
|
21
|
-
});
|
|
22
|
-
}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
export const ideogramStyleTypes = ["AUTO", "GENERAL", "REALISTIC", "DESIGN", "FICTION"] as const;
|
|
2
|
-
|
|
3
|
-
export const ideogramStylePresets = [
|
|
4
|
-
"80S_ILLUSTRATION",
|
|
5
|
-
"90S_NOSTALGIA",
|
|
6
|
-
"ABSTRACT_ORGANIC",
|
|
7
|
-
"ANALOG_NOSTALGIA",
|
|
8
|
-
"ART_BRUT",
|
|
9
|
-
"ART_DECO",
|
|
10
|
-
"ART_POSTER",
|
|
11
|
-
"AURA",
|
|
12
|
-
"AVANT_GARDE",
|
|
13
|
-
"BAUHAUS",
|
|
14
|
-
"BLUEPRINT",
|
|
15
|
-
"BLURRY_MOTION",
|
|
16
|
-
"BRIGHT_ART",
|
|
17
|
-
"C4D_CARTOON",
|
|
18
|
-
"CHILDRENS_BOOK",
|
|
19
|
-
"COLLAGE",
|
|
20
|
-
"COLORING_BOOK_I",
|
|
21
|
-
"COLORING_BOOK_II",
|
|
22
|
-
"CUBISM",
|
|
23
|
-
"DARK_AURA",
|
|
24
|
-
"DOODLE",
|
|
25
|
-
"DOUBLE_EXPOSURE",
|
|
26
|
-
"DRAMATIC_CINEMA",
|
|
27
|
-
"EDITORIAL",
|
|
28
|
-
"EMOTIONAL_MINIMAL",
|
|
29
|
-
"ETHEREAL_PARTY",
|
|
30
|
-
"EXPIRED_FILM",
|
|
31
|
-
"FLAT_ART",
|
|
32
|
-
"FLAT_VECTOR",
|
|
33
|
-
"FOREST_REVERIE",
|
|
34
|
-
"GEO_MINIMALIST",
|
|
35
|
-
"GLASS_PRISM",
|
|
36
|
-
"GOLDEN_HOUR",
|
|
37
|
-
"GRAFFITI_I",
|
|
38
|
-
"GRAFFITI_II",
|
|
39
|
-
"HALFTONE_PRINT",
|
|
40
|
-
"HIGH_CONTRAST",
|
|
41
|
-
"HIPPIE_ERA",
|
|
42
|
-
"ICONIC",
|
|
43
|
-
"JAPANDI_FUSION",
|
|
44
|
-
"JAZZY",
|
|
45
|
-
"LONG_EXPOSURE",
|
|
46
|
-
"MAGAZINE_EDITORIAL",
|
|
47
|
-
"MINIMAL_ILLUSTRATION",
|
|
48
|
-
"MIXED_MEDIA",
|
|
49
|
-
"MONOCHROME",
|
|
50
|
-
"NIGHTLIFE",
|
|
51
|
-
"OIL_PAINTING",
|
|
52
|
-
"OLD_CARTOONS",
|
|
53
|
-
"PAINT_GESTURE",
|
|
54
|
-
"POP_ART",
|
|
55
|
-
"RETRO_ETCHING",
|
|
56
|
-
"RIVIERA_POP",
|
|
57
|
-
"SPOTLIGHT_80S",
|
|
58
|
-
"STYLIZED_RED",
|
|
59
|
-
"SURREAL_COLLAGE",
|
|
60
|
-
"TRAVEL_POSTER",
|
|
61
|
-
"VINTAGE_GEO",
|
|
62
|
-
"VINTAGE_POSTER",
|
|
63
|
-
] as const;
|
|
64
|
-
|
|
65
|
-
export const ideogramResolutions = [
|
|
66
|
-
"512x1536",
|
|
67
|
-
"576x1408",
|
|
68
|
-
"576x1472",
|
|
69
|
-
"576x1536",
|
|
70
|
-
"640x1344",
|
|
71
|
-
"640x1408",
|
|
72
|
-
"640x1472",
|
|
73
|
-
"640x1536",
|
|
74
|
-
"704x1152",
|
|
75
|
-
"704x1216",
|
|
76
|
-
"704x1280",
|
|
77
|
-
"704x1344",
|
|
78
|
-
"704x1408",
|
|
79
|
-
"704x1472",
|
|
80
|
-
"736x1312",
|
|
81
|
-
"768x1088",
|
|
82
|
-
"768x1216",
|
|
83
|
-
"768x1280",
|
|
84
|
-
"768x1344",
|
|
85
|
-
"800x1280",
|
|
86
|
-
"832x960",
|
|
87
|
-
"832x1024",
|
|
88
|
-
"832x1088",
|
|
89
|
-
"832x1152",
|
|
90
|
-
"832x1216",
|
|
91
|
-
"832x1248",
|
|
92
|
-
"864x1152",
|
|
93
|
-
"896x960",
|
|
94
|
-
"896x1024",
|
|
95
|
-
"896x1088",
|
|
96
|
-
"896x1120",
|
|
97
|
-
"896x1152",
|
|
98
|
-
"960x832",
|
|
99
|
-
"960x896",
|
|
100
|
-
"960x1024",
|
|
101
|
-
"960x1088",
|
|
102
|
-
"960x1120",
|
|
103
|
-
"960x1152",
|
|
104
|
-
"1024x832",
|
|
105
|
-
"1024x896",
|
|
106
|
-
"1024x960",
|
|
107
|
-
"1024x1024",
|
|
108
|
-
"1088x768",
|
|
109
|
-
"1088x832",
|
|
110
|
-
"1088x896",
|
|
111
|
-
"1088x960",
|
|
112
|
-
"1120x896",
|
|
113
|
-
"1152x704",
|
|
114
|
-
"1152x832",
|
|
115
|
-
"1152x864",
|
|
116
|
-
"1152x896",
|
|
117
|
-
"1216x704",
|
|
118
|
-
"1216x768",
|
|
119
|
-
"1216x832",
|
|
120
|
-
"1248x832",
|
|
121
|
-
"1280x704",
|
|
122
|
-
"1280x768",
|
|
123
|
-
"1280x800",
|
|
124
|
-
"1312x736",
|
|
125
|
-
"1344x640",
|
|
126
|
-
"1344x704",
|
|
127
|
-
"1344x768",
|
|
128
|
-
"1408x576",
|
|
129
|
-
"1408x640",
|
|
130
|
-
"1408x704",
|
|
131
|
-
"1472x576",
|
|
132
|
-
"1472x640",
|
|
133
|
-
"1472x704",
|
|
134
|
-
"1536x512",
|
|
135
|
-
"1536x576",
|
|
136
|
-
"1536x640",
|
|
137
|
-
] as const;
|
|
138
|
-
|
|
139
|
-
export const ideogramAspectRatios = [
|
|
140
|
-
"1x3",
|
|
141
|
-
"3x1",
|
|
142
|
-
"1x2",
|
|
143
|
-
"2x1",
|
|
144
|
-
"9x16",
|
|
145
|
-
"16x9",
|
|
146
|
-
"10x16",
|
|
147
|
-
"16x10",
|
|
148
|
-
"2x3",
|
|
149
|
-
"3x2",
|
|
150
|
-
"3x4",
|
|
151
|
-
"4x3",
|
|
152
|
-
"4x5",
|
|
153
|
-
"5x4",
|
|
154
|
-
"1x1",
|
|
155
|
-
] as const;
|
|
156
|
-
|
|
157
|
-
export const ideogramRenderingSpeed = ["FLASH", "TURBO", "DEFAULT", "QUALITY"] as const;
|
|
158
|
-
|
|
159
|
-
export const ideogramMagicPrompt = ["AUTO", "ON", "OFF"] as const;
|
|
160
|
-
|
|
161
|
-
export const ideogramColorPalettePreset = [
|
|
162
|
-
"EMBER",
|
|
163
|
-
"FRESH",
|
|
164
|
-
"JUNGLE",
|
|
165
|
-
"MAGIC",
|
|
166
|
-
"MELON",
|
|
167
|
-
"MOSAIC",
|
|
168
|
-
"PASTEL",
|
|
169
|
-
"ULTRAMARINE",
|
|
170
|
-
] as const;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
ideogramAspectRatios,
|
|
4
|
-
ideogramColorPalettePreset,
|
|
5
|
-
ideogramMagicPrompt,
|
|
6
|
-
ideogramRenderingSpeed,
|
|
7
|
-
ideogramResolutions,
|
|
8
|
-
ideogramStylePresets,
|
|
9
|
-
ideogramStyleTypes,
|
|
10
|
-
} from "#modules/ai/ideogram/ideogram.constants";
|
|
11
|
-
|
|
12
|
-
export const ideogramAISchema = z.object({
|
|
13
|
-
prompt: z.string().describe("Create a prompt for the image generation."),
|
|
14
|
-
style_type: z.enum(ideogramStyleTypes).describe("Choose a style type for the image generation."),
|
|
15
|
-
// style_preset: z
|
|
16
|
-
// .enum(ideogramStylePresets)
|
|
17
|
-
// .describe("Choose a style preset for the image generation."),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export const ideogramV3GenerateInputSchema = z.object({
|
|
21
|
-
prompt: z.string(),
|
|
22
|
-
seed: z.number().optional(),
|
|
23
|
-
resolution: z.enum(ideogramResolutions).optional(),
|
|
24
|
-
rendering_speed: z.enum(ideogramRenderingSpeed).optional(),
|
|
25
|
-
magic_prompt: z.enum(ideogramMagicPrompt).optional(),
|
|
26
|
-
negative_prompt: z.string().optional(),
|
|
27
|
-
num_images: z.number().optional(),
|
|
28
|
-
color_palette: z
|
|
29
|
-
.object({
|
|
30
|
-
ColorPaletteWithPresetName: z.object({ name: z.enum(ideogramColorPalettePreset) }).optional(),
|
|
31
|
-
ColorPaletteWithMembers: z
|
|
32
|
-
.object({
|
|
33
|
-
members: z.array(
|
|
34
|
-
z.object({ color_hex: z.string(), color_weight: z.number().min(0.05).max(1) })
|
|
35
|
-
),
|
|
36
|
-
})
|
|
37
|
-
.optional(),
|
|
38
|
-
})
|
|
39
|
-
.optional(),
|
|
40
|
-
style_codes: z.array(z.string()).optional(),
|
|
41
|
-
aspect_ratio: z.enum(ideogramAspectRatios).optional(),
|
|
42
|
-
style_type: z.enum(ideogramStyleTypes).optional(),
|
|
43
|
-
style_preset: z.enum(ideogramStylePresets).optional(),
|
|
44
|
-
style_reference_images: z.array(z.file()).optional(),
|
|
45
|
-
character_reference_images: z.array(z.file()).optional(),
|
|
46
|
-
character_reference_images_mask: z.file().optional(),
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
export const ideogramV3GenerateOutputSchema = z.object({
|
|
50
|
-
created: z.string(),
|
|
51
|
-
data: z.array(
|
|
52
|
-
z.object({
|
|
53
|
-
prompt: z.string(),
|
|
54
|
-
resolution: z.string(),
|
|
55
|
-
is_image_safe: z.boolean(),
|
|
56
|
-
seed: z.number(),
|
|
57
|
-
url: z.url(),
|
|
58
|
-
style_type: z.enum(ideogramStyleTypes),
|
|
59
|
-
})
|
|
60
|
-
),
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
export type IdeogramV3GenerateInput = z.infer<typeof ideogramV3GenerateInputSchema>;
|
|
64
|
-
export type IdeogramV3GenerateOutput = z.infer<typeof ideogramV3GenerateOutputSchema>;
|