Spaces:
Build error
Build error
File size: 2,751 Bytes
c211499 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
import { MultipartBody } from "./MultipartBody.mjs";
export function getRuntime({ manuallyImported } = {}) {
const recommendation = manuallyImported ?
`You may need to use polyfills`
: `Add one of these imports before your first \`import … from '@anthropic-ai/sdk'\`:
- \`import '@anthropic-ai/sdk/shims/node'\` (if you're running on Node)
- \`import '@anthropic-ai/sdk/shims/web'\` (otherwise)
`;
let _fetch, _Request, _Response, _Headers;
try {
// @ts-ignore
_fetch = fetch;
// @ts-ignore
_Request = Request;
// @ts-ignore
_Response = Response;
// @ts-ignore
_Headers = Headers;
}
catch (error) {
throw new Error(`this environment is missing the following Web Fetch API type: ${error.message}. ${recommendation}`);
}
return {
kind: 'web',
fetch: _fetch,
Request: _Request,
Response: _Response,
Headers: _Headers,
FormData:
// @ts-ignore
typeof FormData !== 'undefined' ? FormData : (class FormData {
// @ts-ignore
constructor() {
throw new Error(`file uploads aren't supported in this environment yet as 'FormData' is undefined. ${recommendation}`);
}
}),
Blob: typeof Blob !== 'undefined' ? Blob : (class Blob {
constructor() {
throw new Error(`file uploads aren't supported in this environment yet as 'Blob' is undefined. ${recommendation}`);
}
}),
File:
// @ts-ignore
typeof File !== 'undefined' ? File : (class File {
// @ts-ignore
constructor() {
throw new Error(`file uploads aren't supported in this environment yet as 'File' is undefined. ${recommendation}`);
}
}),
ReadableStream:
// @ts-ignore
typeof ReadableStream !== 'undefined' ? ReadableStream : (class ReadableStream {
// @ts-ignore
constructor() {
throw new Error(`streaming isn't supported in this environment yet as 'ReadableStream' is undefined. ${recommendation}`);
}
}),
getMultipartRequestOptions: async (
// @ts-ignore
form, opts) => ({
...opts,
body: new MultipartBody(form),
}),
getDefaultAgent: (url) => undefined,
fileFromPath: () => {
throw new Error('The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/anthropics/anthropic-sdk-typescript#file-uploads');
},
isFsReadStream: (value) => false,
};
}
//# sourceMappingURL=web-runtime.mjs.map |