UNPKG

@assistant-ui/react

Version:

Typescript/React library for AI Chat

65 lines (64 loc) 2.19 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/runtimes/adapters/attachment/SimpleTextAttachmentAdapter.ts var SimpleTextAttachmentAdapter_exports = {}; __export(SimpleTextAttachmentAdapter_exports, { SimpleTextAttachmentAdapter: () => SimpleTextAttachmentAdapter }); module.exports = __toCommonJS(SimpleTextAttachmentAdapter_exports); var SimpleTextAttachmentAdapter = class { accept = "text/plain,text/html,text/markdown,text/csv,text/xml,text/json,text/css"; async add(state) { return { id: state.file.name, type: "document", name: state.file.name, contentType: state.file.type, file: state.file, status: { type: "requires-action", reason: "composer-send" } }; } async send(attachment) { return { ...attachment, status: { type: "complete" }, content: [ { type: "text", text: `<attachment name=${attachment.name}> ${await getFileText(attachment.file)} </attachment>` } ] }; } async remove() { } }; var getFileText = (file) => new Promise((resolve, reject) => { const reader = new FileReader(); reader.onload = () => resolve(reader.result); reader.onerror = (error) => reject(error); reader.readAsText(file); }); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { SimpleTextAttachmentAdapter }); //# sourceMappingURL=SimpleTextAttachmentAdapter.js.map