From e6b659f809a0ed4225bd8c1986d2ee25146ebd94 Mon Sep 17 00:00:00 2001 From: Kirk Lin Date: Wed, 7 Feb 2024 00:25:14 +0800 Subject: [PATCH] chore: fix build --- .../openai/api/chat-with-functions.ts | 1 + .../services/openai/api/chat-with-vision.ts | 1 + packages/ai/services/openai/api/chat.ts | 1 + packages/ai/services/openai/api/completion.ts | 1 + .../ai/services/openai/api/proxy/[...].ts | 10 ---- packages/ai/services/openai/package.json | 1 + pnpm-lock.yaml | 57 +++++++++++++------ services/admin/package.json | 1 + 8 files changed, 45 insertions(+), 28 deletions(-) delete mode 100644 packages/ai/services/openai/api/proxy/[...].ts diff --git a/packages/ai/services/openai/api/chat-with-functions.ts b/packages/ai/services/openai/api/chat-with-functions.ts index 3b0538f6..d5b2f81c 100644 --- a/packages/ai/services/openai/api/chat-with-functions.ts +++ b/packages/ai/services/openai/api/chat-with-functions.ts @@ -5,6 +5,7 @@ import { } from "ai"; import OpenAI from "openai"; import type { ChatCompletionCreateParams } from "openai/resources/chat"; +import { defineEventHandler, defineLazyEventHandler, readBody } from "h3"; import { getServerConfig } from "../config/server"; const functions: ChatCompletionCreateParams.Function[] = [ diff --git a/packages/ai/services/openai/api/chat-with-vision.ts b/packages/ai/services/openai/api/chat-with-vision.ts index 12c3f013..24ccb22e 100644 --- a/packages/ai/services/openai/api/chat-with-vision.ts +++ b/packages/ai/services/openai/api/chat-with-vision.ts @@ -1,5 +1,6 @@ import { OpenAIStream, StreamingTextResponse } from "ai"; import OpenAI from "openai"; +import { defineEventHandler, defineLazyEventHandler, readBody } from "h3"; import { getServerConfig } from "../config/server"; export default defineLazyEventHandler(async () => { diff --git a/packages/ai/services/openai/api/chat.ts b/packages/ai/services/openai/api/chat.ts index bd5735c0..b40376ab 100644 --- a/packages/ai/services/openai/api/chat.ts +++ b/packages/ai/services/openai/api/chat.ts @@ -1,6 +1,7 @@ import { OpenAIStream, StreamingTextResponse } from "ai"; import OpenAI from "openai"; import type { ChatCompletionMessageParam } from "openai/resources/chat"; +import { defineEventHandler, defineLazyEventHandler, readBody } from "h3"; import { getServerConfig } from "../config/server"; export default defineLazyEventHandler(async () => { diff --git a/packages/ai/services/openai/api/completion.ts b/packages/ai/services/openai/api/completion.ts index 44f5b1be..0527a74d 100644 --- a/packages/ai/services/openai/api/completion.ts +++ b/packages/ai/services/openai/api/completion.ts @@ -4,6 +4,7 @@ import { experimental_StreamData, } from "ai"; import OpenAI from "openai"; +import { defineEventHandler, defineLazyEventHandler, readBody } from "h3"; import { getServerConfig } from "../config/server"; export default defineLazyEventHandler(async () => { diff --git a/packages/ai/services/openai/api/proxy/[...].ts b/packages/ai/services/openai/api/proxy/[...].ts deleted file mode 100644 index e14f6ea6..00000000 --- a/packages/ai/services/openai/api/proxy/[...].ts +++ /dev/null @@ -1,10 +0,0 @@ -import { sendProxy } from "h3"; - -const config = useRuntimeConfig(); -export default defineEventHandler(async (event) => { - const target = new URL( - event.node.req.url.replace(/^\/api\/proxy/, ""), - config.proxyApiUrl, - ); - return await sendProxy(event, target.toString()); -}); diff --git a/packages/ai/services/openai/package.json b/packages/ai/services/openai/package.json index 1343dadd..e9f68193 100644 --- a/packages/ai/services/openai/package.json +++ b/packages/ai/services/openai/package.json @@ -13,6 +13,7 @@ "devDependencies": { "@celeris/constants": "workspace:*", "@celeris/types": "workspace:*", + "h3": "^1.10.1", "nitropack": "^2.8.1" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1395e050..e103bad2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -257,6 +257,9 @@ importers: '@celeris/types': specifier: workspace:* version: link:../../../web/types + h3: + specifier: ^1.10.1 + version: 1.10.1 nitropack: specifier: ^2.8.1 version: 2.8.1 @@ -565,6 +568,9 @@ importers: '@celeris/types': specifier: workspace:* version: link:../../packages/web/types + h3: + specifier: ^1.10.1 + version: 1.10.1 nitropack: specifier: ^2.8.1 version: 2.8.1 @@ -6925,6 +6931,10 @@ packages: /defu@6.1.3: resolution: {integrity: sha512-Vy2wmG3NTkmHNg/kzpuvHhkqeIx3ODWqasgCRbKtbXEN0G+HpEEv9BtJLp7ZG1CZloFaC41Ah3ZFbq7aqCqMeQ==} + /defu@6.1.4: + resolution: {integrity: sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==} + dev: true + /delayed-stream@1.0.0: resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} engines: {node: '>=0.4.0'} @@ -8317,7 +8327,7 @@ packages: node-fetch-native: 1.6.1 nypm: 0.3.6 ohash: 1.1.3 - pathe: 1.1.1 + pathe: 1.1.2 tar: 6.2.0 dev: true @@ -8483,17 +8493,18 @@ packages: duplexer: 0.1.2 dev: true - /h3@1.9.0: - resolution: {integrity: sha512-+F3ZqrNV/CFXXfZ2lXBINHi+rM4Xw3CDC5z2CDK3NMPocjonKipGLLDSkrqY9DOrioZNPTIdDMWfQKm//3X2DA==} + /h3@1.10.1: + resolution: {integrity: sha512-UBAUp47hmm4BB5/njB4LrEa9gpuvZj4/Qf/ynSMzO6Ku2RXaouxEfiG2E2IFnv6fxbhAkzjasDxmo6DFdEeXRg==} dependencies: cookie-es: 1.0.0 - defu: 6.1.3 + defu: 6.1.4 destr: 2.0.2 iron-webcrypto: 1.0.0 + ohash: 1.1.3 radix3: 1.1.0 ufo: 1.3.2 uncrypto: 0.1.3 - unenv: 1.8.0 + unenv: 1.9.0 dev: true /hard-rejection@2.1.0: @@ -9469,7 +9480,7 @@ packages: consola: 3.2.3 defu: 6.1.3 get-port-please: 3.1.1 - h3: 1.9.0 + h3: 1.10.1 http-shutdown: 1.2.2 jiti: 1.21.0 mlly: 1.5.0 @@ -10055,14 +10066,14 @@ packages: optional: true dependencies: citty: 0.1.3 - defu: 6.1.2 + defu: 6.1.3 esbuild: 0.18.20 fs-extra: 11.2.0 globby: 13.2.2 jiti: 1.19.3 mlly: 1.4.0 mri: 1.2.0 - pathe: 1.1.1 + pathe: 1.1.2 typescript: 5.3.3 dev: true @@ -10078,16 +10089,16 @@ packages: resolution: {integrity: sha512-ua8PAThnTwpprIaU47EPeZ/bPUVp2QYBbWMphUQpVdBI3Lgqzm5KZQ45Agm3YJedHXaIHl6pBGabaLSUPPSptg==} dependencies: acorn: 8.10.0 - pathe: 1.1.1 + pathe: 1.1.2 pkg-types: 1.0.3 - ufo: 1.1.2 + ufo: 1.3.2 dev: true /mlly@1.4.2: resolution: {integrity: sha512-i/Ykufi2t1EZ6NaPLdfnZk2AX8cs0d+mTzVKuPfqPKPatxLApaBoxJQ9x1/uckXtrS/U5oisPMDkNs0yQTaBRg==} dependencies: acorn: 8.10.0 - pathe: 1.1.1 + pathe: 1.1.2 pkg-types: 1.0.3 ufo: 1.3.2 @@ -10221,7 +10232,7 @@ packages: fs-extra: 11.2.0 globby: 14.0.0 gzip-size: 7.0.0 - h3: 1.9.0 + h3: 1.10.1 hookable: 5.5.3 httpxy: 0.1.5 is-primitive: 3.0.1 @@ -12777,6 +12788,16 @@ packages: pathe: 1.1.1 dev: true + /unenv@1.9.0: + resolution: {integrity: sha512-QKnFNznRxmbOF1hDgzpqrlIf6NC5sbZ2OJ+5Wl3OX8uM+LUJXbj4TXvLJCtwbPTmbMHCLIz6JLKNinNsMShK9g==} + dependencies: + consola: 3.2.3 + defu: 6.1.4 + mime: 3.0.0 + node-fetch-native: 1.6.1 + pathe: 1.1.2 + dev: true + /unicode-canonical-property-names-ecmascript@2.0.0: resolution: {integrity: sha512-yY5PpDlfVIU5+y/BSCxAJRBIS1Zc2dDG3Ujq+sR0U+JjUevW2JhocOF+soROYDSaAezOzOKuyyixhD6mBknSmQ==} engines: {node: '>=4'} @@ -12814,9 +12835,9 @@ packages: estree-walker: 3.0.3 fast-glob: 3.3.2 local-pkg: 0.5.0 - magic-string: 0.30.5 - mlly: 1.4.2 - pathe: 1.1.1 + magic-string: 0.30.7 + mlly: 1.5.0 + pathe: 1.1.2 pkg-types: 1.0.3 scule: 1.1.1 strip-literal: 1.3.0 @@ -13119,7 +13140,7 @@ packages: anymatch: 3.1.3 chokidar: 3.5.3 destr: 2.0.2 - h3: 1.9.0 + h3: 1.10.1 ioredis: 5.3.2 listhen: 1.5.5 lru-cache: 10.1.0 @@ -13137,7 +13158,7 @@ packages: dependencies: citty: 0.1.5 consola: 3.2.3 - pathe: 1.1.1 + pathe: 1.1.2 dev: true /untyped@1.4.0: @@ -13147,7 +13168,7 @@ packages: '@babel/core': 7.22.15 '@babel/standalone': 7.22.15 '@babel/types': 7.22.15 - defu: 6.1.2 + defu: 6.1.3 jiti: 1.19.3 mri: 1.2.0 scule: 1.0.0 diff --git a/services/admin/package.json b/services/admin/package.json index 198cedcf..71009a85 100644 --- a/services/admin/package.json +++ b/services/admin/package.json @@ -11,6 +11,7 @@ "devDependencies": { "@celeris/constants": "workspace:*", "@celeris/types": "workspace:*", + "h3": "^1.10.1", "nitropack": "^2.8.1" } }