@graphai/pdf2text_agent 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import templateAgent from "./template_agent";
2
- export { templateAgent };
1
+ import pdf2textAgent from "./pdf2text_agent";
2
+ export { pdf2textAgent };
package/lib/index.js CHANGED
@@ -3,6 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.templateAgent = void 0;
7
- const template_agent_1 = __importDefault(require("./template_agent"));
8
- exports.templateAgent = template_agent_1.default;
6
+ exports.pdf2textAgent = void 0;
7
+ const pdf2text_agent_1 = __importDefault(require("./pdf2text_agent"));
8
+ exports.pdf2textAgent = pdf2text_agent_1.default;
@@ -0,0 +1,10 @@
1
+ import { AgentFunction, AgentFunctionInfo } from "graphai";
2
+ export declare const pdf2textAgent: AgentFunction<{
3
+ type: string;
4
+ }, {
5
+ text?: string;
6
+ }, null, {
7
+ buffer: Buffer;
8
+ }>;
9
+ declare const pdf2textAgentInfo: AgentFunctionInfo;
10
+ export default pdf2textAgentInfo;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.pdf2textAgent = void 0;
7
+ const graphai_1 = require("graphai");
8
+ const pdf2md_1 = __importDefault(require("@opendocsg/pdf2md"));
9
+ const unpdf_1 = require("unpdf");
10
+ const pdf2textAgent = async ({ params, namedInputs }) => {
11
+ const { buffer } = namedInputs;
12
+ const { type } = params;
13
+ (0, graphai_1.assert)(!!buffer, "pdf2textAgent required buffer");
14
+ if (type === "md" || type === "markdown") {
15
+ const md_text = await (0, pdf2md_1.default)(buffer);
16
+ return { text: md_text };
17
+ }
18
+ const pdf = await (0, unpdf_1.getDocumentProxy)(new Uint8Array(buffer));
19
+ const { text: pdf_text } = await (0, unpdf_1.extractText)(pdf, { mergePages: true });
20
+ return { text: pdf_text };
21
+ };
22
+ exports.pdf2textAgent = pdf2textAgent;
23
+ const pdf2textAgentInfo = {
24
+ name: "pdf2textAgent",
25
+ agent: exports.pdf2textAgent,
26
+ mock: exports.pdf2textAgent,
27
+ samples: [],
28
+ description: "Pdf2text Agent",
29
+ category: ["documents"],
30
+ author: "Receptron team",
31
+ repository: "https://github.com/receptron/graphai",
32
+ license: "MIT",
33
+ };
34
+ exports.default = pdf2textAgentInfo;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphai/pdf2text_agent",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "files": [