@superinterface/server 1.0.18 → 1.0.19
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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +2 -2
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/eslint/.cache_btwyo7 +1 -1
- package/.next/fallback-build-manifest.json +2 -2
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/api/files/[fileId]/contents/route.js +1 -1
- package/.next/server/app/api/files/[fileId]/contents/route.js.nft.json +1 -1
- package/.next/server/app/api/files/route.js +1 -1
- package/.next/server/app/api/files/route.js.nft.json +1 -1
- package/.next/server/app/api/messages/route.js +3 -3
- package/.next/server/app/api/messages/route.js.nft.json +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +1 -1
- package/.next/server/chunks/[root-of-the-server]__0c1bc5ed._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0c1bc5ed._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__13c6bd62._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__13c6bd62._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__25ee13bc._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__25ee13bc._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__27aadac9._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__27aadac9._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__2945c9e9._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__2945c9e9._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__29635e8e._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__29635e8e._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__29b43490._.js +2 -2
- package/.next/server/chunks/[root-of-the-server]__29b43490._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__315f084a._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__315f084a._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__441cee00._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__441cee00._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__464a4377._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__464a4377._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__4e536bc0._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__4e536bc0._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__51977f30._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__51977f30._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__583a7f1c._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__583a7f1c._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__5abf1160._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__5abf1160._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__5d09614a._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__5d09614a._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__62d958e7._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__62d958e7._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__7f9ca1e3._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__7f9ca1e3._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__83461316._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__83461316._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__9a611d42._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__9a611d42._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__a135e388._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__a135e388._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__b10ec83e._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__b10ec83e._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__b9a334c3._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__b9a334c3._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__c1629392._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__c1629392._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__dd176cb5._.js +2 -2
- package/.next/server/chunks/[root-of-the-server]__dd176cb5._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__eb816e13._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__eb816e13._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__ed6cf593._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__ed6cf593._.js.map +1 -1
- package/.next/server/chunks/{[root-of-the-server]__30845206._.js → [root-of-the-server]__ff90af03._.js} +3 -3
- package/.next/server/chunks/{[root-of-the-server]__30845206._.js.map → [root-of-the-server]__ff90af03._.js.map} +1 -1
- package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_cb746cf4.js +1 -1
- package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_cb746cf4.js.map +1 -1
- package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_f952d9ab.js +1 -1
- package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_f952d9ab.js.map +1 -1
- package/.next/server/chunks/supercorp_superinterface_bebd2c96._.js +2 -2
- package/.next/server/chunks/supercorp_superinterface_bebd2c96._.js.map +1 -1
- package/.next/server/functions-config-manifest.json +2 -2
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/trace +1 -1
- package/bin/index.cjs +2 -0
- package/dist/app/api/api-keys/[apiKeyId]/route.d.ts +55 -0
- package/dist/app/api/api-keys/[apiKeyId]/route.d.ts.map +1 -1
- package/dist/app/api/api-keys/[apiKeyId]/route.js +10 -4
- package/dist/app/api/api-keys/route.d.ts +29 -0
- package/dist/app/api/api-keys/route.d.ts.map +1 -1
- package/dist/app/api/api-keys/route.js +8 -3
- package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.d.ts +172 -0
- package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.js +11 -4
- package/dist/app/api/assistants/[assistantId]/functions/route.d.ts +113 -0
- package/dist/app/api/assistants/[assistantId]/functions/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/functions/route.js +8 -3
- package/dist/app/api/assistants/[assistantId]/initial-messages/route.d.ts +39 -0
- package/dist/app/api/assistants/[assistantId]/initial-messages/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/initial-messages/route.js +8 -3
- package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.d.ts +94 -0
- package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.js +10 -4
- package/dist/app/api/assistants/[assistantId]/mcp-servers/route.d.ts +61 -0
- package/dist/app/api/assistants/[assistantId]/mcp-servers/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/mcp-servers/route.js +7 -3
- package/dist/app/api/assistants/[assistantId]/route.d.ts +123 -0
- package/dist/app/api/assistants/[assistantId]/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/route.js +15 -6
- package/dist/app/api/assistants/route.d.ts +59 -0
- package/dist/app/api/assistants/route.d.ts.map +1 -1
- package/dist/app/api/assistants/route.js +8 -4
- package/dist/app/api/files/[fileId]/contents/route.d.ts +3 -2
- package/dist/app/api/files/[fileId]/contents/route.d.ts.map +1 -1
- package/dist/app/api/files/[fileId]/contents/route.js +6 -3
- package/dist/app/api/files/route.d.ts +10 -0
- package/dist/app/api/files/route.d.ts.map +1 -1
- package/dist/app/api/files/route.js +7 -3
- package/dist/app/api/messages/route.d.ts +24 -1
- package/dist/app/api/messages/route.d.ts.map +1 -1
- package/dist/app/api/messages/route.js +27 -6
- package/dist/app/api/providers/[modelProviderId]/assistants/route.d.ts +19 -0
- package/dist/app/api/providers/[modelProviderId]/assistants/route.d.ts.map +1 -1
- package/dist/app/api/providers/[modelProviderId]/assistants/route.js +4 -2
- package/dist/app/api/providers/[modelProviderId]/models/route.d.ts +14 -0
- package/dist/app/api/providers/[modelProviderId]/models/route.d.ts.map +1 -1
- package/dist/app/api/providers/[modelProviderId]/models/route.js +4 -2
- package/dist/app/api/providers/[modelProviderId]/route.d.ts +64 -0
- package/dist/app/api/providers/[modelProviderId]/route.d.ts.map +1 -1
- package/dist/app/api/providers/[modelProviderId]/route.js +12 -6
- package/dist/app/api/providers/route.d.ts +35 -0
- package/dist/app/api/providers/route.d.ts.map +1 -1
- package/dist/app/api/providers/route.js +9 -5
- package/dist/app/api/tasks/[taskId]/route.d.ts +61 -0
- package/dist/app/api/tasks/[taskId]/route.d.ts.map +1 -1
- package/dist/app/api/tasks/[taskId]/route.js +11 -5
- package/dist/app/api/tasks/callback/route.d.ts.map +1 -1
- package/dist/app/api/tasks/callback/route.js +14 -6
- package/dist/app/api/tasks/route.d.ts +33 -0
- package/dist/app/api/tasks/route.d.ts.map +1 -1
- package/dist/app/api/tasks/route.js +8 -4
- package/dist/app/api/threads/runs/submit-client-tool-outputs/route.d.ts +9 -1
- package/dist/app/api/threads/runs/submit-client-tool-outputs/route.d.ts.map +1 -1
- package/dist/app/api/threads/runs/submit-client-tool-outputs/route.js +5 -3
- package/dist/app/api/workspaces/[workspaceId]/route.d.ts +33 -0
- package/dist/app/api/workspaces/[workspaceId]/route.d.ts.map +1 -1
- package/dist/app/api/workspaces/[workspaceId]/route.js +7 -3
- package/dist/app/api/workspaces/route.d.ts +17 -3
- package/dist/app/api/workspaces/route.d.ts.map +1 -1
- package/dist/app/api/workspaces/route.js +8 -4
- package/dist/lib/apiKeys/getApiKey.d.ts +3 -2
- package/dist/lib/apiKeys/getApiKey.d.ts.map +1 -1
- package/dist/lib/apiKeys/getApiKey.js +1 -2
- package/dist/lib/apiKeys/workspaceAccessWhere.d.ts +3 -1
- package/dist/lib/apiKeys/workspaceAccessWhere.d.ts.map +1 -1
- package/dist/lib/apiKeys/workspaceAccessWhere.js +2 -1
- package/dist/lib/assistants/assistantClientAdapter/buildGetOpenaiAssistant.d.ts +3 -2
- package/dist/lib/assistants/assistantClientAdapter/buildGetOpenaiAssistant.d.ts.map +1 -1
- package/dist/lib/assistants/assistantClientAdapter/buildGetOpenaiAssistant.js +3 -3
- package/dist/lib/assistants/assistantClientAdapter/index.d.ts.map +1 -1
- package/dist/lib/assistants/assistantClientAdapter/index.js +7 -2
- package/dist/lib/computerCalls/handleComputerCall/index.d.ts +3 -2
- package/dist/lib/computerCalls/handleComputerCall/index.d.ts.map +1 -1
- package/dist/lib/computerCalls/handleComputerCall/index.js +5 -1
- package/dist/lib/functions/createFunction.d.ts +2 -1
- package/dist/lib/functions/createFunction.d.ts.map +1 -1
- package/dist/lib/functions/createFunction.js +2 -2
- package/dist/lib/functions/handleFunction/handleAssistant.d.ts +3 -2
- package/dist/lib/functions/handleFunction/handleAssistant.d.ts.map +1 -1
- package/dist/lib/functions/handleFunction/handleAssistant.js +12 -2
- package/dist/lib/functions/handleFunction/handleClientTool.d.ts +3 -2
- package/dist/lib/functions/handleFunction/handleClientTool.d.ts.map +1 -1
- package/dist/lib/functions/handleFunction/handleClientTool.js +2 -1
- package/dist/lib/functions/handleFunction/handleFirecrawl.d.ts +3 -2
- package/dist/lib/functions/handleFunction/handleFirecrawl.d.ts.map +1 -1
- package/dist/lib/functions/handleFunction/handleFirecrawl.js +7 -1
- package/dist/lib/functions/handleFunction/handleReplicate.d.ts +3 -2
- package/dist/lib/functions/handleFunction/handleReplicate.d.ts.map +1 -1
- package/dist/lib/functions/handleFunction/handleReplicate.js +4 -1
- package/dist/lib/functions/handleFunction/handleRequest.d.ts +3 -2
- package/dist/lib/functions/handleFunction/handleRequest.d.ts.map +1 -1
- package/dist/lib/functions/handleFunction/handleRequest.js +6 -1
- package/dist/lib/functions/handleFunction/index.d.ts +3 -2
- package/dist/lib/functions/handleFunction/index.d.ts.map +1 -1
- package/dist/lib/functions/handleFunction/index.js +25 -1
- package/dist/lib/functions/handleFunction/tasks/handleCreateTask.d.ts +3 -2
- package/dist/lib/functions/handleFunction/tasks/handleCreateTask.d.ts.map +1 -1
- package/dist/lib/functions/handleFunction/tasks/handleCreateTask.js +4 -4
- package/dist/lib/functions/handleFunction/tasks/handleDeleteTask.d.ts +3 -2
- package/dist/lib/functions/handleFunction/tasks/handleDeleteTask.d.ts.map +1 -1
- package/dist/lib/functions/handleFunction/tasks/handleDeleteTask.js +3 -3
- package/dist/lib/functions/handleFunction/tasks/handleListTasks.d.ts +3 -2
- package/dist/lib/functions/handleFunction/tasks/handleListTasks.d.ts.map +1 -1
- package/dist/lib/functions/handleFunction/tasks/handleListTasks.js +3 -3
- package/dist/lib/functions/handleFunction/tasks/handleUpdateTask.d.ts +3 -2
- package/dist/lib/functions/handleFunction/tasks/handleUpdateTask.d.ts.map +1 -1
- package/dist/lib/functions/handleFunction/tasks/handleUpdateTask.js +4 -4
- package/dist/lib/functions/updateFunction.d.ts +2 -1
- package/dist/lib/functions/updateFunction.d.ts.map +1 -1
- package/dist/lib/functions/updateFunction.js +2 -2
- package/dist/lib/handlers/handlerPrismaInput.d.ts +3 -1
- package/dist/lib/handlers/handlerPrismaInput.d.ts.map +1 -1
- package/dist/lib/handlers/handlerPrismaInput.jsx +1 -2
- package/dist/lib/initialMessages/updateInitialMessages.d.ts +3 -2
- package/dist/lib/initialMessages/updateInitialMessages.d.ts.map +1 -1
- package/dist/lib/initialMessages/updateInitialMessages.js +1 -2
- package/dist/lib/logs/createLog.d.ts +3 -2
- package/dist/lib/logs/createLog.d.ts.map +1 -1
- package/dist/lib/logs/createLog.js +1 -2
- package/dist/lib/mcpServers/connectMcpServer.d.ts +6 -4
- package/dist/lib/mcpServers/connectMcpServer.d.ts.map +1 -1
- package/dist/lib/mcpServers/connectMcpServer.js +7 -5
- package/dist/lib/mcpServers/getToolCallMcpServer.d.ts +3 -2
- package/dist/lib/mcpServers/getToolCallMcpServer.d.ts.map +1 -1
- package/dist/lib/mcpServers/getToolCallMcpServer.js +2 -1
- package/dist/lib/mcpServers/headers.d.ts +3 -2
- package/dist/lib/mcpServers/headers.d.ts.map +1 -1
- package/dist/lib/mcpServers/headers.js +2 -1
- package/dist/lib/mcpServers/url.d.ts +3 -2
- package/dist/lib/mcpServers/url.d.ts.map +1 -1
- package/dist/lib/mcpServers/url.js +2 -1
- package/dist/lib/metadata/serializeMetadata.d.ts +3 -1
- package/dist/lib/metadata/serializeMetadata.d.ts.map +1 -1
- package/dist/lib/metadata/serializeMetadata.js +3 -2
- package/dist/lib/organizationApiKeys/getOrganizationApiKey.d.ts +3 -2
- package/dist/lib/organizationApiKeys/getOrganizationApiKey.d.ts.map +1 -1
- package/dist/lib/organizationApiKeys/getOrganizationApiKey.js +1 -2
- package/dist/lib/runs/createRunOpts.d.ts +3 -2
- package/dist/lib/runs/createRunOpts.d.ts.map +1 -1
- package/dist/lib/runs/createRunOpts.js +2 -2
- package/dist/lib/tasks/getTaskToolKey.d.ts +3 -2
- package/dist/lib/tasks/getTaskToolKey.d.ts.map +1 -1
- package/dist/lib/tasks/getTaskToolKey.js +2 -1
- package/dist/lib/tasks/parseTaskToolArgs.d.ts +3 -2
- package/dist/lib/tasks/parseTaskToolArgs.d.ts.map +1 -1
- package/dist/lib/tasks/parseTaskToolArgs.js +4 -1
- package/dist/lib/tasks/scheduleTask.d.ts +3 -2
- package/dist/lib/tasks/scheduleTask.d.ts.map +1 -1
- package/dist/lib/tasks/scheduleTask.js +1 -2
- package/dist/lib/threads/createThread/index.d.ts +3 -3
- package/dist/lib/threads/createThread/index.d.ts.map +1 -1
- package/dist/lib/threads/createThread/index.js +1 -0
- package/dist/lib/threads/managedOpenaiThreadId.d.ts +3 -2
- package/dist/lib/threads/managedOpenaiThreadId.d.ts.map +1 -1
- package/dist/lib/threads/managedOpenaiThreadId.js +1 -2
- package/dist/lib/toolCalls/handleToolCall.d.ts +3 -2
- package/dist/lib/toolCalls/handleToolCall.d.ts.map +1 -1
- package/dist/lib/toolCalls/handleToolCall.js +5 -1
- package/dist/lib/tools/tools/index.d.ts +3 -2
- package/dist/lib/tools/tools/index.d.ts.map +1 -1
- package/dist/lib/tools/tools/index.js +9 -6
- package/package.json +1 -1
- package/scripts/utils/loadPrisma.ts +1 -2
- /package/.next/static/{s_BjB5fnRbk2L3A0fMr5L → rEvucoSBXJWMKfLWTgPF2}/_buildManifest.js +0 -0
- /package/.next/static/{s_BjB5fnRbk2L3A0fMr5L → rEvucoSBXJWMKfLWTgPF2}/_clientMiddlewareManifest.json +0 -0
- /package/.next/static/{s_BjB5fnRbk2L3A0fMr5L → rEvucoSBXJWMKfLWTgPF2}/_ssgManifest.js +0 -0
|
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { NextResponse } from 'next/server';
|
|
13
|
-
import { LogRequestMethod, LogRequestRoute, LogLevel } from '@prisma/client';
|
|
13
|
+
import { LogRequestMethod, LogRequestRoute, LogLevel, } from '@prisma/client';
|
|
14
14
|
import { messagesResponse, createMessageResponse, } from '@superinterface/react/server';
|
|
15
15
|
import { enqueueJson } from '@superinterface/react/utils';
|
|
16
16
|
import { cacheHeaders } from '../../../lib/cache/cacheHeaders';
|
|
@@ -24,7 +24,7 @@ import { createRunOpts } from '../../../lib/runs/createRunOpts';
|
|
|
24
24
|
import { handleToolCall } from '../../../lib/toolCalls/handleToolCall';
|
|
25
25
|
import { createThread } from '../../../lib/threads/createThread';
|
|
26
26
|
import { managedOpenaiThreadId } from '../../../lib/threads/managedOpenaiThreadId';
|
|
27
|
-
import { prisma } from '../../../lib/prisma';
|
|
27
|
+
import { prisma as defaultPrisma } from '../../../lib/prisma';
|
|
28
28
|
import { createLog } from '../../../lib/logs/createLog';
|
|
29
29
|
import { serializeThread } from './lib/serializeThread';
|
|
30
30
|
import { getWorkspaceId } from './lib/getWorkspaceId';
|
|
@@ -34,7 +34,7 @@ import { serializeMetadata } from '../../../lib/metadata/serializeMetadata';
|
|
|
34
34
|
import { isResponsesStorageProvider } from '../../../lib/storageProviders/isResponsesStorageProvider';
|
|
35
35
|
import { serializeError } from '../../../lib/errors/serializeError';
|
|
36
36
|
export const maxDuration = 800;
|
|
37
|
-
export const
|
|
37
|
+
export const buildGET = ({ prisma = defaultPrisma } = {}) => async (request) => {
|
|
38
38
|
var _a;
|
|
39
39
|
const paramsResult = z
|
|
40
40
|
.object({
|
|
@@ -46,6 +46,7 @@ export const GET = async (request) => {
|
|
|
46
46
|
.parse(Object.fromEntries(request.nextUrl.searchParams.entries()));
|
|
47
47
|
const workspaceAccessWhere = await getWorkspaceAccessWhere({
|
|
48
48
|
publicApiKey: (_a = paramsResult.publicApiKey) !== null && _a !== void 0 ? _a : null,
|
|
49
|
+
prisma,
|
|
49
50
|
});
|
|
50
51
|
if (!workspaceAccessWhere) {
|
|
51
52
|
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
@@ -61,6 +62,7 @@ export const GET = async (request) => {
|
|
|
61
62
|
message: 'No assistantId found.',
|
|
62
63
|
workspaceId: await getWorkspaceId({ workspaceAccessWhere, prisma }),
|
|
63
64
|
},
|
|
65
|
+
prisma,
|
|
64
66
|
});
|
|
65
67
|
return NextResponse.json({ error: 'No assistant id found' }, { status: 400 });
|
|
66
68
|
}
|
|
@@ -125,6 +127,7 @@ export const GET = async (request) => {
|
|
|
125
127
|
message: 'No assistant found.',
|
|
126
128
|
workspaceId: await getWorkspaceId({ workspaceAccessWhere, prisma }),
|
|
127
129
|
},
|
|
130
|
+
prisma,
|
|
128
131
|
});
|
|
129
132
|
return NextResponse.json({ error: 'No assistant found' }, { status: 400 });
|
|
130
133
|
}
|
|
@@ -167,11 +170,13 @@ export const GET = async (request) => {
|
|
|
167
170
|
assistantId: assistant.id,
|
|
168
171
|
threadId: thread.id,
|
|
169
172
|
},
|
|
173
|
+
prisma,
|
|
170
174
|
});
|
|
171
175
|
return NextResponse.json({ error: 'Failed to load messages.' }, { status: 500 });
|
|
172
176
|
}
|
|
173
177
|
};
|
|
174
|
-
export const
|
|
178
|
+
export const GET = buildGET();
|
|
179
|
+
export const buildPOST = ({ prisma = defaultPrisma, onSuccessCreateThread = () => void 0, } = {}) => async (request) => {
|
|
175
180
|
var _a;
|
|
176
181
|
const bodyResult = z
|
|
177
182
|
.object({
|
|
@@ -187,6 +192,7 @@ export const buildPOST = ({ onSuccessCreateThread = () => void 0, }) => async (r
|
|
|
187
192
|
const { audioContent, content: textContent, attachments, assistantId, publicApiKey } = bodyResult, variables = __rest(bodyResult, ["audioContent", "content", "attachments", "assistantId", "publicApiKey"]);
|
|
188
193
|
const workspaceAccessWhere = await getWorkspaceAccessWhere({
|
|
189
194
|
publicApiKey: publicApiKey !== null && publicApiKey !== void 0 ? publicApiKey : null,
|
|
195
|
+
prisma,
|
|
190
196
|
});
|
|
191
197
|
if (!workspaceAccessWhere) {
|
|
192
198
|
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
@@ -201,6 +207,7 @@ export const buildPOST = ({ onSuccessCreateThread = () => void 0, }) => async (r
|
|
|
201
207
|
message: 'No assistantId found.',
|
|
202
208
|
workspaceId: await getWorkspaceId({ workspaceAccessWhere, prisma }),
|
|
203
209
|
},
|
|
210
|
+
prisma,
|
|
204
211
|
});
|
|
205
212
|
return NextResponse.json({ error: 'No assistantId found.' }, { status: 400 });
|
|
206
213
|
}
|
|
@@ -214,6 +221,7 @@ export const buildPOST = ({ onSuccessCreateThread = () => void 0, }) => async (r
|
|
|
214
221
|
message: 'No content found.',
|
|
215
222
|
workspaceId: await getWorkspaceId({ workspaceAccessWhere, prisma }),
|
|
216
223
|
},
|
|
224
|
+
prisma,
|
|
217
225
|
});
|
|
218
226
|
return NextResponse.json({ error: 'No content found.' }, { status: 400 });
|
|
219
227
|
}
|
|
@@ -303,6 +311,7 @@ export const buildPOST = ({ onSuccessCreateThread = () => void 0, }) => async (r
|
|
|
303
311
|
message: 'No assistant found.',
|
|
304
312
|
workspaceId: await getWorkspaceId({ workspaceAccessWhere, prisma }),
|
|
305
313
|
},
|
|
314
|
+
prisma,
|
|
306
315
|
});
|
|
307
316
|
return NextResponse.json({ error: 'No assistant found.' }, { status: 400 });
|
|
308
317
|
}
|
|
@@ -320,6 +329,7 @@ export const buildPOST = ({ onSuccessCreateThread = () => void 0, }) => async (r
|
|
|
320
329
|
workspaceId: assistant.workspaceId,
|
|
321
330
|
assistantId: assistant.id,
|
|
322
331
|
},
|
|
332
|
+
prisma,
|
|
323
333
|
});
|
|
324
334
|
return NextResponse.json({ error: 'Assistant setup is not done.' }, { status: 400 });
|
|
325
335
|
}
|
|
@@ -349,6 +359,7 @@ export const buildPOST = ({ onSuccessCreateThread = () => void 0, }) => async (r
|
|
|
349
359
|
workspaceId: assistant.workspaceId,
|
|
350
360
|
assistantId: assistant.id,
|
|
351
361
|
},
|
|
362
|
+
prisma,
|
|
352
363
|
});
|
|
353
364
|
return NextResponse.json({ error: 'Failed to create thread.' }, { status: 500 });
|
|
354
365
|
}
|
|
@@ -373,6 +384,7 @@ export const buildPOST = ({ onSuccessCreateThread = () => void 0, }) => async (r
|
|
|
373
384
|
assistantId: assistant.id,
|
|
374
385
|
threadId: thread.id,
|
|
375
386
|
},
|
|
387
|
+
prisma,
|
|
376
388
|
});
|
|
377
389
|
return NextResponse.json({ error: 'Failed to get storage thread id.' }, { status: 500 });
|
|
378
390
|
}
|
|
@@ -387,6 +399,7 @@ export const buildPOST = ({ onSuccessCreateThread = () => void 0, }) => async (r
|
|
|
387
399
|
storageThreadId = await managedOpenaiThreadId({
|
|
388
400
|
assistant,
|
|
389
401
|
threadId: thread.id,
|
|
402
|
+
prisma,
|
|
390
403
|
});
|
|
391
404
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
392
405
|
}
|
|
@@ -402,6 +415,7 @@ export const buildPOST = ({ onSuccessCreateThread = () => void 0, }) => async (r
|
|
|
402
415
|
assistantId: assistant.id,
|
|
403
416
|
threadId: thread.id,
|
|
404
417
|
},
|
|
418
|
+
prisma,
|
|
405
419
|
});
|
|
406
420
|
return NextResponse.json({ error: 'Failed to get managed openai thread id.' }, { status: 500 });
|
|
407
421
|
}
|
|
@@ -418,6 +432,7 @@ export const buildPOST = ({ onSuccessCreateThread = () => void 0, }) => async (r
|
|
|
418
432
|
assistantId: assistant.id,
|
|
419
433
|
threadId: thread.id,
|
|
420
434
|
},
|
|
435
|
+
prisma,
|
|
421
436
|
});
|
|
422
437
|
return NextResponse.json({ error: 'Invalid thread configuration.' }, { status: 500 });
|
|
423
438
|
}
|
|
@@ -443,6 +458,7 @@ export const buildPOST = ({ onSuccessCreateThread = () => void 0, }) => async (r
|
|
|
443
458
|
assistantId: assistant.id,
|
|
444
459
|
threadId: thread.id,
|
|
445
460
|
},
|
|
461
|
+
prisma,
|
|
446
462
|
});
|
|
447
463
|
return NextResponse.json({ error: 'Failed to get content.' }, { status: 500 });
|
|
448
464
|
}
|
|
@@ -455,6 +471,7 @@ export const buildPOST = ({ onSuccessCreateThread = () => void 0, }) => async (r
|
|
|
455
471
|
await client.beta.threads.messages.create(storageThreadId, Object.assign(Object.assign({ role: 'user', content }, ((attachments === null || attachments === void 0 ? void 0 : attachments.length) ? { attachments } : {})), { metadata: serializeMetadata({
|
|
456
472
|
variables,
|
|
457
473
|
workspaceId: assistant.workspaceId,
|
|
474
|
+
prisma,
|
|
458
475
|
}) }));
|
|
459
476
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
460
477
|
}
|
|
@@ -471,12 +488,13 @@ export const buildPOST = ({ onSuccessCreateThread = () => void 0, }) => async (r
|
|
|
471
488
|
assistantId: assistant.id,
|
|
472
489
|
threadId: thread.id,
|
|
473
490
|
},
|
|
491
|
+
prisma,
|
|
474
492
|
});
|
|
475
493
|
return NextResponse.json({ error: 'Failed to create message.' }, { status: 500 });
|
|
476
494
|
}
|
|
477
495
|
let createRunStream;
|
|
478
496
|
try {
|
|
479
|
-
createRunStream = await client.beta.threads.runs.create(storageThreadId, await createRunOpts({ assistant, thread }));
|
|
497
|
+
createRunStream = await client.beta.threads.runs.create(storageThreadId, await createRunOpts({ assistant, thread, prisma }));
|
|
480
498
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
481
499
|
}
|
|
482
500
|
catch (error) {
|
|
@@ -492,6 +510,7 @@ export const buildPOST = ({ onSuccessCreateThread = () => void 0, }) => async (r
|
|
|
492
510
|
assistantId: assistant.id,
|
|
493
511
|
threadId: thread.id,
|
|
494
512
|
},
|
|
513
|
+
prisma,
|
|
495
514
|
});
|
|
496
515
|
return NextResponse.json({ error: 'Failed to create run stream.' }, { status: 500 });
|
|
497
516
|
}
|
|
@@ -500,7 +519,7 @@ export const buildPOST = ({ onSuccessCreateThread = () => void 0, }) => async (r
|
|
|
500
519
|
return new Response(createMessageResponse({
|
|
501
520
|
client,
|
|
502
521
|
createRunStream,
|
|
503
|
-
handleToolCall: handleToolCall({ assistant, thread }),
|
|
522
|
+
handleToolCall: handleToolCall({ assistant, thread, prisma }),
|
|
504
523
|
onStart: ({ controller, }) => {
|
|
505
524
|
if (!isThreadCreated)
|
|
506
525
|
return;
|
|
@@ -528,6 +547,7 @@ export const buildPOST = ({ onSuccessCreateThread = () => void 0, }) => async (r
|
|
|
528
547
|
assistantId: assistant.id,
|
|
529
548
|
threadId: thread.id,
|
|
530
549
|
},
|
|
550
|
+
prisma,
|
|
531
551
|
});
|
|
532
552
|
// if (latestInProgressRunData) {
|
|
533
553
|
// await client.beta.threads.runs.cancel(
|
|
@@ -550,6 +570,7 @@ export const buildPOST = ({ onSuccessCreateThread = () => void 0, }) => async (r
|
|
|
550
570
|
assistantId: assistant.id,
|
|
551
571
|
threadId: thread.id,
|
|
552
572
|
},
|
|
573
|
+
prisma,
|
|
553
574
|
});
|
|
554
575
|
}
|
|
555
576
|
else if (event === 'thread.run.in_progress') {
|
|
@@ -1,4 +1,23 @@
|
|
|
1
|
+
import { type PrismaClient } from '@prisma/client';
|
|
1
2
|
import { NextResponse, type NextRequest } from 'next/server';
|
|
3
|
+
export declare const buildGET: ({ prisma }?: {
|
|
4
|
+
prisma?: PrismaClient;
|
|
5
|
+
}) => (_request: NextRequest, props: {
|
|
6
|
+
params: Promise<{
|
|
7
|
+
modelProviderId: string;
|
|
8
|
+
}>;
|
|
9
|
+
}) => Promise<NextResponse<{
|
|
10
|
+
error: string;
|
|
11
|
+
}> | NextResponse<{
|
|
12
|
+
storageProviderAssistants: {
|
|
13
|
+
id: string;
|
|
14
|
+
model: string;
|
|
15
|
+
name: string | null;
|
|
16
|
+
description: string | null;
|
|
17
|
+
instructions: string | null;
|
|
18
|
+
tools: import("openai/resources/beta/assistants.mjs").AssistantTool[];
|
|
19
|
+
}[];
|
|
20
|
+
}>>;
|
|
2
21
|
export declare const GET: (_request: NextRequest, props: {
|
|
3
22
|
params: Promise<{
|
|
4
23
|
modelProviderId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/providers/[modelProviderId]/assistants/route.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/providers/[modelProviderId]/assistants/route.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAO5D,eAAO,MAAM,QAAQ,GAClB,aAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,UAAU,WAAW,EACrB,OAAO;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;;;GAiDxD,CAAA;AAEH,eAAO,MAAM,GAAG,aApDF,WAAW,SACd;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;;;GAmD9B,CAAA;AAE7B,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
|
|
@@ -2,11 +2,11 @@ import { headers } from 'next/headers';
|
|
|
2
2
|
import { ApiKeyType } from '@prisma/client';
|
|
3
3
|
import { NextResponse } from 'next/server';
|
|
4
4
|
import { cacheHeaders } from '../../../../../lib/cache/cacheHeaders';
|
|
5
|
-
import { prisma } from '../../../../../lib/prisma';
|
|
5
|
+
import { prisma as defaultPrisma } from '../../../../../lib/prisma';
|
|
6
6
|
import { getApiKey } from '../../../../../lib/apiKeys/getApiKey';
|
|
7
7
|
import { getStorageProviderAssistants } from '../../../../../lib/storageProviders/getStorageProviderAssistants';
|
|
8
8
|
import { serializeApiStorageProviderAssistant } from '../../../../../lib/storageProviders/serializeApiStorageProviderAssistant';
|
|
9
|
-
export const
|
|
9
|
+
export const buildGET = ({ prisma = defaultPrisma } = {}) => async (_request, props) => {
|
|
10
10
|
const { modelProviderId } = await props.params;
|
|
11
11
|
const headersList = await headers();
|
|
12
12
|
const authorization = headersList.get('authorization');
|
|
@@ -16,6 +16,7 @@ export const GET = async (_request, props) => {
|
|
|
16
16
|
const privateApiKey = await getApiKey({
|
|
17
17
|
type: ApiKeyType.PRIVATE,
|
|
18
18
|
authorization,
|
|
19
|
+
prisma,
|
|
19
20
|
});
|
|
20
21
|
if (!privateApiKey) {
|
|
21
22
|
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
@@ -38,6 +39,7 @@ export const GET = async (_request, props) => {
|
|
|
38
39
|
})),
|
|
39
40
|
}, { headers: cacheHeaders });
|
|
40
41
|
};
|
|
42
|
+
export const GET = buildGET();
|
|
41
43
|
export const OPTIONS = () => NextResponse.json({}, {
|
|
42
44
|
headers: cacheHeaders,
|
|
43
45
|
});
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
+
import { type PrismaClient } from '@prisma/client';
|
|
1
2
|
import { NextResponse, type NextRequest } from 'next/server';
|
|
3
|
+
export declare const buildGET: ({ prisma }?: {
|
|
4
|
+
prisma?: PrismaClient;
|
|
5
|
+
}) => (_request: NextRequest, props: {
|
|
6
|
+
params: Promise<{
|
|
7
|
+
modelProviderId: string;
|
|
8
|
+
}>;
|
|
9
|
+
}) => Promise<NextResponse<{
|
|
10
|
+
error: string;
|
|
11
|
+
}> | NextResponse<{
|
|
12
|
+
models: {
|
|
13
|
+
id: string;
|
|
14
|
+
}[];
|
|
15
|
+
}>>;
|
|
2
16
|
export declare const GET: (_request: NextRequest, props: {
|
|
3
17
|
params: Promise<{
|
|
4
18
|
modelProviderId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/providers/[modelProviderId]/models/route.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/providers/[modelProviderId]/models/route.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAO5D,eAAO,MAAM,QAAQ,GAClB,aAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,UAAU,WAAW,EACrB,OAAO;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;GAiDxD,CAAA;AAEH,eAAO,MAAM,GAAG,aApDF,WAAW,SACd;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;GAmD9B,CAAA;AAE7B,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
|
|
@@ -2,11 +2,11 @@ import { headers } from 'next/headers';
|
|
|
2
2
|
import { ApiKeyType } from '@prisma/client';
|
|
3
3
|
import { NextResponse } from 'next/server';
|
|
4
4
|
import { cacheHeaders } from '../../../../../lib/cache/cacheHeaders';
|
|
5
|
-
import { prisma } from '../../../../../lib/prisma';
|
|
5
|
+
import { prisma as defaultPrisma } from '../../../../../lib/prisma';
|
|
6
6
|
import { getApiKey } from '../../../../../lib/apiKeys/getApiKey';
|
|
7
7
|
import { getModels } from '../../../../../lib/models/getModels';
|
|
8
8
|
import { serializeApiModel } from '../../../../../lib/models/serializeApiModel';
|
|
9
|
-
export const
|
|
9
|
+
export const buildGET = ({ prisma = defaultPrisma } = {}) => async (_request, props) => {
|
|
10
10
|
const { modelProviderId } = await props.params;
|
|
11
11
|
const headersList = await headers();
|
|
12
12
|
const authorization = headersList.get('authorization');
|
|
@@ -16,6 +16,7 @@ export const GET = async (_request, props) => {
|
|
|
16
16
|
const privateApiKey = await getApiKey({
|
|
17
17
|
type: ApiKeyType.PRIVATE,
|
|
18
18
|
authorization,
|
|
19
|
+
prisma,
|
|
19
20
|
});
|
|
20
21
|
if (!privateApiKey) {
|
|
21
22
|
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
@@ -38,6 +39,7 @@ export const GET = async (_request, props) => {
|
|
|
38
39
|
})),
|
|
39
40
|
}, { headers: cacheHeaders });
|
|
40
41
|
};
|
|
42
|
+
export const GET = buildGET();
|
|
41
43
|
export const OPTIONS = () => NextResponse.json({}, {
|
|
42
44
|
headers: cacheHeaders,
|
|
43
45
|
});
|
|
@@ -1,4 +1,26 @@
|
|
|
1
|
+
import { type PrismaClient } from '@prisma/client';
|
|
1
2
|
import { NextResponse, type NextRequest } from 'next/server';
|
|
3
|
+
export declare const buildGET: ({ prisma }?: {
|
|
4
|
+
prisma?: PrismaClient;
|
|
5
|
+
}) => (_request: NextRequest, props: {
|
|
6
|
+
params: Promise<{
|
|
7
|
+
modelProviderId: string;
|
|
8
|
+
}>;
|
|
9
|
+
}) => Promise<NextResponse<{
|
|
10
|
+
error: string;
|
|
11
|
+
}> | NextResponse<{
|
|
12
|
+
provider: {
|
|
13
|
+
id: string;
|
|
14
|
+
type: import("@prisma/client").$Enums.ModelProviderType;
|
|
15
|
+
name: string;
|
|
16
|
+
apiKey: string;
|
|
17
|
+
endpoint: string | null;
|
|
18
|
+
apiVersion: string | null;
|
|
19
|
+
workspaceId: string;
|
|
20
|
+
createdAt: string;
|
|
21
|
+
updatedAt: string;
|
|
22
|
+
};
|
|
23
|
+
}>>;
|
|
2
24
|
export declare const GET: (_request: NextRequest, props: {
|
|
3
25
|
params: Promise<{
|
|
4
26
|
modelProviderId: string;
|
|
@@ -18,6 +40,27 @@ export declare const GET: (_request: NextRequest, props: {
|
|
|
18
40
|
updatedAt: string;
|
|
19
41
|
};
|
|
20
42
|
}>>;
|
|
43
|
+
export declare const buildPATCH: ({ prisma }?: {
|
|
44
|
+
prisma?: PrismaClient;
|
|
45
|
+
}) => (request: NextRequest, props: {
|
|
46
|
+
params: Promise<{
|
|
47
|
+
modelProviderId: string;
|
|
48
|
+
}>;
|
|
49
|
+
}) => Promise<NextResponse<{
|
|
50
|
+
error: string;
|
|
51
|
+
}> | NextResponse<{
|
|
52
|
+
provider: {
|
|
53
|
+
id: string;
|
|
54
|
+
type: import("@prisma/client").$Enums.ModelProviderType;
|
|
55
|
+
name: string;
|
|
56
|
+
apiKey: string;
|
|
57
|
+
endpoint: string | null;
|
|
58
|
+
apiVersion: string | null;
|
|
59
|
+
workspaceId: string;
|
|
60
|
+
createdAt: string;
|
|
61
|
+
updatedAt: string;
|
|
62
|
+
};
|
|
63
|
+
}>>;
|
|
21
64
|
export declare const PATCH: (request: NextRequest, props: {
|
|
22
65
|
params: Promise<{
|
|
23
66
|
modelProviderId: string;
|
|
@@ -37,6 +80,27 @@ export declare const PATCH: (request: NextRequest, props: {
|
|
|
37
80
|
updatedAt: string;
|
|
38
81
|
};
|
|
39
82
|
}>>;
|
|
83
|
+
export declare const buildDELETE: ({ prisma }?: {
|
|
84
|
+
prisma?: PrismaClient;
|
|
85
|
+
}) => (_request: NextRequest, props: {
|
|
86
|
+
params: Promise<{
|
|
87
|
+
modelProviderId: string;
|
|
88
|
+
}>;
|
|
89
|
+
}) => Promise<NextResponse<{
|
|
90
|
+
error: string;
|
|
91
|
+
}> | NextResponse<{
|
|
92
|
+
provider: {
|
|
93
|
+
id: string;
|
|
94
|
+
type: import("@prisma/client").$Enums.ModelProviderType;
|
|
95
|
+
name: string;
|
|
96
|
+
apiKey: string;
|
|
97
|
+
endpoint: string | null;
|
|
98
|
+
apiVersion: string | null;
|
|
99
|
+
workspaceId: string;
|
|
100
|
+
createdAt: string;
|
|
101
|
+
updatedAt: string;
|
|
102
|
+
};
|
|
103
|
+
}>>;
|
|
40
104
|
export declare const DELETE: (_request: NextRequest, props: {
|
|
41
105
|
params: Promise<{
|
|
42
106
|
modelProviderId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../src/app/api/providers/[modelProviderId]/route.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../src/app/api/providers/[modelProviderId]/route.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAQ5D,eAAO,MAAM,QAAQ,GAClB,aAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,UAAU,WAAW,EACrB,OAAO;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;;;;;;GA+CxD,CAAA;AAEH,eAAO,MAAM,GAAG,aAlDF,WAAW,SACd;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;;;;;;GAiD9B,CAAA;AAE7B,eAAO,MAAM,UAAU,GACpB,aAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,SAAS,WAAW,EACpB,OAAO;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;;;;;;GAkFxD,CAAA;AAEH,eAAO,MAAM,KAAK,YArFL,WAAW,SACb;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;;;;;;GAoF1B,CAAA;AAEjC,eAAO,MAAM,WAAW,GACrB,aAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,UAAU,WAAW,EACrB,OAAO;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;;;;;;GA8DxD,CAAA;AAEH,eAAO,MAAM,MAAM,aAjEL,WAAW,SACd;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;;;;;;GAgExB,CAAA;AAEnC,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { headers } from 'next/headers';
|
|
2
|
-
import { ApiKeyType, ModelProviderType } from '@prisma/client';
|
|
2
|
+
import { ApiKeyType, ModelProviderType, } from '@prisma/client';
|
|
3
3
|
import { NextResponse } from 'next/server';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { cacheHeaders } from '../../../../lib/cache/cacheHeaders';
|
|
6
|
-
import { prisma } from '../../../../lib/prisma';
|
|
6
|
+
import { prisma as defaultPrisma } from '../../../../lib/prisma';
|
|
7
7
|
import { serializeModelProvider } from '../../../../lib/modelProviders/serializeModelProvider';
|
|
8
8
|
import { getApiKey } from '../../../../lib/apiKeys/getApiKey';
|
|
9
9
|
import { validate } from 'uuid';
|
|
10
|
-
export const
|
|
10
|
+
export const buildGET = ({ prisma = defaultPrisma } = {}) => async (_request, props) => {
|
|
11
11
|
const { modelProviderId } = await props.params;
|
|
12
12
|
const headersList = await headers();
|
|
13
13
|
const authorization = headersList.get('authorization');
|
|
@@ -17,6 +17,7 @@ export const GET = async (_request, props) => {
|
|
|
17
17
|
const privateApiKey = await getApiKey({
|
|
18
18
|
type: ApiKeyType.PRIVATE,
|
|
19
19
|
authorization,
|
|
20
|
+
prisma,
|
|
20
21
|
});
|
|
21
22
|
if (!privateApiKey) {
|
|
22
23
|
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
@@ -37,7 +38,8 @@ export const GET = async (_request, props) => {
|
|
|
37
38
|
provider: serializeModelProvider({ provider }),
|
|
38
39
|
}, { headers: cacheHeaders });
|
|
39
40
|
};
|
|
40
|
-
export const
|
|
41
|
+
export const GET = buildGET();
|
|
42
|
+
export const buildPATCH = ({ prisma = defaultPrisma } = {}) => async (request, props) => {
|
|
41
43
|
const { modelProviderId } = await props.params;
|
|
42
44
|
const headersList = await headers();
|
|
43
45
|
const authorization = headersList.get('authorization');
|
|
@@ -47,6 +49,7 @@ export const PATCH = async (request, props) => {
|
|
|
47
49
|
const privateApiKey = await getApiKey({
|
|
48
50
|
authorization,
|
|
49
51
|
type: ApiKeyType.PRIVATE,
|
|
52
|
+
prisma,
|
|
50
53
|
});
|
|
51
54
|
if (!privateApiKey) {
|
|
52
55
|
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
@@ -66,7 +69,7 @@ export const PATCH = async (request, props) => {
|
|
|
66
69
|
if (!parsed.success) {
|
|
67
70
|
return NextResponse.json({ error: 'Invalid payload' }, { status: 400 });
|
|
68
71
|
}
|
|
69
|
-
const { type, apiKey: providerKey, endpoint, apiVersion, name } = parsed.data;
|
|
72
|
+
const { type, apiKey: providerKey, endpoint, apiVersion, name, } = parsed.data;
|
|
70
73
|
const updateData = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (type ? { type } : {})), (name !== undefined ? { name } : {})), (providerKey !== undefined ? { apiKey: providerKey } : {})), (endpoint !== undefined ? { endpoint } : {})), (apiVersion !== undefined ? { apiVersion } : {}));
|
|
71
74
|
const existingProvider = await prisma.modelProvider.findFirst({
|
|
72
75
|
where: {
|
|
@@ -85,7 +88,8 @@ export const PATCH = async (request, props) => {
|
|
|
85
88
|
provider: serializeModelProvider({ provider }),
|
|
86
89
|
}, { headers: cacheHeaders });
|
|
87
90
|
};
|
|
88
|
-
export const
|
|
91
|
+
export const PATCH = buildPATCH();
|
|
92
|
+
export const buildDELETE = ({ prisma = defaultPrisma } = {}) => async (_request, props) => {
|
|
89
93
|
const { modelProviderId } = await props.params;
|
|
90
94
|
const headersList = await headers();
|
|
91
95
|
const authorization = headersList.get('authorization');
|
|
@@ -95,6 +99,7 @@ export const DELETE = async (_request, props) => {
|
|
|
95
99
|
const privateApiKey = await getApiKey({
|
|
96
100
|
authorization,
|
|
97
101
|
type: ApiKeyType.PRIVATE,
|
|
102
|
+
prisma,
|
|
98
103
|
});
|
|
99
104
|
if (!privateApiKey) {
|
|
100
105
|
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
@@ -127,6 +132,7 @@ export const DELETE = async (_request, props) => {
|
|
|
127
132
|
provider: serializeModelProvider({ provider }),
|
|
128
133
|
}, { headers: cacheHeaders });
|
|
129
134
|
};
|
|
135
|
+
export const DELETE = buildDELETE();
|
|
130
136
|
export const OPTIONS = () => NextResponse.json({}, {
|
|
131
137
|
headers: cacheHeaders,
|
|
132
138
|
});
|
|
@@ -1,4 +1,22 @@
|
|
|
1
|
+
import { type PrismaClient } from '@prisma/client';
|
|
1
2
|
import { NextResponse, type NextRequest } from 'next/server';
|
|
3
|
+
export declare const buildGET: ({ prisma }?: {
|
|
4
|
+
prisma?: PrismaClient;
|
|
5
|
+
}) => () => Promise<NextResponse<{
|
|
6
|
+
error: string;
|
|
7
|
+
}> | NextResponse<{
|
|
8
|
+
providers: {
|
|
9
|
+
id: string;
|
|
10
|
+
type: import("@prisma/client").$Enums.ModelProviderType;
|
|
11
|
+
name: string;
|
|
12
|
+
apiKey: string;
|
|
13
|
+
endpoint: string | null;
|
|
14
|
+
apiVersion: string | null;
|
|
15
|
+
workspaceId: string;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
updatedAt: string;
|
|
18
|
+
}[];
|
|
19
|
+
}>>;
|
|
2
20
|
export declare const GET: () => Promise<NextResponse<{
|
|
3
21
|
error: string;
|
|
4
22
|
}> | NextResponse<{
|
|
@@ -14,6 +32,23 @@ export declare const GET: () => Promise<NextResponse<{
|
|
|
14
32
|
updatedAt: string;
|
|
15
33
|
}[];
|
|
16
34
|
}>>;
|
|
35
|
+
export declare const buildPOST: ({ prisma }?: {
|
|
36
|
+
prisma?: PrismaClient;
|
|
37
|
+
}) => (request: NextRequest) => Promise<NextResponse<{
|
|
38
|
+
error: string;
|
|
39
|
+
}> | NextResponse<{
|
|
40
|
+
provider: {
|
|
41
|
+
id: string;
|
|
42
|
+
type: import("@prisma/client").$Enums.ModelProviderType;
|
|
43
|
+
name: string;
|
|
44
|
+
apiKey: string;
|
|
45
|
+
endpoint: string | null;
|
|
46
|
+
apiVersion: string | null;
|
|
47
|
+
workspaceId: string;
|
|
48
|
+
createdAt: string;
|
|
49
|
+
updatedAt: string;
|
|
50
|
+
};
|
|
51
|
+
}>>;
|
|
17
52
|
export declare const POST: (request: NextRequest) => Promise<NextResponse<{
|
|
18
53
|
error: string;
|
|
19
54
|
}> | NextResponse<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/app/api/providers/route.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/app/api/providers/route.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAO5D,eAAO,MAAM,QAAQ,GAClB,aAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO;;;;;;;;;;;;;;GAmC1D,CAAA;AAEH,eAAO,MAAM,GAAG;;;;;;;;;;;;;;GAAa,CAAA;AAE7B,eAAO,MAAM,SAAS,GACnB,aAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MACpD,SAAS,WAAW;;;;;;;;;;;;;;GA6D1B,CAAA;AAEH,eAAO,MAAM,IAAI,YA/DC,WAAW;;;;;;;;;;;;;;GA+DE,CAAA;AAE/B,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { headers } from 'next/headers';
|
|
2
|
-
import { ApiKeyType, ModelProviderType } from '@prisma/client';
|
|
2
|
+
import { ApiKeyType, ModelProviderType, } from '@prisma/client';
|
|
3
3
|
import { NextResponse } from 'next/server';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { cacheHeaders } from '../../../lib/cache/cacheHeaders';
|
|
6
|
-
import { prisma } from '../../../lib/prisma';
|
|
6
|
+
import { prisma as defaultPrisma } from '../../../lib/prisma';
|
|
7
7
|
import { serializeModelProvider } from '../../../lib/modelProviders/serializeModelProvider';
|
|
8
8
|
import { getApiKey } from '../../../lib/apiKeys/getApiKey';
|
|
9
|
-
export const
|
|
9
|
+
export const buildGET = ({ prisma = defaultPrisma } = {}) => async () => {
|
|
10
10
|
const headersList = await headers();
|
|
11
11
|
const authorization = headersList.get('authorization');
|
|
12
12
|
if (!authorization) {
|
|
@@ -15,6 +15,7 @@ export const GET = async () => {
|
|
|
15
15
|
const privateApiKey = await getApiKey({
|
|
16
16
|
type: ApiKeyType.PRIVATE,
|
|
17
17
|
authorization,
|
|
18
|
+
prisma,
|
|
18
19
|
});
|
|
19
20
|
if (!privateApiKey) {
|
|
20
21
|
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
@@ -28,7 +29,8 @@ export const GET = async () => {
|
|
|
28
29
|
providers: providers.map((p) => serializeModelProvider({ provider: p })),
|
|
29
30
|
}, { headers: cacheHeaders });
|
|
30
31
|
};
|
|
31
|
-
export const
|
|
32
|
+
export const GET = buildGET();
|
|
33
|
+
export const buildPOST = ({ prisma = defaultPrisma } = {}) => async (request) => {
|
|
32
34
|
const headersList = await headers();
|
|
33
35
|
const authorization = headersList.get('authorization');
|
|
34
36
|
if (!authorization) {
|
|
@@ -37,6 +39,7 @@ export const POST = async (request) => {
|
|
|
37
39
|
const privateApiKey = await getApiKey({
|
|
38
40
|
authorization,
|
|
39
41
|
type: ApiKeyType.PRIVATE,
|
|
42
|
+
prisma,
|
|
40
43
|
});
|
|
41
44
|
if (!privateApiKey) {
|
|
42
45
|
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
@@ -53,7 +56,7 @@ export const POST = async (request) => {
|
|
|
53
56
|
if (!parsed.success) {
|
|
54
57
|
return NextResponse.json({ error: 'Invalid payload' }, { status: 400 });
|
|
55
58
|
}
|
|
56
|
-
const { type, name, apiKey: providerKey, endpoint, apiVersion } = parsed.data;
|
|
59
|
+
const { type, name, apiKey: providerKey, endpoint, apiVersion, } = parsed.data;
|
|
57
60
|
const workspaceId = privateApiKey.workspaceId;
|
|
58
61
|
const provider = await prisma.modelProvider.create({
|
|
59
62
|
data: {
|
|
@@ -69,6 +72,7 @@ export const POST = async (request) => {
|
|
|
69
72
|
provider: serializeModelProvider({ provider }),
|
|
70
73
|
}, { headers: cacheHeaders });
|
|
71
74
|
};
|
|
75
|
+
export const POST = buildPOST();
|
|
72
76
|
export const OPTIONS = () => NextResponse.json({}, {
|
|
73
77
|
headers: cacheHeaders,
|
|
74
78
|
});
|