mirror of
https://github.com/documenso/documenso.git
synced 2025-11-16 01:32:06 +10:00
chore: prompt changes
This commit is contained in:
@ -472,17 +472,7 @@ export const EnvelopeEditorFieldsPage = () => {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{isAutoAddingFields ? (
|
{isAutoAddingFields ? <Trans>Processing...</Trans> : <Trans>Auto add fields</Trans>}
|
||||||
processingProgress ? (
|
|
||||||
<Trans>
|
|
||||||
Processing page {processingProgress.current} of {processingProgress.total}...
|
|
||||||
</Trans>
|
|
||||||
) : (
|
|
||||||
<Trans>Processing...</Trans>
|
|
||||||
)
|
|
||||||
) : (
|
|
||||||
<Trans>Auto add fields</Trans>
|
|
||||||
)}
|
|
||||||
</Button>
|
</Button>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
// sort-imports-ignore
|
// sort-imports-ignore
|
||||||
|
|
||||||
// ---- PATCH pdfjs-dist's canvas require BEFORE importing it ----
|
// ---- PATCH pdfjs-dist's canvas require BEFORE importing it ----
|
||||||
import { createRequire } from 'module';
|
import { createRequire } from 'node:module';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import { Canvas, Image } from 'skia-canvas';
|
import { Canvas, Image } from 'skia-canvas';
|
||||||
|
|
||||||
const require = createRequire(import.meta.url || fileURLToPath(new URL('.', import.meta.url)));
|
const require = createRequire(import.meta.url || fileURLToPath(new URL('.', import.meta.url)));
|
||||||
const Module = require('module');
|
const Module = require('node:module');
|
||||||
|
|
||||||
const originalRequire = Module.prototype.require;
|
const originalRequire = Module.prototype.require;
|
||||||
Module.prototype.require = function (path: string) {
|
Module.prototype.require = function (path: string) {
|
||||||
@ -24,24 +24,23 @@ Module.prototype.require = function (path: string) {
|
|||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
const pdfjsLib = require('pdfjs-dist/legacy/build/pdf.js');
|
const pdfjsLib = require('pdfjs-dist/legacy/build/pdf.js');
|
||||||
|
|
||||||
import { generateObject } from 'ai';
|
import { mkdir, writeFile } from 'node:fs/promises';
|
||||||
import { mkdir, writeFile } from 'fs/promises';
|
import { join } from 'node:path';
|
||||||
import { Hono } from 'hono';
|
|
||||||
import { join } from 'path';
|
|
||||||
import sharp from 'sharp';
|
|
||||||
|
|
||||||
import { getSession } from '@documenso/auth/server/lib/utils/get-session';
|
import { getSession } from '@documenso/auth/server/lib/utils/get-session';
|
||||||
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
|
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
|
||||||
import { getTeamById } from '@documenso/lib/server-only/team/get-team';
|
import { getTeamById } from '@documenso/lib/server-only/team/get-team';
|
||||||
import { getFileServerSide } from '@documenso/lib/universal/upload/get-file.server';
|
import { getFileServerSide } from '@documenso/lib/universal/upload/get-file.server';
|
||||||
import { env } from '@documenso/lib/utils/env';
|
import { env } from '@documenso/lib/utils/env';
|
||||||
import { prisma } from '@documenso/prisma';
|
import { prisma } from '@documenso/prisma';
|
||||||
|
import { generateObject } from 'ai';
|
||||||
|
import { Hono } from 'hono';
|
||||||
|
import sharp from 'sharp';
|
||||||
|
|
||||||
import type { HonoEnv } from '../router';
|
import type { HonoEnv } from '../router';
|
||||||
import {
|
import {
|
||||||
type TDetectFormFieldsResponse,
|
type TDetectFormFieldsResponse,
|
||||||
ZDetectFormFieldsRequestSchema,
|
|
||||||
ZDetectedFormFieldSchema,
|
ZDetectedFormFieldSchema,
|
||||||
|
ZDetectFormFieldsRequestSchema,
|
||||||
} from './ai.types';
|
} from './ai.types';
|
||||||
|
|
||||||
const renderPdfToImage = async (pdfBytes: Uint8Array) => {
|
const renderPdfToImage = async (pdfBytes: Uint8Array) => {
|
||||||
@ -143,6 +142,8 @@ DETECTION GUIDELINES:
|
|||||||
|
|
||||||
BOUNDING BOX PLACEMENT (CRITICAL):
|
BOUNDING BOX PLACEMENT (CRITICAL):
|
||||||
- Your coordinates must capture ONLY the empty fillable space (the blank area where input goes)
|
- Your coordinates must capture ONLY the empty fillable space (the blank area where input goes)
|
||||||
|
- Once you find the fillable region, LOCK the box to the full boundary of that region (top, bottom, left, right). Do not leave the box floating over just the starting edge.
|
||||||
|
- If the field is defined by a line or a rectangular border, extend xmin/xmax/ymin/ymax across the entire line/border so the box spans the whole writable area end-to-end.
|
||||||
- EXCLUDE all printed text labels, even if they are:
|
- EXCLUDE all printed text labels, even if they are:
|
||||||
· Directly to the left of the field (e.g., "Name: _____")
|
· Directly to the left of the field (e.g., "Name: _____")
|
||||||
· Directly above the field (e.g., "Signature" printed above a line)
|
· Directly above the field (e.g., "Signature" printed above a line)
|
||||||
@ -150,6 +151,7 @@ BOUNDING BOX PLACEMENT (CRITICAL):
|
|||||||
· Inside the same outlined box as the fillable area
|
· Inside the same outlined box as the fillable area
|
||||||
- The label text helps you IDENTIFY the field type, but must be EXCLUDED from the bounding box
|
- The label text helps you IDENTIFY the field type, but must be EXCLUDED from the bounding box
|
||||||
- If you detect a label "Email:" followed by a blank box, draw the box around ONLY the blank box, not the word "Email:"
|
- If you detect a label "Email:" followed by a blank box, draw the box around ONLY the blank box, not the word "Email:"
|
||||||
|
- The box should never cover only the leftmost few characters of a long field. For "Signature: ____________", the box must stretch from the first underscore to the last.
|
||||||
|
|
||||||
COORDINATE SYSTEM:
|
COORDINATE SYSTEM:
|
||||||
- [ymin, xmin, ymax, xmax] normalized to 0-1000 scale
|
- [ymin, xmin, ymax, xmax] normalized to 0-1000 scale
|
||||||
|
|||||||
Reference in New Issue
Block a user