mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2026-02-03 21:40:53 +00:00
nhj
more
This commit is contained in:
21
unified-ai-platform/node_modules/fetch-blob/LICENSE
generated
vendored
Normal file
21
unified-ai-platform/node_modules/fetch-blob/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 David Frank
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
49
unified-ai-platform/node_modules/fetch-blob/file.js
generated
vendored
Normal file
49
unified-ai-platform/node_modules/fetch-blob/file.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
import Blob from './index.js'
|
||||
|
||||
const _File = class File extends Blob {
|
||||
#lastModified = 0
|
||||
#name = ''
|
||||
|
||||
/**
|
||||
* @param {*[]} fileBits
|
||||
* @param {string} fileName
|
||||
* @param {{lastModified?: number, type?: string}} options
|
||||
*/// @ts-ignore
|
||||
constructor (fileBits, fileName, options = {}) {
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`)
|
||||
}
|
||||
super(fileBits, options)
|
||||
|
||||
if (options === null) options = {}
|
||||
|
||||
// Simulate WebIDL type casting for NaN value in lastModified option.
|
||||
const lastModified = options.lastModified === undefined ? Date.now() : Number(options.lastModified)
|
||||
if (!Number.isNaN(lastModified)) {
|
||||
this.#lastModified = lastModified
|
||||
}
|
||||
|
||||
this.#name = String(fileName)
|
||||
}
|
||||
|
||||
get name () {
|
||||
return this.#name
|
||||
}
|
||||
|
||||
get lastModified () {
|
||||
return this.#lastModified
|
||||
}
|
||||
|
||||
get [Symbol.toStringTag] () {
|
||||
return 'File'
|
||||
}
|
||||
|
||||
static [Symbol.hasInstance] (object) {
|
||||
return !!object && object instanceof Blob &&
|
||||
/^(File)$/.test(object[Symbol.toStringTag])
|
||||
}
|
||||
}
|
||||
|
||||
/** @type {typeof globalThis.File} */// @ts-ignore
|
||||
export const File = _File
|
||||
export default File
|
||||
100
unified-ai-platform/node_modules/fetch-blob/from.js
generated
vendored
Normal file
100
unified-ai-platform/node_modules/fetch-blob/from.js
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
import { statSync, createReadStream, promises as fs } from 'node:fs'
|
||||
import { basename } from 'node:path'
|
||||
import DOMException from 'node-domexception'
|
||||
|
||||
import File from './file.js'
|
||||
import Blob from './index.js'
|
||||
|
||||
const { stat } = fs
|
||||
|
||||
/**
|
||||
* @param {string} path filepath on the disk
|
||||
* @param {string} [type] mimetype to use
|
||||
*/
|
||||
const blobFromSync = (path, type) => fromBlob(statSync(path), path, type)
|
||||
|
||||
/**
|
||||
* @param {string} path filepath on the disk
|
||||
* @param {string} [type] mimetype to use
|
||||
* @returns {Promise<Blob>}
|
||||
*/
|
||||
const blobFrom = (path, type) => stat(path).then(stat => fromBlob(stat, path, type))
|
||||
|
||||
/**
|
||||
* @param {string} path filepath on the disk
|
||||
* @param {string} [type] mimetype to use
|
||||
* @returns {Promise<File>}
|
||||
*/
|
||||
const fileFrom = (path, type) => stat(path).then(stat => fromFile(stat, path, type))
|
||||
|
||||
/**
|
||||
* @param {string} path filepath on the disk
|
||||
* @param {string} [type] mimetype to use
|
||||
*/
|
||||
const fileFromSync = (path, type) => fromFile(statSync(path), path, type)
|
||||
|
||||
// @ts-ignore
|
||||
const fromBlob = (stat, path, type = '') => new Blob([new BlobDataItem({
|
||||
path,
|
||||
size: stat.size,
|
||||
lastModified: stat.mtimeMs,
|
||||
start: 0
|
||||
})], { type })
|
||||
|
||||
// @ts-ignore
|
||||
const fromFile = (stat, path, type = '') => new File([new BlobDataItem({
|
||||
path,
|
||||
size: stat.size,
|
||||
lastModified: stat.mtimeMs,
|
||||
start: 0
|
||||
})], basename(path), { type, lastModified: stat.mtimeMs })
|
||||
|
||||
/**
|
||||
* This is a blob backed up by a file on the disk
|
||||
* with minium requirement. Its wrapped around a Blob as a blobPart
|
||||
* so you have no direct access to this.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
class BlobDataItem {
|
||||
#path
|
||||
#start
|
||||
|
||||
constructor (options) {
|
||||
this.#path = options.path
|
||||
this.#start = options.start
|
||||
this.size = options.size
|
||||
this.lastModified = options.lastModified
|
||||
}
|
||||
|
||||
/**
|
||||
* Slicing arguments is first validated and formatted
|
||||
* to not be out of range by Blob.prototype.slice
|
||||
*/
|
||||
slice (start, end) {
|
||||
return new BlobDataItem({
|
||||
path: this.#path,
|
||||
lastModified: this.lastModified,
|
||||
size: end - start,
|
||||
start: this.#start + start
|
||||
})
|
||||
}
|
||||
|
||||
async * stream () {
|
||||
const { mtimeMs } = await stat(this.#path)
|
||||
if (mtimeMs > this.lastModified) {
|
||||
throw new DOMException('The requested file could not be read, typically due to permission problems that have occurred after a reference to a file was acquired.', 'NotReadableError')
|
||||
}
|
||||
yield * createReadStream(this.#path, {
|
||||
start: this.#start,
|
||||
end: this.#start + this.size - 1
|
||||
})
|
||||
}
|
||||
|
||||
get [Symbol.toStringTag] () {
|
||||
return 'Blob'
|
||||
}
|
||||
}
|
||||
|
||||
export default blobFromSync
|
||||
export { File, Blob, blobFrom, blobFromSync, fileFrom, fileFromSync }
|
||||
51
unified-ai-platform/node_modules/fetch-blob/streams.cjs
generated
vendored
Normal file
51
unified-ai-platform/node_modules/fetch-blob/streams.cjs
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
/* c8 ignore start */
|
||||
// 64 KiB (same size chrome slice theirs blob into Uint8array's)
|
||||
const POOL_SIZE = 65536
|
||||
|
||||
if (!globalThis.ReadableStream) {
|
||||
// `node:stream/web` got introduced in v16.5.0 as experimental
|
||||
// and it's preferred over the polyfilled version. So we also
|
||||
// suppress the warning that gets emitted by NodeJS for using it.
|
||||
try {
|
||||
const process = require('node:process')
|
||||
const { emitWarning } = process
|
||||
try {
|
||||
process.emitWarning = () => {}
|
||||
Object.assign(globalThis, require('node:stream/web'))
|
||||
process.emitWarning = emitWarning
|
||||
} catch (error) {
|
||||
process.emitWarning = emitWarning
|
||||
throw error
|
||||
}
|
||||
} catch (error) {
|
||||
// fallback to polyfill implementation
|
||||
Object.assign(globalThis, require('web-streams-polyfill/dist/ponyfill.es2018.js'))
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// Don't use node: prefix for this, require+node: is not supported until node v14.14
|
||||
// Only `import()` can use prefix in 12.20 and later
|
||||
const { Blob } = require('buffer')
|
||||
if (Blob && !Blob.prototype.stream) {
|
||||
Blob.prototype.stream = function name (params) {
|
||||
let position = 0
|
||||
const blob = this
|
||||
|
||||
return new ReadableStream({
|
||||
type: 'bytes',
|
||||
async pull (ctrl) {
|
||||
const chunk = blob.slice(position, Math.min(blob.size, position + POOL_SIZE))
|
||||
const buffer = await chunk.arrayBuffer()
|
||||
position += buffer.byteLength
|
||||
ctrl.enqueue(new Uint8Array(buffer))
|
||||
|
||||
if (position === blob.size) {
|
||||
ctrl.close()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
} catch (error) {}
|
||||
/* c8 ignore end */
|
||||
Reference in New Issue
Block a user