@superinterface/server 1.0.25 → 1.0.27
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/api-keys/[apiKeyId]/route.js +1 -1
- package/.next/server/app/api/api-keys/[apiKeyId]/route.js.nft.json +1 -1
- package/.next/server/app/api/api-keys/route.js +1 -1
- package/.next/server/app/api/api-keys/route.js.nft.json +1 -1
- package/.next/server/app/api/assistants/[assistantId]/functions/[functionId]/route.js +1 -1
- package/.next/server/app/api/assistants/[assistantId]/functions/[functionId]/route.js.nft.json +1 -1
- package/.next/server/app/api/assistants/[assistantId]/functions/route.js +1 -1
- package/.next/server/app/api/assistants/[assistantId]/functions/route.js.nft.json +1 -1
- package/.next/server/app/api/assistants/[assistantId]/initial-messages/route.js +1 -1
- package/.next/server/app/api/assistants/[assistantId]/initial-messages/route.js.nft.json +1 -1
- package/.next/server/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.js +1 -1
- package/.next/server/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.js.nft.json +1 -1
- package/.next/server/app/api/assistants/[assistantId]/mcp-servers/route.js +1 -1
- package/.next/server/app/api/assistants/[assistantId]/mcp-servers/route.js.nft.json +1 -1
- package/.next/server/app/api/assistants/[assistantId]/route.js +1 -1
- package/.next/server/app/api/assistants/[assistantId]/route.js.nft.json +1 -1
- package/.next/server/app/api/assistants/route.js +1 -1
- package/.next/server/app/api/assistants/route.js.nft.json +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 +1 -1
- package/.next/server/app/api/messages/route.js.nft.json +1 -1
- package/.next/server/app/api/providers/[modelProviderId]/assistants/route.js +1 -1
- package/.next/server/app/api/providers/[modelProviderId]/assistants/route.js.nft.json +1 -1
- package/.next/server/app/api/providers/[modelProviderId]/models/route.js +1 -1
- package/.next/server/app/api/providers/[modelProviderId]/models/route.js.nft.json +1 -1
- package/.next/server/app/api/providers/[modelProviderId]/route.js +1 -1
- package/.next/server/app/api/providers/[modelProviderId]/route.js.nft.json +1 -1
- package/.next/server/app/api/providers/route.js +1 -1
- package/.next/server/app/api/providers/route.js.nft.json +1 -1
- package/.next/server/app/api/tasks/[taskId]/route.js +1 -1
- package/.next/server/app/api/tasks/[taskId]/route.js.nft.json +1 -1
- package/.next/server/app/api/tasks/callback/route.js +1 -1
- package/.next/server/app/api/tasks/callback/route.js.nft.json +1 -1
- package/.next/server/app/api/tasks/route.js +1 -1
- package/.next/server/app/api/tasks/route.js.nft.json +1 -1
- package/.next/server/app/api/threads/runs/submit-client-tool-outputs/route.js +1 -1
- package/.next/server/app/api/threads/runs/submit-client-tool-outputs/route.js.nft.json +1 -1
- package/.next/server/app/api/workspaces/[workspaceId]/route.js +1 -1
- package/.next/server/app/api/workspaces/[workspaceId]/route.js.nft.json +1 -1
- package/.next/server/app/api/workspaces/route.js +1 -1
- package/.next/server/app/api/workspaces/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]__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]__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]__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]__40ab45eb._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__40ab45eb._.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]__47b17fad._.js +38 -0
- package/.next/server/chunks/[root-of-the-server]__47b17fad._.js.map +1 -0
- 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]__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]__676affb1._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__676affb1._.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]__a878c913._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__a878c913._.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]__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]__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]__f6f61507._.js +38 -0
- package/.next/server/chunks/[root-of-the-server]__f6f61507._.js.map +1 -0
- 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/functions-config-manifest.json +1 -8
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/trace +1 -1
- package/dist/app/api/api-keys/[apiKeyId]/buildRoute.d.ts +52 -0
- package/dist/app/api/api-keys/[apiKeyId]/buildRoute.d.ts.map +1 -0
- package/dist/app/api/api-keys/[apiKeyId]/buildRoute.js +121 -0
- package/dist/app/api/api-keys/[apiKeyId]/route.d.ts +10 -21
- package/dist/app/api/api-keys/[apiKeyId]/route.d.ts.map +1 -1
- package/dist/app/api/api-keys/[apiKeyId]/route.js +6 -125
- package/dist/app/api/api-keys/buildRoute.d.ts +32 -0
- package/dist/app/api/api-keys/buildRoute.d.ts.map +1 -0
- package/dist/app/api/api-keys/buildRoute.js +104 -0
- package/dist/app/api/api-keys/builders.d.ts +31 -0
- package/dist/app/api/api-keys/builders.d.ts.map +1 -0
- package/dist/app/api/api-keys/builders.js +109 -0
- package/dist/app/api/api-keys/route.d.ts +5 -13
- package/dist/app/api/api-keys/route.d.ts.map +1 -1
- package/dist/app/api/api-keys/route.js +8 -108
- package/dist/app/api/assistants/[assistantId]/buildRoute.d.ts +120 -0
- package/dist/app/api/assistants/[assistantId]/buildRoute.d.ts.map +1 -0
- package/dist/app/api/assistants/[assistantId]/buildRoute.js +226 -0
- package/dist/app/api/assistants/[assistantId]/functions/[functionId]/buildRoute.d.ts +167 -0
- package/dist/app/api/assistants/[assistantId]/functions/[functionId]/buildRoute.d.ts.map +1 -0
- package/dist/app/api/assistants/[assistantId]/functions/[functionId]/buildRoute.js +184 -0
- package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.d.ts +10 -21
- package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.js +6 -191
- package/dist/app/api/assistants/[assistantId]/functions/buildRoute.d.ts +114 -0
- package/dist/app/api/assistants/[assistantId]/functions/buildRoute.d.ts.map +1 -0
- package/dist/app/api/assistants/[assistantId]/functions/buildRoute.js +117 -0
- package/dist/app/api/assistants/[assistantId]/functions/route.d.ts +7 -15
- package/dist/app/api/assistants/[assistantId]/functions/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/functions/route.js +5 -122
- package/dist/app/api/assistants/[assistantId]/initial-messages/buildRoute.d.ts +40 -0
- package/dist/app/api/assistants/[assistantId]/initial-messages/buildRoute.d.ts.map +1 -0
- package/dist/app/api/assistants/[assistantId]/initial-messages/buildRoute.js +85 -0
- package/dist/app/api/assistants/[assistantId]/initial-messages/route.d.ts +7 -15
- package/dist/app/api/assistants/[assistantId]/initial-messages/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/initial-messages/route.js +5 -90
- package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/buildRoute.d.ts +89 -0
- package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/buildRoute.d.ts.map +1 -0
- package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/buildRoute.js +167 -0
- package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.d.ts +10 -21
- 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 +6 -174
- package/dist/app/api/assistants/[assistantId]/mcp-servers/buildRoute.d.ts +62 -0
- package/dist/app/api/assistants/[assistantId]/mcp-servers/buildRoute.d.ts.map +1 -0
- package/dist/app/api/assistants/[assistantId]/mcp-servers/buildRoute.js +115 -0
- package/dist/app/api/assistants/[assistantId]/mcp-servers/route.d.ts +7 -15
- package/dist/app/api/assistants/[assistantId]/mcp-servers/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/mcp-servers/route.js +5 -120
- package/dist/app/api/assistants/[assistantId]/route.d.ts +11 -22
- package/dist/app/api/assistants/[assistantId]/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/route.js +6 -233
- package/dist/app/api/assistants/buildRoute.d.ts +121 -0
- package/dist/app/api/assistants/buildRoute.d.ts.map +1 -0
- package/dist/app/api/assistants/buildRoute.js +144 -0
- package/dist/app/api/assistants/route.d.ts +7 -13
- package/dist/app/api/assistants/route.d.ts.map +1 -1
- package/dist/app/api/assistants/route.js +6 -148
- package/dist/app/api/files/[fileId]/contents/buildRoute.d.ts +18 -0
- package/dist/app/api/files/[fileId]/contents/buildRoute.d.ts.map +1 -0
- package/dist/app/api/files/[fileId]/contents/buildRoute.js +81 -0
- package/dist/app/api/files/[fileId]/contents/route.d.ts +3 -13
- package/dist/app/api/files/[fileId]/contents/route.d.ts.map +1 -1
- package/dist/app/api/files/[fileId]/contents/route.js +4 -84
- package/dist/app/api/files/buildRoute.d.ts +14 -0
- package/dist/app/api/files/buildRoute.d.ts.map +1 -0
- package/dist/app/api/files/buildRoute.js +88 -0
- package/dist/app/api/files/route.d.ts +4 -10
- package/dist/app/api/files/route.d.ts.map +1 -1
- package/dist/app/api/files/route.js +4 -91
- package/dist/app/api/messages/buildRoute.d.ts +34 -0
- package/dist/app/api/messages/buildRoute.d.ts.map +1 -0
- package/dist/app/api/messages/buildRoute.js +607 -0
- package/dist/app/api/messages/lib/initialMessagesResponse.d.ts.map +1 -1
- package/dist/app/api/messages/lib/initialMessagesResponse.js +1 -1
- package/dist/app/api/messages/route.d.ts +10 -22
- package/dist/app/api/messages/route.d.ts.map +1 -1
- package/dist/app/api/messages/route.js +6 -612
- package/dist/app/api/providers/[modelProviderId]/assistants/buildRoute.d.ts +24 -0
- package/dist/app/api/providers/[modelProviderId]/assistants/buildRoute.d.ts.map +1 -0
- package/dist/app/api/providers/[modelProviderId]/assistants/buildRoute.js +43 -0
- package/dist/app/api/providers/[modelProviderId]/assistants/route.d.ts +4 -9
- package/dist/app/api/providers/[modelProviderId]/assistants/route.d.ts.map +1 -1
- package/dist/app/api/providers/[modelProviderId]/assistants/route.js +4 -46
- package/dist/app/api/providers/[modelProviderId]/buildRoute.d.ts +61 -0
- package/dist/app/api/providers/[modelProviderId]/buildRoute.d.ts.map +1 -0
- package/dist/app/api/providers/[modelProviderId]/buildRoute.js +134 -0
- package/dist/app/api/providers/[modelProviderId]/models/buildRoute.d.ts +19 -0
- package/dist/app/api/providers/[modelProviderId]/models/buildRoute.d.ts.map +1 -0
- package/dist/app/api/providers/[modelProviderId]/models/buildRoute.js +43 -0
- package/dist/app/api/providers/[modelProviderId]/models/route.d.ts +4 -9
- package/dist/app/api/providers/[modelProviderId]/models/route.d.ts.map +1 -1
- package/dist/app/api/providers/[modelProviderId]/models/route.js +4 -46
- package/dist/app/api/providers/[modelProviderId]/route.d.ts +10 -21
- package/dist/app/api/providers/[modelProviderId]/route.d.ts.map +1 -1
- package/dist/app/api/providers/[modelProviderId]/route.js +6 -141
- package/dist/app/api/providers/buildRoute.d.ts +38 -0
- package/dist/app/api/providers/buildRoute.d.ts.map +1 -0
- package/dist/app/api/providers/buildRoute.js +75 -0
- package/dist/app/api/providers/route.d.ts +5 -13
- package/dist/app/api/providers/route.d.ts.map +1 -1
- package/dist/app/api/providers/route.js +5 -80
- package/dist/app/api/tasks/[taskId]/buildRoute.d.ts +19 -0
- package/dist/app/api/tasks/[taskId]/buildRoute.d.ts.map +1 -0
- package/dist/app/api/tasks/[taskId]/buildRoute.js +125 -0
- package/dist/app/api/tasks/[taskId]/route.d.ts +7 -57
- package/dist/app/api/tasks/[taskId]/route.d.ts.map +1 -1
- package/dist/app/api/tasks/[taskId]/route.js +6 -144
- package/dist/app/api/tasks/buildRoute.d.ts +36 -0
- package/dist/app/api/tasks/buildRoute.d.ts.map +1 -0
- package/dist/app/api/tasks/buildRoute.js +85 -0
- package/dist/app/api/tasks/callback/buildRoute.d.ts +6 -0
- package/dist/app/api/tasks/callback/buildRoute.d.ts.map +1 -0
- package/dist/app/api/tasks/callback/buildRoute.js +244 -0
- package/dist/app/api/tasks/callback/route.d.ts +2 -1
- package/dist/app/api/tasks/callback/route.d.ts.map +1 -1
- package/dist/app/api/tasks/callback/route.js +4 -244
- package/dist/app/api/tasks/route.d.ts +5 -13
- package/dist/app/api/tasks/route.d.ts.map +1 -1
- package/dist/app/api/tasks/route.js +5 -90
- package/dist/app/api/threads/runs/submit-client-tool-outputs/buildRoute.d.ts +10 -0
- package/dist/app/api/threads/runs/submit-client-tool-outputs/buildRoute.d.ts.map +1 -0
- package/dist/app/api/threads/runs/submit-client-tool-outputs/buildRoute.js +36 -0
- package/dist/app/api/threads/runs/submit-client-tool-outputs/route.d.ts +2 -7
- 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 +3 -37
- package/dist/app/api/workspaces/[workspaceId]/buildRoute.d.ts +16 -0
- package/dist/app/api/workspaces/[workspaceId]/buildRoute.d.ts.map +1 -0
- package/dist/app/api/workspaces/[workspaceId]/buildRoute.js +89 -0
- package/dist/app/api/workspaces/[workspaceId]/route.d.ts +5 -31
- package/dist/app/api/workspaces/[workspaceId]/route.d.ts.map +1 -1
- package/dist/app/api/workspaces/[workspaceId]/route.js +5 -89
- package/dist/app/api/workspaces/buildRoute.d.ts +42 -0
- package/dist/app/api/workspaces/buildRoute.d.ts.map +1 -0
- package/dist/app/api/workspaces/buildRoute.js +78 -0
- package/dist/app/api/workspaces/route.d.ts +7 -27
- package/dist/app/api/workspaces/route.d.ts.map +1 -1
- package/dist/app/api/workspaces/route.js +6 -82
- package/dist/lib/functions/functionSchema.d.ts +56 -56
- package/dist/lib/functions/handleFunction/getFunction.d.ts +4 -4
- package/dist/lib/mcpServers/mcpServerSchema.d.ts +20 -20
- package/dist/lib/prisma/index.d.ts +1 -9
- package/dist/lib/prisma/index.d.ts.map +1 -1
- package/dist/lib/prisma/index.js +10 -78
- package/package.json +4 -12
- package/.next/server/chunks/[root-of-the-server]__228bff78._.js +0 -38
- package/.next/server/chunks/[root-of-the-server]__228bff78._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__3307123c._.js +0 -38
- package/.next/server/chunks/[root-of-the-server]__3307123c._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__50c5f12c._.js +0 -38
- package/.next/server/chunks/[root-of-the-server]__50c5f12c._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__6b8ba839._.js +0 -38
- package/.next/server/chunks/[root-of-the-server]__6b8ba839._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__e7819e95._.js +0 -38
- package/.next/server/chunks/[root-of-the-server]__e7819e95._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__f0dfab03._.js +0 -38
- package/.next/server/chunks/[root-of-the-server]__f0dfab03._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__ff90af03._.js +0 -38
- package/.next/server/chunks/[root-of-the-server]__ff90af03._.js.map +0 -1
- /package/.next/static/{jt8inwg6nWaLQZ4qpiSJ- → iaWEclnh6aHcuw0CBnWpA}/_buildManifest.js +0 -0
- /package/.next/static/{jt8inwg6nWaLQZ4qpiSJ- → iaWEclnh6aHcuw0CBnWpA}/_clientMiddlewareManifest.json +0 -0
- /package/.next/static/{jt8inwg6nWaLQZ4qpiSJ- → iaWEclnh6aHcuw0CBnWpA}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { isString } from 'radash';
|
|
2
|
+
import { StorageProviderType } from '@prisma/client';
|
|
3
|
+
import { NextResponse } from 'next/server';
|
|
4
|
+
import { cacheHeaders } from '../../../lib/cache/cacheHeaders';
|
|
5
|
+
import { assistantClientAdapter } from '../../../lib/assistants/assistantClientAdapter';
|
|
6
|
+
import { workspaceAccessWhere as getWorkspaceAccessWhere } from '../../../lib/apiKeys/workspaceAccessWhere';
|
|
7
|
+
import { isOpenaiAssistantsStorageProvider } from '../../../lib/storageProviders/isOpenaiAssistantsStorageProvider';
|
|
8
|
+
export const buildPOST = ({ prisma }) => async (request) => {
|
|
9
|
+
var _a;
|
|
10
|
+
const formData = await request.formData();
|
|
11
|
+
const assistantId = formData.get('assistantId');
|
|
12
|
+
if (!isString(assistantId)) {
|
|
13
|
+
return NextResponse.json({ error: 'Invalid assistantId' }, { status: 400 });
|
|
14
|
+
}
|
|
15
|
+
const publicApiKey = formData.get('publicApiKey');
|
|
16
|
+
if (!isString(publicApiKey)) {
|
|
17
|
+
return NextResponse.json({ error: 'Invalid publicApiKey' }, { status: 400 });
|
|
18
|
+
}
|
|
19
|
+
const file = formData.get('file');
|
|
20
|
+
const workspaceAccessWhere = await getWorkspaceAccessWhere({
|
|
21
|
+
publicApiKey,
|
|
22
|
+
prisma,
|
|
23
|
+
});
|
|
24
|
+
if (!workspaceAccessWhere) {
|
|
25
|
+
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
26
|
+
}
|
|
27
|
+
if (!assistantId) {
|
|
28
|
+
return NextResponse.json({ error: 'No assistantId found' }, { status: 400 });
|
|
29
|
+
}
|
|
30
|
+
if (!file) {
|
|
31
|
+
return NextResponse.json({ error: 'No file found' }, { status: 400 });
|
|
32
|
+
}
|
|
33
|
+
const assistant = await prisma.assistant.findFirst({
|
|
34
|
+
where: {
|
|
35
|
+
id: assistantId,
|
|
36
|
+
workspace: workspaceAccessWhere,
|
|
37
|
+
},
|
|
38
|
+
include: {
|
|
39
|
+
modelProvider: true,
|
|
40
|
+
tools: {
|
|
41
|
+
include: {
|
|
42
|
+
fileSearchTool: true,
|
|
43
|
+
webSearchTool: true,
|
|
44
|
+
imageGenerationTool: true,
|
|
45
|
+
codeInterpreterTool: true,
|
|
46
|
+
computerUseTool: true,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
mcpServers: {
|
|
50
|
+
include: {
|
|
51
|
+
computerUseTool: true,
|
|
52
|
+
stdioTransport: true,
|
|
53
|
+
sseTransport: true,
|
|
54
|
+
httpTransport: true,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
functions: true,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
if (!assistant) {
|
|
61
|
+
return NextResponse.json({ error: 'No assistant found' }, { status: 400 });
|
|
62
|
+
}
|
|
63
|
+
if (isOpenaiAssistantsStorageProvider({
|
|
64
|
+
storageProviderType: assistant.storageProviderType,
|
|
65
|
+
}) &&
|
|
66
|
+
!assistant.openaiAssistantId) {
|
|
67
|
+
return NextResponse.json({ error: 'Assistant setup is not done.' }, { status: 400 });
|
|
68
|
+
}
|
|
69
|
+
const assistantClient = assistantClientAdapter({ assistant, prisma });
|
|
70
|
+
const purpose = (_a = formData.get('purpose')) !== null && _a !== void 0 ? _a : 'assistants';
|
|
71
|
+
const createFileResponse = await assistantClient.files.create(Object.assign({
|
|
72
|
+
// @ts-expect-error file is Uploadable
|
|
73
|
+
file,
|
|
74
|
+
purpose }, (assistant.storageProviderType === StorageProviderType.OPENAI
|
|
75
|
+
? {
|
|
76
|
+
expires_after: {
|
|
77
|
+
anchor: 'created_at',
|
|
78
|
+
seconds: 2592000, // 30 days
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
: {})));
|
|
82
|
+
return NextResponse.json({
|
|
83
|
+
file: createFileResponse,
|
|
84
|
+
}, { headers: cacheHeaders });
|
|
85
|
+
};
|
|
86
|
+
export const buildOPTIONS = () => () => NextResponse.json({}, {
|
|
87
|
+
headers: cacheHeaders,
|
|
88
|
+
});
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import { type PrismaClient } from '@prisma/client';
|
|
3
|
-
import { type NextRequest, NextResponse } from 'next/server';
|
|
4
|
-
export declare const buildPOST: ({ prisma: providedPrisma }?: {
|
|
5
|
-
prisma?: PrismaClient;
|
|
6
|
-
}) => (request: NextRequest) => Promise<NextResponse<{
|
|
1
|
+
export declare const POST: (request: import("next/server").NextRequest) => Promise<import("next/server").NextResponse<{
|
|
7
2
|
error: string;
|
|
8
|
-
}> | NextResponse<{
|
|
9
|
-
file:
|
|
3
|
+
}> | import("next/server").NextResponse<{
|
|
4
|
+
file: import("openai/resources/files.mjs").FileObject & {
|
|
10
5
|
_request_id?: string | null;
|
|
11
6
|
};
|
|
12
7
|
}>>;
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const OPTIONS: () => NextResponse<{}>;
|
|
8
|
+
export declare const OPTIONS: () => import("next/server").NextResponse<{}>;
|
|
15
9
|
//# sourceMappingURL=route.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/app/api/files/route.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/app/api/files/route.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,IAAI;;;;;;GAAwB,CAAA;AAEzC,eAAO,MAAM,OAAO,8CAAiB,CAAA"}
|
|
@@ -1,91 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { assistantClientAdapter } from '../../../lib/assistants/assistantClientAdapter';
|
|
6
|
-
import { workspaceAccessWhere as getWorkspaceAccessWhere } from '../../../lib/apiKeys/workspaceAccessWhere';
|
|
7
|
-
import { resolvePrisma } from '../../../lib/prisma';
|
|
8
|
-
import { isOpenaiAssistantsStorageProvider } from '../../../lib/storageProviders/isOpenaiAssistantsStorageProvider';
|
|
9
|
-
export const buildPOST = ({ prisma: providedPrisma } = {}) => async (request) => {
|
|
10
|
-
var _a;
|
|
11
|
-
const prisma = resolvePrisma(providedPrisma);
|
|
12
|
-
const formData = await request.formData();
|
|
13
|
-
const assistantId = formData.get('assistantId');
|
|
14
|
-
if (!isString(assistantId)) {
|
|
15
|
-
return NextResponse.json({ error: 'Invalid assistantId' }, { status: 400 });
|
|
16
|
-
}
|
|
17
|
-
const publicApiKey = formData.get('publicApiKey');
|
|
18
|
-
if (!isString(publicApiKey)) {
|
|
19
|
-
return NextResponse.json({ error: 'Invalid publicApiKey' }, { status: 400 });
|
|
20
|
-
}
|
|
21
|
-
const file = formData.get('file');
|
|
22
|
-
const workspaceAccessWhere = await getWorkspaceAccessWhere({
|
|
23
|
-
publicApiKey,
|
|
24
|
-
prisma,
|
|
25
|
-
});
|
|
26
|
-
if (!workspaceAccessWhere) {
|
|
27
|
-
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
28
|
-
}
|
|
29
|
-
if (!assistantId) {
|
|
30
|
-
return NextResponse.json({ error: 'No assistantId found' }, { status: 400 });
|
|
31
|
-
}
|
|
32
|
-
if (!file) {
|
|
33
|
-
return NextResponse.json({ error: 'No file found' }, { status: 400 });
|
|
34
|
-
}
|
|
35
|
-
const assistant = await prisma.assistant.findFirst({
|
|
36
|
-
where: {
|
|
37
|
-
id: assistantId,
|
|
38
|
-
workspace: workspaceAccessWhere,
|
|
39
|
-
},
|
|
40
|
-
include: {
|
|
41
|
-
modelProvider: true,
|
|
42
|
-
tools: {
|
|
43
|
-
include: {
|
|
44
|
-
fileSearchTool: true,
|
|
45
|
-
webSearchTool: true,
|
|
46
|
-
imageGenerationTool: true,
|
|
47
|
-
codeInterpreterTool: true,
|
|
48
|
-
computerUseTool: true,
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
mcpServers: {
|
|
52
|
-
include: {
|
|
53
|
-
computerUseTool: true,
|
|
54
|
-
stdioTransport: true,
|
|
55
|
-
sseTransport: true,
|
|
56
|
-
httpTransport: true,
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
functions: true,
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
if (!assistant) {
|
|
63
|
-
return NextResponse.json({ error: 'No assistant found' }, { status: 400 });
|
|
64
|
-
}
|
|
65
|
-
if (isOpenaiAssistantsStorageProvider({
|
|
66
|
-
storageProviderType: assistant.storageProviderType,
|
|
67
|
-
}) &&
|
|
68
|
-
!assistant.openaiAssistantId) {
|
|
69
|
-
return NextResponse.json({ error: 'Assistant setup is not done.' }, { status: 400 });
|
|
70
|
-
}
|
|
71
|
-
const assistantClient = assistantClientAdapter({ assistant, prisma });
|
|
72
|
-
const purpose = (_a = formData.get('purpose')) !== null && _a !== void 0 ? _a : 'assistants';
|
|
73
|
-
const createFileResponse = await assistantClient.files.create(Object.assign({
|
|
74
|
-
// @ts-expect-error file is Uploadable
|
|
75
|
-
file,
|
|
76
|
-
purpose }, (assistant.storageProviderType === StorageProviderType.OPENAI
|
|
77
|
-
? {
|
|
78
|
-
expires_after: {
|
|
79
|
-
anchor: 'created_at',
|
|
80
|
-
seconds: 2592000, // 30 days
|
|
81
|
-
},
|
|
82
|
-
}
|
|
83
|
-
: {})));
|
|
84
|
-
return NextResponse.json({
|
|
85
|
-
file: createFileResponse,
|
|
86
|
-
}, { headers: cacheHeaders });
|
|
87
|
-
};
|
|
88
|
-
export const POST = ((...args) => buildPOST()(...args));
|
|
89
|
-
export const OPTIONS = () => NextResponse.json({}, {
|
|
90
|
-
headers: cacheHeaders,
|
|
91
|
-
});
|
|
1
|
+
import { prisma } from '../../../lib/prisma';
|
|
2
|
+
import { buildOPTIONS, buildPOST } from './buildRoute';
|
|
3
|
+
export const POST = buildPOST({ prisma });
|
|
4
|
+
export const OPTIONS = buildOPTIONS();
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type NextRequest, NextResponse } from 'next/server';
|
|
2
|
+
import OpenAI from 'openai';
|
|
3
|
+
import { type PrismaClient } from '@prisma/client';
|
|
4
|
+
import type { Thread } from '@prisma/client';
|
|
5
|
+
export declare const maxDuration = 800;
|
|
6
|
+
export declare const buildGET: ({ prisma }: {
|
|
7
|
+
prisma: PrismaClient;
|
|
8
|
+
}) => (request: NextRequest) => Promise<NextResponse<{
|
|
9
|
+
error: string;
|
|
10
|
+
}> | NextResponse<{
|
|
11
|
+
data: {
|
|
12
|
+
id: string;
|
|
13
|
+
role: "user" | "assistant";
|
|
14
|
+
created_at: number;
|
|
15
|
+
content: OpenAI.Beta.Threads.Messages.MessageContent[];
|
|
16
|
+
run_id: string;
|
|
17
|
+
assistant_id: string;
|
|
18
|
+
thread_id: string;
|
|
19
|
+
attachments: OpenAI.Beta.Threads.Messages.Message.Attachment[];
|
|
20
|
+
metadata: import("openai/resources/shared.mjs").Metadata;
|
|
21
|
+
runSteps: Pick<OpenAI.Beta.Threads.Runs.Steps.RunStep, "id" | "run_id" | "step_details" | "completed_at" | "cancelled_at" | "failed_at" | "status">[];
|
|
22
|
+
status: "in_progress" | "incomplete" | "completed";
|
|
23
|
+
}[];
|
|
24
|
+
hasNextPage: boolean;
|
|
25
|
+
lastId: null;
|
|
26
|
+
}> | NextResponse<import("@superinterface/react/types/index").MessagesPage>>;
|
|
27
|
+
export declare const buildPOST: ({ prisma, onSuccessCreateThread, }: {
|
|
28
|
+
prisma: PrismaClient;
|
|
29
|
+
onSuccessCreateThread?: ({ thread, }: {
|
|
30
|
+
thread: Thread;
|
|
31
|
+
}) => void | Promise<void>;
|
|
32
|
+
}) => (request: NextRequest) => Promise<Response>;
|
|
33
|
+
export declare const buildOPTIONS: () => () => NextResponse<{}>;
|
|
34
|
+
//# sourceMappingURL=buildRoute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildRoute.d.ts","sourceRoot":"","sources":["../../../../src/app/api/messages/buildRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AA0B5C,eAAO,MAAM,WAAW,MAAM,CAAA;AAE9B,eAAO,MAAM,QAAQ,GAClB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,SAAS,WAAW;;;;;;;;;;;;;;;;;;4EA2K1B,CAAA;AAEH,eAAO,MAAM,SAAS,GACnB,oCAGE;IACD,MAAM,EAAE,YAAY,CAAA;IACpB,qBAAqB,CAAC,EAAE,CAAC,EACvB,MAAM,GACP,EAAE;QACD,MAAM,EAAE,MAAM,CAAA;KACf,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC3B,MACM,SAAS,WAAW,sBA+f1B,CAAA;AAEH,eAAO,MAAM,YAAY,8BAMtB,CAAA"}
|