@things-factory/ai-assistant 10.1.263 → 10.1.265
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/client/components/assistant-chat.ts +3 -3
- package/client/index.ts +1 -1
- package/client/utils/pdf-pages.ts +2 -15
- package/dist-client/components/assistant-chat.js +3 -3
- package/dist-client/components/assistant-chat.js.map +1 -1
- package/dist-client/index.d.ts +1 -1
- package/dist-client/index.js +1 -1
- package/dist-client/index.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/utils/pdf-pages.d.ts +0 -2
- package/dist-client/utils/pdf-pages.js +2 -14
- package/dist-client/utils/pdf-pages.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
|
@@ -41,12 +41,13 @@ import {
|
|
|
41
41
|
} from './markdown.js'
|
|
42
42
|
import { acceptOf, chatAttachmentUrl, limitsOf, refuseAttachments, textCharsOf } from '../utils/attachment-policy.js'
|
|
43
43
|
import { fileUploadLimits } from '@operato/utils/file-acceptance.js'
|
|
44
|
+
import { openPdf } from '@operato/utils/pdf-loader.js'
|
|
44
45
|
import '@operato/input/ox-input-file.js'
|
|
45
46
|
import { pastedTableFile } from '../utils/pasted-table.js'
|
|
46
47
|
import { appendWords, composerHeight, composerKeyAction, composerSuggestion, sendShortcut, tableAsWords } from '../utils/composer-frame.js'
|
|
47
48
|
import { readSpreadsheet, spreadsheetKindOf, type SpreadsheetRefusal } from '../utils/spreadsheet-text.js'
|
|
48
49
|
import { documentKindOf, readDocx, readPdf, readPptx, type DocumentRefusal } from '../utils/document-text.js'
|
|
49
|
-
import { drawPdfPage
|
|
50
|
+
import { drawPdfPage } from '../utils/pdf-pages.js'
|
|
50
51
|
import { entryReviewAddress, offersWorkspaceReview } from '../utils/entry-workspace.js'
|
|
51
52
|
import { buildAssistantChatInput, buildChatMutationInput } from './chat-input-builder.js'
|
|
52
53
|
import { agentDetail, offersAgentPicker, pickAgentId, rememberAgent, rememberedAgent, type AgentChoice } from '../utils/agent-choice.js'
|
|
@@ -791,10 +792,9 @@ export class OxAssistantChat extends LitElement {
|
|
|
791
792
|
const data = await file.arrayBuffer()
|
|
792
793
|
let read
|
|
793
794
|
if (kind === 'pdf') {
|
|
794
|
-
const pdfjs = await loadPdfjs()
|
|
795
795
|
let pdf: any
|
|
796
796
|
read = await readPdf(
|
|
797
|
-
async () => (pdf = await
|
|
797
|
+
async () => (pdf = await (await openPdf(data)).promise),
|
|
798
798
|
file.name,
|
|
799
799
|
maxChars,
|
|
800
800
|
/* The text travels as one file; the scans may take the rest of what one message carries. */
|
package/client/index.ts
CHANGED
|
@@ -32,5 +32,5 @@ export * from './utils/assistant-capability.js'
|
|
|
32
32
|
export * from './utils/assistant-capability-read.js'
|
|
33
33
|
|
|
34
34
|
/* Shared document readers for material-driven editors. */
|
|
35
|
-
export {
|
|
35
|
+
export { drawPdfPage } from './utils/pdf-pages.js'
|
|
36
36
|
export { pdfPageText, isScannedPage } from './utils/document-text.js'
|
|
@@ -1,20 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* A PDF page drawn into an image - for a scanned page, whose text has to be read from its picture. The PDF is opened
|
|
3
|
+
* through @operato/utils pdf-loader (document-text.ts reads the pages' text).
|
|
4
4
|
*/
|
|
5
|
-
let loading: Promise<any> | undefined
|
|
6
|
-
|
|
7
|
-
/** pdf.js with its worker - the worker parses the file off the page's thread. */
|
|
8
|
-
export function loadPdfjs(): Promise<any> {
|
|
9
|
-
loading ??= (async () => {
|
|
10
|
-
const pdfjs: any = await import('pdfjs-dist')
|
|
11
|
-
if (!pdfjs.GlobalWorkerOptions.workerPort) {
|
|
12
|
-
pdfjs.GlobalWorkerOptions.workerPort = new Worker(new URL('pdfjs-dist/build/pdf.worker.min.mjs', import.meta.url), { type: 'module' })
|
|
13
|
-
}
|
|
14
|
-
return pdfjs
|
|
15
|
-
})()
|
|
16
|
-
return loading
|
|
17
|
-
}
|
|
18
5
|
|
|
19
6
|
/** The longest side of a drawn page, in pixels - enough for a model to read print, small enough to send. */
|
|
20
7
|
export const PAGE_IMAGE_SIDE = 1600
|
|
@@ -36,12 +36,13 @@ import gql from 'graphql-tag';
|
|
|
36
36
|
import { renderMarkdown, injectMentionRefids, injectMentionUserIds, stripMentionRefids } from './markdown.js';
|
|
37
37
|
import { acceptOf, chatAttachmentUrl, limitsOf, refuseAttachments, textCharsOf } from '../utils/attachment-policy.js';
|
|
38
38
|
import { fileUploadLimits } from '@operato/utils/file-acceptance.js';
|
|
39
|
+
import { openPdf } from '@operato/utils/pdf-loader.js';
|
|
39
40
|
import '@operato/input/ox-input-file.js';
|
|
40
41
|
import { pastedTableFile } from '../utils/pasted-table.js';
|
|
41
42
|
import { appendWords, composerHeight, composerKeyAction, composerSuggestion, sendShortcut, tableAsWords } from '../utils/composer-frame.js';
|
|
42
43
|
import { readSpreadsheet, spreadsheetKindOf } from '../utils/spreadsheet-text.js';
|
|
43
44
|
import { documentKindOf, readDocx, readPdf, readPptx } from '../utils/document-text.js';
|
|
44
|
-
import { drawPdfPage
|
|
45
|
+
import { drawPdfPage } from '../utils/pdf-pages.js';
|
|
45
46
|
import { entryReviewAddress, offersWorkspaceReview } from '../utils/entry-workspace.js';
|
|
46
47
|
import { buildAssistantChatInput, buildChatMutationInput } from './chat-input-builder.js';
|
|
47
48
|
import { agentDetail, offersAgentPicker, pickAgentId, rememberAgent, rememberedAgent } from '../utils/agent-choice.js';
|
|
@@ -598,9 +599,8 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
|
|
|
598
599
|
const data = await file.arrayBuffer();
|
|
599
600
|
let read;
|
|
600
601
|
if (kind === 'pdf') {
|
|
601
|
-
const pdfjs = await loadPdfjs();
|
|
602
602
|
let pdf;
|
|
603
|
-
read = await readPdf(async () => (pdf = await
|
|
603
|
+
read = await readPdf(async () => (pdf = await (await openPdf(data)).promise), file.name, maxChars,
|
|
604
604
|
/* The text travels as one file; the scans may take the rest of what one message carries. */
|
|
605
605
|
{ allowed: !!policy?.kinds?.includes('image'), max: Math.max(0, limitsOf(policy).maxFiles - 1) }, number => drawPdfPage(pdf, number));
|
|
606
606
|
}
|