refactor!: use xsschema/ext-providers instead of typeschema/providers (#50)
* refactor!: use xsschema/ext-providers instead of typeschema/deprecated-providers * fix: add deps * chore: remove gcornut/valibot-json-schema * fix(stage): update provider options
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
"@electron-toolkit/preload": "^3.0.1",
|
||||
"@electron-toolkit/utils": "^3.0.0",
|
||||
"@formkit/auto-animate": "^0.8.2",
|
||||
"@gcornut/valibot-json-schema": "^0.42.0",
|
||||
"@huggingface/transformers": "^3.3.3",
|
||||
"@pixi/app": "6",
|
||||
"@pixi/constants": "6",
|
||||
@@ -47,16 +46,15 @@
|
||||
"@tresjs/cientos": "^4.1.0",
|
||||
"@tresjs/core": "^4.3.3",
|
||||
"@types/yauzl": "^2.10.3",
|
||||
"@typeschema/valibot": "^0.14.0",
|
||||
"@unhead/vue": "^2.0.0-beta.2",
|
||||
"@unocss/reset": "^66.1.0-beta.3",
|
||||
"@vueuse/core": "^12.7.0",
|
||||
"@vueuse/head": "^2.0.0",
|
||||
"@vueuse/shared": "^12.7.0",
|
||||
"@xsai-ext/providers-local": "catalog:",
|
||||
"@xsai/generate-speech": "catalog:",
|
||||
"@xsai/generate-text": "catalog:",
|
||||
"@xsai/model": "catalog:",
|
||||
"@xsai/providers": "catalog:",
|
||||
"@xsai/shared-chat": "catalog:",
|
||||
"@xsai/stream-text": "catalog:",
|
||||
"@xsai/utils-chat": "catalog:",
|
||||
@@ -80,6 +78,7 @@
|
||||
"vue-demi": "^0.14.10",
|
||||
"vue-i18n": "^11.1.1",
|
||||
"vue-router": "^4.5.0",
|
||||
"xsschema": "catalog:",
|
||||
"yauzl": "^3.2.0",
|
||||
"zod": "^3.24.2"
|
||||
},
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
"dependencies": {
|
||||
"@11labs/client": "^0.0.7",
|
||||
"@formkit/auto-animate": "^0.8.2",
|
||||
"@gcornut/valibot-json-schema": "^0.42.0",
|
||||
"@huggingface/transformers": "^3.3.3",
|
||||
"@pixi/app": "6",
|
||||
"@pixi/constants": "6",
|
||||
@@ -43,17 +42,16 @@
|
||||
"@tresjs/cientos": "^4.1.0",
|
||||
"@tresjs/core": "^4.3.3",
|
||||
"@types/yauzl": "^2.10.3",
|
||||
"@typeschema/valibot": "^0.14.0",
|
||||
"@unhead/vue": "^2.0.0-beta.2",
|
||||
"@unocss/reset": "^66.1.0-beta.3",
|
||||
"@valibot/to-json-schema": "1.0.0-rc.0",
|
||||
"@vueuse/core": "^12.7.0",
|
||||
"@vueuse/head": "^2.0.0",
|
||||
"@vueuse/shared": "^12.7.0",
|
||||
"@xsai-ext/providers-local": "catalog:",
|
||||
"@xsai/generate-speech": "catalog:",
|
||||
"@xsai/generate-text": "catalog:",
|
||||
"@xsai/model": "catalog:",
|
||||
"@xsai/providers": "catalog:",
|
||||
"@xsai/shared-chat": "catalog:",
|
||||
"@xsai/stream-text": "catalog:",
|
||||
"@xsai/utils-chat": "catalog:",
|
||||
@@ -81,6 +79,7 @@
|
||||
"vue-demi": "^0.14.10",
|
||||
"vue-i18n": "^11.1.1",
|
||||
"vue-router": "^4.5.0",
|
||||
"xsschema": "catalog:",
|
||||
"yauzl": "^3.2.0",
|
||||
"zod": "^3.24.2"
|
||||
},
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import type { Infer, Schema } from '@typeschema/valibot'
|
||||
import type { ProviderOptions } from '@xsai/providers'
|
||||
import type { CommonRequestOptions } from '@xsai/shared'
|
||||
import type { Message } from '@xsai/shared-chat'
|
||||
import type { Infer, Schema } from 'xsschema'
|
||||
|
||||
import { toJSONSchema, validate } from '@typeschema/valibot'
|
||||
import { generateText } from '@xsai/generate-text'
|
||||
import { message } from '@xsai/utils-chat'
|
||||
import { toJSONSchema, validate } from 'xsschema'
|
||||
|
||||
type SchemaOrString<S extends Schema | undefined | unknown> = S extends unknown ? string : S extends Schema ? Infer<S> : never
|
||||
|
||||
async function parseJSONFormat<S extends Schema, R extends SchemaOrString<S>>(content: string, options: { messages: Message[], apiKey?: string, baseURL: string, model: string } & ProviderOptions, schema?: S, erroredValue?: string, errorMessage?: string): Promise<R> {
|
||||
async function parseJSONFormat<S extends Schema, R extends SchemaOrString<S>>(content: string, options: { messages: Message[], apiKey?: string, baseURL: string, model: string } & Partial<CommonRequestOptions>, schema?: S, erroredValue?: string, errorMessage?: string): Promise<R> {
|
||||
if (!schema)
|
||||
return content as unknown as R
|
||||
|
||||
@@ -39,24 +39,8 @@ ${JSON.stringify(await toJSONSchema(schema))}`))
|
||||
return parseJSONFormat(response, options, schema, content, String(parseError))
|
||||
}
|
||||
|
||||
const validation = await validate(schema, parsedContent)
|
||||
if (validation.success) {
|
||||
return parsedContent as R
|
||||
}
|
||||
|
||||
console.error('Schema validation failed:', validation.issues, parsedContent)
|
||||
options.messages.push(message.user(`
|
||||
${correctionPrompt}The response failed schema validation:
|
||||
${JSON.stringify(parsedContent)}
|
||||
|
||||
Validation errors:
|
||||
${validation.issues.map(issue => `- ${issue.message}`).join('\n')}
|
||||
|
||||
Please provide a corrected response that matches the schema:
|
||||
${JSON.stringify(await toJSONSchema(schema))}`))
|
||||
|
||||
const response = await call(options, schema)
|
||||
return parseJSONFormat(response, options, schema, JSON.stringify(parsedContent), validation.issues.map(i => i.message).join(', '))
|
||||
// TODO: print validation issues
|
||||
return await validate(schema, parsedContent) as R
|
||||
}
|
||||
catch (error) {
|
||||
console.error('Error processing response:', error)
|
||||
@@ -67,7 +51,7 @@ ${JSON.stringify(await toJSONSchema(schema))}`))
|
||||
/**
|
||||
* Processes user input and generates LLM response along with thought nodes.
|
||||
*/
|
||||
async function call<S extends Schema, R extends SchemaOrString<S>>(options: { messages: Message[], apiKey?: string, baseURL: string, model: string } & ProviderOptions, schema?: S): Promise<R> {
|
||||
async function call<S extends Schema, R extends SchemaOrString<S>>(options: { messages: Message[], apiKey?: string, baseURL: string, model: string } & Partial<CommonRequestOptions>, schema?: S): Promise<R> {
|
||||
if (schema != null) {
|
||||
options.messages.push(message.user(`Your response must follow the following schema:
|
||||
${JSON.stringify(await toJSONSchema(schema))}
|
||||
@@ -85,6 +69,6 @@ Without any extra markups such as \`\`\` in markdown, or descriptions.`))
|
||||
return await parseJSONFormat<S, R>(response.text || '', options, schema)
|
||||
}
|
||||
|
||||
export async function generateObject<S extends Schema, R extends SchemaOrString<S>>(options: { messages: Message[], model: string, apiKey?: string, baseURL: string } & ProviderOptions, schema?: S): Promise<R> {
|
||||
export async function generateObject<S extends Schema, R extends SchemaOrString<S>>(options: { messages: Message[], model: string, apiKey?: string, baseURL: string } & Partial<CommonRequestOptions>, schema?: S): Promise<R> {
|
||||
return await call(options, schema)
|
||||
}
|
||||
|
||||
+1
-2
@@ -50,7 +50,6 @@ words:
|
||||
- elevenlabs
|
||||
- Factorio
|
||||
- formkit
|
||||
- gcornut
|
||||
- giteeai
|
||||
- gltf
|
||||
- gpuu
|
||||
@@ -138,7 +137,6 @@ words:
|
||||
- taze
|
||||
- tolist
|
||||
- tresjs
|
||||
- typeschema
|
||||
- unhead
|
||||
- unocss
|
||||
- unplugin
|
||||
@@ -153,6 +151,7 @@ words:
|
||||
- worklet
|
||||
- Xenova
|
||||
- xsai
|
||||
- xsschema
|
||||
- zhipu
|
||||
ignoreWords: []
|
||||
import: []
|
||||
|
||||
@@ -4,11 +4,11 @@ import type { DuckDBWasmDrizzleDatabase } from '@proj-airi/drizzle-duckdb-wasm'
|
||||
import type { Emotion } from '../../constants/emotions'
|
||||
|
||||
import { drizzle } from '@proj-airi/drizzle-duckdb-wasm'
|
||||
import { createUnElevenLabs } from '@xsai-ext/providers-local'
|
||||
// import { createTransformers } from '@proj-airi/provider-transformers'
|
||||
// import embedWorkerURL from '@proj-airi/provider-transformers/worker?worker&url'
|
||||
// import { embed } from '@xsai/embed'
|
||||
import { generateSpeech } from '@xsai/generate-speech'
|
||||
import { createUnElevenLabs } from '@xsai/providers'
|
||||
import { sql } from 'drizzle-orm'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { onMounted, onUnmounted, ref } from 'vue'
|
||||
@@ -82,10 +82,7 @@ const ttsQueue = useQueue<string>({
|
||||
|
||||
const now = Date.now()
|
||||
|
||||
const elevenlabs = createUnElevenLabs({
|
||||
apiKey: elevenLabsApiKey.value,
|
||||
baseURL: 'https://unspeech.hyp3r.link/v1/',
|
||||
})
|
||||
const elevenlabs = createUnElevenLabs(elevenLabsApiKey.value, 'https://unspeech.hyp3r.link/v1/')
|
||||
const res = await generateSpeech({
|
||||
...elevenlabs.speech('eleven_multilingual_v2', {
|
||||
voiceSettings: {
|
||||
|
||||
Generated
+47
-104
@@ -6,6 +6,12 @@ settings:
|
||||
|
||||
catalogs:
|
||||
default:
|
||||
'@xsai-ext/providers-cloud':
|
||||
specifier: ^0.1.2
|
||||
version: 0.1.2
|
||||
'@xsai-ext/providers-local':
|
||||
specifier: ^0.1.2
|
||||
version: 0.1.2
|
||||
'@xsai-ext/shared-providers':
|
||||
specifier: ^0.1.2
|
||||
version: 0.1.2
|
||||
@@ -24,9 +30,6 @@ catalogs:
|
||||
'@xsai/model':
|
||||
specifier: ^0.1.2
|
||||
version: 0.1.2
|
||||
'@xsai/providers':
|
||||
specifier: ^0.1.0-beta.5
|
||||
version: 0.1.0-beta.5
|
||||
'@xsai/shared':
|
||||
specifier: ^0.1.2
|
||||
version: 0.1.2
|
||||
@@ -42,6 +45,9 @@ catalogs:
|
||||
'@xsai/utils-chat':
|
||||
specifier: ^0.1.2
|
||||
version: 0.1.2
|
||||
xsschema:
|
||||
specifier: ^0.1.2
|
||||
version: 0.1.2
|
||||
|
||||
importers:
|
||||
|
||||
@@ -177,9 +183,6 @@ importers:
|
||||
'@formkit/auto-animate':
|
||||
specifier: ^0.8.2
|
||||
version: 0.8.2
|
||||
'@gcornut/valibot-json-schema':
|
||||
specifier: ^0.42.0
|
||||
version: 0.42.0(esbuild@0.25.0)(typescript@5.8.2)
|
||||
'@huggingface/transformers':
|
||||
specifier: ^3.3.3
|
||||
version: 3.3.3
|
||||
@@ -246,9 +249,6 @@ importers:
|
||||
'@types/yauzl':
|
||||
specifier: ^2.10.3
|
||||
version: 2.10.3
|
||||
'@typeschema/valibot':
|
||||
specifier: ^0.14.0
|
||||
version: 0.14.0(@gcornut/valibot-json-schema@0.42.0(esbuild@0.25.0)(typescript@5.8.2))(@types/json-schema@7.0.15)(valibot@1.0.0-beta.9(typescript@5.8.2))
|
||||
'@unhead/vue':
|
||||
specifier: ^2.0.0-beta.2
|
||||
version: 2.0.0-beta.2(vue@3.5.13(typescript@5.8.2))
|
||||
@@ -264,6 +264,9 @@ importers:
|
||||
'@vueuse/shared':
|
||||
specifier: ^12.7.0
|
||||
version: 12.7.0(typescript@5.8.2)
|
||||
'@xsai-ext/providers-local':
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.2
|
||||
'@xsai/generate-speech':
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.2
|
||||
@@ -273,9 +276,6 @@ importers:
|
||||
'@xsai/model':
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.2
|
||||
'@xsai/providers':
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.0-beta.5
|
||||
'@xsai/shared-chat':
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.2
|
||||
@@ -345,6 +345,9 @@ importers:
|
||||
vue-router:
|
||||
specifier: ^4.5.0
|
||||
version: 4.5.0(vue@3.5.13(typescript@5.8.2))
|
||||
xsschema:
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.2(@valibot/to-json-schema@1.0.0-rc.0(valibot@1.0.0-beta.9(typescript@5.8.2)))(zod-to-json-schema@3.24.3(zod@3.24.2))
|
||||
yauzl:
|
||||
specifier: ^3.2.0
|
||||
version: 3.2.0
|
||||
@@ -463,9 +466,6 @@ importers:
|
||||
'@formkit/auto-animate':
|
||||
specifier: ^0.8.2
|
||||
version: 0.8.2
|
||||
'@gcornut/valibot-json-schema':
|
||||
specifier: ^0.42.0
|
||||
version: 0.42.0(esbuild@0.19.12)(typescript@5.8.2)
|
||||
'@huggingface/transformers':
|
||||
specifier: ^3.3.3
|
||||
version: 3.3.3
|
||||
@@ -535,9 +535,6 @@ importers:
|
||||
'@types/yauzl':
|
||||
specifier: ^2.10.3
|
||||
version: 2.10.3
|
||||
'@typeschema/valibot':
|
||||
specifier: ^0.14.0
|
||||
version: 0.14.0(@gcornut/valibot-json-schema@0.42.0(esbuild@0.19.12)(typescript@5.8.2))(@types/json-schema@7.0.15)(valibot@1.0.0-beta.9(typescript@5.8.2))
|
||||
'@unhead/vue':
|
||||
specifier: ^2.0.0-beta.2
|
||||
version: 2.0.0-beta.2(vue@3.5.13(typescript@5.8.2))
|
||||
@@ -556,6 +553,9 @@ importers:
|
||||
'@vueuse/shared':
|
||||
specifier: ^12.7.0
|
||||
version: 12.7.0(typescript@5.8.2)
|
||||
'@xsai-ext/providers-local':
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.2
|
||||
'@xsai/generate-speech':
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.2
|
||||
@@ -565,9 +565,6 @@ importers:
|
||||
'@xsai/model':
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.2
|
||||
'@xsai/providers':
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.0-beta.5
|
||||
'@xsai/shared-chat':
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.2
|
||||
@@ -649,6 +646,9 @@ importers:
|
||||
vue-router:
|
||||
specifier: ^4.5.0
|
||||
version: 4.5.0(vue@3.5.13(typescript@5.8.2))
|
||||
xsschema:
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.2(@valibot/to-json-schema@1.0.0-rc.0(valibot@1.0.0-beta.9(typescript@5.8.2)))(zod-to-json-schema@3.24.3(zod@3.24.2))
|
||||
yauzl:
|
||||
specifier: ^3.2.0
|
||||
version: 3.2.0
|
||||
@@ -1164,6 +1164,9 @@ importers:
|
||||
'@proj-airi/server-shared':
|
||||
specifier: workspace:^
|
||||
version: link:../../packages/server-shared
|
||||
'@xsai-ext/providers-cloud':
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.2
|
||||
'@xsai/generate-speech':
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.2
|
||||
@@ -1173,9 +1176,6 @@ importers:
|
||||
'@xsai/generate-transcription':
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.2
|
||||
'@xsai/providers':
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.0-beta.5
|
||||
'@xsai/shared-chat':
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.2
|
||||
@@ -1203,9 +1203,6 @@ importers:
|
||||
'@proj-airi/server-sdk':
|
||||
specifier: ^0.3.6
|
||||
version: 0.3.6
|
||||
'@typeschema/zod':
|
||||
specifier: ^0.14.0
|
||||
version: 0.14.0(@types/json-schema@7.0.15)(zod-to-json-schema@3.24.3(zod@3.24.2))(zod@3.24.2)
|
||||
awilix:
|
||||
specifier: ^12.0.4
|
||||
version: 12.0.4
|
||||
@@ -1285,24 +1282,18 @@ importers:
|
||||
'@dotenvx/dotenvx':
|
||||
specifier: ^1.38.3
|
||||
version: 1.38.3
|
||||
'@gcornut/valibot-json-schema':
|
||||
specifier: ^0.42.0
|
||||
version: 0.42.0(esbuild@0.25.0)(typescript@5.8.2)
|
||||
'@grammyjs/files':
|
||||
specifier: ^1.1.1
|
||||
version: 1.1.1(grammy@1.35.0(encoding@0.1.13))
|
||||
'@guiiai/logg':
|
||||
specifier: ^1.0.7
|
||||
version: 1.0.7
|
||||
'@typeschema/valibot':
|
||||
specifier: ^0.14.0
|
||||
version: 0.14.0(@gcornut/valibot-json-schema@0.42.0(esbuild@0.25.0)(typescript@5.8.2))(@types/json-schema@7.0.15)(valibot@1.0.0-beta.9(typescript@5.8.2))
|
||||
'@xsai-ext/providers-cloud':
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.2
|
||||
'@xsai/generate-text':
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.2
|
||||
'@xsai/providers':
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.0-beta.5
|
||||
'@xsai/shared-chat':
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.2
|
||||
@@ -3032,10 +3023,6 @@ packages:
|
||||
'@formkit/auto-animate@0.8.2':
|
||||
resolution: {integrity: sha512-SwPWfeRa5veb1hOIBMdzI+73te5puUBHmqqaF1Bu7FjvxlYSz/kJcZKSa9Cg60zL0uRNeJL2SbRxV6Jp6Q1nFQ==}
|
||||
|
||||
'@gcornut/valibot-json-schema@0.42.0':
|
||||
resolution: {integrity: sha512-4Et4AN6wmqeA0PfU5Clkv/IS27wiefsWf6TemAZrb75uzkClYEFavim7SboeKwbll9Nbsn2Iv0LT/HS5H7orZg==}
|
||||
hasBin: true
|
||||
|
||||
'@grammyjs/files@1.1.1':
|
||||
resolution: {integrity: sha512-T3vJCVlj76I8d4BUI0MPDyIkfWOkG4NXyy8HDKAmG5tIb1SxMtrQHcwRYCOHeSJ1EvLWtfadFNTbRXuym+8c6Q==}
|
||||
engines: {node: ^12.20.0 || >=14.13.1}
|
||||
@@ -5293,6 +5280,12 @@ packages:
|
||||
resolution: {integrity: sha512-2WALfTl4xo2SkGCYRt6rDTFfk9R1czmBvUQy12gK2KuRKIpWEhcbbzy8EZXtz/jkRqHX8bFEc6FC1HjX4TUWYw==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
|
||||
'@xsai-ext/providers-cloud@0.1.2':
|
||||
resolution: {integrity: sha512-8NoheGXX3QhUeqKCv/urTHIdJRwwaAhCDWFWWjcmqT6M70wDcoqmXPZoyscCiLLTCazpWHMAz5X0tUGT2pdURQ==}
|
||||
|
||||
'@xsai-ext/providers-local@0.1.2':
|
||||
resolution: {integrity: sha512-p2VvuYVqGHwNIdinjrsvVHADXWiQWbKkZVIn0zBP6G7n1r4mlO6XaiANqV4ReHz9DEMnNoajb5Xal/NjKEHMGw==}
|
||||
|
||||
'@xsai-ext/shared-providers@0.1.2':
|
||||
resolution: {integrity: sha512-8EPnYzJuK0AKQl/gp33R9BpULvjxeicdQl0sAT128F7as0de4yIYEPY/q8BZNY/NgY5XCv0qw023ijODXCnvxw==}
|
||||
|
||||
@@ -6890,12 +6883,6 @@ packages:
|
||||
peerDependencies:
|
||||
esbuild: '>=0.12 <1'
|
||||
|
||||
esbuild-runner@2.2.2:
|
||||
resolution: {integrity: sha512-fRFVXcmYVmSmtYm2mL8RlUASt2TDkGh3uRcvHFOKNr/T58VrfVeKD9uT9nlgxk96u0LS0ehS/GY7Da/bXWKkhw==}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
esbuild: '*'
|
||||
|
||||
esbuild@0.18.20:
|
||||
resolution: {integrity: sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -11406,14 +11393,6 @@ packages:
|
||||
resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==}
|
||||
hasBin: true
|
||||
|
||||
valibot@0.42.1:
|
||||
resolution: {integrity: sha512-3keXV29Ar5b//Hqi4MbSdV7lfVp6zuYLZuA9V1PvQUsXqogr+u5lvLPLk3A4f74VUXDnf/JfWMN6sB+koJ/FFw==}
|
||||
peerDependencies:
|
||||
typescript: '>=5'
|
||||
peerDependenciesMeta:
|
||||
typescript:
|
||||
optional: true
|
||||
|
||||
valibot@1.0.0-beta.9:
|
||||
resolution: {integrity: sha512-yEX8gMAZ2R1yI2uwOO4NCtVnJQx36zn3vD0omzzj9FhcoblvPukENIiRZXKZwCnqSeV80bMm8wNiGhQ0S8fiww==}
|
||||
peerDependencies:
|
||||
@@ -13673,26 +13652,6 @@ snapshots:
|
||||
|
||||
'@formkit/auto-animate@0.8.2': {}
|
||||
|
||||
'@gcornut/valibot-json-schema@0.42.0(esbuild@0.19.12)(typescript@5.8.2)':
|
||||
dependencies:
|
||||
valibot: 0.42.1(typescript@5.8.2)
|
||||
optionalDependencies:
|
||||
'@types/json-schema': 7.0.15
|
||||
esbuild-runner: 2.2.2(esbuild@0.19.12)
|
||||
transitivePeerDependencies:
|
||||
- esbuild
|
||||
- typescript
|
||||
|
||||
'@gcornut/valibot-json-schema@0.42.0(esbuild@0.25.0)(typescript@5.8.2)':
|
||||
dependencies:
|
||||
valibot: 0.42.1(typescript@5.8.2)
|
||||
optionalDependencies:
|
||||
'@types/json-schema': 7.0.15
|
||||
esbuild-runner: 2.2.2(esbuild@0.25.0)
|
||||
transitivePeerDependencies:
|
||||
- esbuild
|
||||
- typescript
|
||||
|
||||
'@grammyjs/files@1.1.1(grammy@1.35.0(encoding@0.1.13))':
|
||||
dependencies:
|
||||
grammy: 1.35.0(encoding@0.1.13)
|
||||
@@ -15447,28 +15406,19 @@ snapshots:
|
||||
dependencies:
|
||||
'@typeschema/core': 0.14.0(@types/json-schema@7.0.15)
|
||||
optionalDependencies:
|
||||
'@typeschema/valibot': 0.14.0(@gcornut/valibot-json-schema@0.42.0(esbuild@0.25.0)(typescript@5.8.2))(@types/json-schema@7.0.15)(valibot@1.0.0-beta.9(typescript@5.8.2))
|
||||
'@typeschema/valibot': 0.14.0(@types/json-schema@7.0.15)(valibot@1.0.0-beta.9(typescript@5.8.2))
|
||||
'@typeschema/zod': 0.14.0(@types/json-schema@7.0.15)(zod-to-json-schema@3.24.3(zod@3.24.2))(zod@3.24.2)
|
||||
transitivePeerDependencies:
|
||||
- '@types/json-schema'
|
||||
|
||||
'@typeschema/valibot@0.14.0(@gcornut/valibot-json-schema@0.42.0(esbuild@0.19.12)(typescript@5.8.2))(@types/json-schema@7.0.15)(valibot@1.0.0-beta.9(typescript@5.8.2))':
|
||||
'@typeschema/valibot@0.14.0(@types/json-schema@7.0.15)(valibot@1.0.0-beta.9(typescript@5.8.2))':
|
||||
dependencies:
|
||||
'@typeschema/core': 0.14.0(@types/json-schema@7.0.15)
|
||||
optionalDependencies:
|
||||
'@gcornut/valibot-json-schema': 0.42.0(esbuild@0.19.12)(typescript@5.8.2)
|
||||
valibot: 1.0.0-beta.9(typescript@5.8.2)
|
||||
transitivePeerDependencies:
|
||||
- '@types/json-schema'
|
||||
|
||||
'@typeschema/valibot@0.14.0(@gcornut/valibot-json-schema@0.42.0(esbuild@0.25.0)(typescript@5.8.2))(@types/json-schema@7.0.15)(valibot@1.0.0-beta.9(typescript@5.8.2))':
|
||||
dependencies:
|
||||
'@typeschema/core': 0.14.0(@types/json-schema@7.0.15)
|
||||
optionalDependencies:
|
||||
'@gcornut/valibot-json-schema': 0.42.0(esbuild@0.25.0)(typescript@5.8.2)
|
||||
valibot: 1.0.0-beta.9(typescript@5.8.2)
|
||||
transitivePeerDependencies:
|
||||
- '@types/json-schema'
|
||||
optional: true
|
||||
|
||||
'@typeschema/zod@0.14.0(@types/json-schema@7.0.15)(zod-to-json-schema@3.24.3(zod@3.24.2))(zod@3.24.2)':
|
||||
dependencies:
|
||||
@@ -15478,6 +15428,7 @@ snapshots:
|
||||
zod-to-json-schema: 3.24.3(zod@3.24.2)
|
||||
transitivePeerDependencies:
|
||||
- '@types/json-schema'
|
||||
optional: true
|
||||
|
||||
'@typescript-eslint/eslint-plugin@8.24.1(@typescript-eslint/parser@8.24.1(eslint@9.21.0(jiti@2.4.2))(typescript@5.8.2))(eslint@9.21.0(jiti@2.4.2))(typescript@5.8.2)':
|
||||
dependencies:
|
||||
@@ -16375,6 +16326,16 @@ snapshots:
|
||||
|
||||
'@xmldom/xmldom@0.8.10': {}
|
||||
|
||||
'@xsai-ext/providers-cloud@0.1.2':
|
||||
dependencies:
|
||||
'@xsai-ext/shared-providers': 0.1.2
|
||||
'@xsai/shared': 0.1.2
|
||||
|
||||
'@xsai-ext/providers-local@0.1.2':
|
||||
dependencies:
|
||||
'@xsai-ext/shared-providers': 0.1.2
|
||||
'@xsai/shared': 0.1.2
|
||||
|
||||
'@xsai-ext/shared-providers@0.1.2':
|
||||
dependencies:
|
||||
'@xsai/shared': 0.1.2
|
||||
@@ -18327,20 +18288,6 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
esbuild-runner@2.2.2(esbuild@0.19.12):
|
||||
dependencies:
|
||||
esbuild: 0.19.12
|
||||
source-map-support: 0.5.21
|
||||
tslib: 2.4.0
|
||||
optional: true
|
||||
|
||||
esbuild-runner@2.2.2(esbuild@0.25.0):
|
||||
dependencies:
|
||||
esbuild: 0.25.0
|
||||
source-map-support: 0.5.21
|
||||
tslib: 2.4.0
|
||||
optional: true
|
||||
|
||||
esbuild@0.18.20:
|
||||
optionalDependencies:
|
||||
'@esbuild/android-arm': 0.18.20
|
||||
@@ -24402,10 +24349,6 @@ snapshots:
|
||||
|
||||
uuid@8.3.2: {}
|
||||
|
||||
valibot@0.42.1(typescript@5.8.2):
|
||||
optionalDependencies:
|
||||
typescript: 5.8.2
|
||||
|
||||
valibot@1.0.0-beta.9(typescript@5.8.2):
|
||||
optionalDependencies:
|
||||
typescript: 5.8.2
|
||||
|
||||
+3
-2
@@ -17,6 +17,7 @@ catalog:
|
||||
'@xsai/tool': *xsai
|
||||
'@xsai/utils-chat': *xsai
|
||||
'@xsai/embed': *xsai
|
||||
'@xsai-ext/providers-cloud': *xsai
|
||||
'@xsai-ext/providers-local': *xsai
|
||||
'@xsai-ext/shared-providers': *xsai
|
||||
# TODO: remove deprecated package
|
||||
'@xsai/providers': ^0.1.0-beta.5
|
||||
xsschema: *xsai
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
"@huggingface/transformers": "^3.3.3",
|
||||
"@proj-airi/server-sdk": "workspace:^",
|
||||
"@proj-airi/server-shared": "workspace:^",
|
||||
"@xsai-ext/providers-cloud": "catalog:",
|
||||
"@xsai/generate-speech": "catalog:",
|
||||
"@xsai/generate-text": "catalog:",
|
||||
"@xsai/generate-transcription": "catalog:",
|
||||
"@xsai/providers": "catalog:",
|
||||
"@xsai/shared-chat": "catalog:",
|
||||
"discord.js": "^14.18.0",
|
||||
"libsodium-wrappers": "^0.7.15",
|
||||
|
||||
@@ -4,8 +4,8 @@ import type { Buffer } from 'node:buffer'
|
||||
import { env } from 'node:process'
|
||||
import { useLogg } from '@guiiai/logg'
|
||||
import { pipeline } from '@huggingface/transformers'
|
||||
import { createOpenAI } from '@xsai-ext/providers-cloud'
|
||||
import { generateTranscription } from '@xsai/generate-transcription'
|
||||
import { createOpenAI } from '@xsai/providers'
|
||||
import wavefile from 'wavefile'
|
||||
|
||||
import { pcmToWav } from '../utils/audio'
|
||||
@@ -74,10 +74,7 @@ export async function openaiTranscribe(wavBuffer: Buffer) {
|
||||
log.log('Transcribing audio...')
|
||||
|
||||
const wavFile = new Blob([wavBuffer], { type: 'audio/wav' })
|
||||
const openai = createOpenAI({
|
||||
baseURL: env.OPENAI_STT_API_BASE_URL,
|
||||
apiKey: env.OPENAI_STT_API_KEY,
|
||||
})
|
||||
const openai = createOpenAI(env.OPENAI_STT_API_KEY, env.OPENAI_STT_API_BASE_URL)
|
||||
|
||||
try {
|
||||
const result = await generateTranscription({
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
"dependencies": {
|
||||
"@guiiai/logg": "^1.0.7",
|
||||
"@proj-airi/server-sdk": "^0.3.6",
|
||||
"@typeschema/zod": "^0.14.0",
|
||||
"awilix": "^12.0.4",
|
||||
"es-toolkit": "^1.32.0",
|
||||
"eventemitter3": "^5.0.1",
|
||||
|
||||
@@ -21,12 +21,10 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@dotenvx/dotenvx": "^1.38.3",
|
||||
"@gcornut/valibot-json-schema": "^0.42.0",
|
||||
"@grammyjs/files": "^1.1.1",
|
||||
"@guiiai/logg": "^1.0.7",
|
||||
"@typeschema/valibot": "^0.14.0",
|
||||
"@xsai-ext/providers-cloud": "catalog:",
|
||||
"@xsai/generate-text": "catalog:",
|
||||
"@xsai/providers": "catalog:",
|
||||
"@xsai/shared-chat": "catalog:",
|
||||
"@xsai/tool": "catalog:",
|
||||
"dotenv": "^16.4.7",
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import { env } from 'node:process'
|
||||
import { createOpenAI } from '@xsai/providers'
|
||||
import { createOpenAI } from '@xsai-ext/providers-cloud'
|
||||
|
||||
export const openAI = createOpenAI({
|
||||
baseURL: env.OPENAI_API_BASE_URL!,
|
||||
apiKey: env.OPENAI_API_KEY!,
|
||||
})
|
||||
export const openAI = createOpenAI(env.OPENAI_API_KEY!, env.OPENAI_API_BASE_URL!)
|
||||
|
||||
Reference in New Issue
Block a user