u
This commit is contained in:
@@ -1,96 +1,5 @@
|
||||
Process Incoming Product and Invoices: Document Extraction & Manifests
|
||||
Process Incoming Product and Invoices: use draft_delivery_manifest tool to store parsed invoice
|
||||
|
||||
# Overview
|
||||
|
||||
This skill guides the automated and interactive processing of inbound supplier documents (invoices / *Rechnungen* and delivery notes / *Lieferscheine*).
|
||||
It covers:
|
||||
- **Document Data Extraction**: Extracting structured metadata, packaging units (VPE), units of measurement, line items, and notes from document text or images.
|
||||
- **Delta & Batching Updates**: Formatting and returning extracted product and document metadata via the `output_manifest` tool.
|
||||
|
||||
---
|
||||
|
||||
# 2. Extraction Tool Specification (`output_manifest`)
|
||||
|
||||
The extraction engine outputs structured findings via the `output_manifest` tool call.
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "output_manifest",
|
||||
"description": "Stores extracted invoice/delivery-note data: header metadata (basedata), notes, and product line items. Each component is strictly optional — only include the ones that carry new data.",
|
||||
"strict": false,
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [],
|
||||
"properties": {
|
||||
"basedata": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"date": { "type": ["string", "null"], "description": "Document date (ISO 8601, YYYY-MM-DD)" },
|
||||
"lieferant_id": { "type": ["number", "null"], "description": "Lieferant ID if matched, else null" },
|
||||
"lieferantName": { "type": "string", "description": "Supplier name" },
|
||||
"manifestNr": { "type": ["string", "null"], "description": "Lieferscheinnummer or Rechnungsnummer" },
|
||||
"manifestType": {
|
||||
"anyOf": [
|
||||
{ "type": "string", "enum": ["rechnung", "lieferschein"] },
|
||||
{ "type": "null" }
|
||||
],
|
||||
"description": "Document type"
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "type": "null" }
|
||||
],
|
||||
"description": "Header/metadata. Only include fields that are currently missing or changed."
|
||||
},
|
||||
"notes": {
|
||||
"anyOf": [
|
||||
{ "type": "array", "items": { "type": "string" } },
|
||||
{ "type": "null" }
|
||||
],
|
||||
"description": "New noteworthy details (in German), for a human to double-check the result."
|
||||
},
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"numberOfItemsToAdd": { "type": "number", "description": "Number of NEW line items being added in this call." },
|
||||
"items": {
|
||||
"type": "array",
|
||||
"description": "Invoice/delivery product line items",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["position", "count", "vpe", "unit", "articleName", "liefArtNr", "mwst", "eknetto"],
|
||||
"properties": {
|
||||
"position": { "type": "number", "description": "Position number" },
|
||||
"count": { "type": "number", "description": "Quantity (Menge)" },
|
||||
"vpe": { "type": "number", "description": "Packaging unit size (VPE). Default: 1." },
|
||||
"unit": { "type": "string", "description": "Unit of the individual sellable item. NEVER 'VE' or 'VPE'." },
|
||||
"articleName": { "type": "string", "description": "Article name" },
|
||||
"liefArtNr": { "type": "string", "description": "Supplier article number" },
|
||||
"mwst": {
|
||||
"anyOf": [{ "type": "string", "enum": ["7", "19"] }, { "type": "null" }],
|
||||
"description": "VAT rate percentage; null if delivery note or missing"
|
||||
},
|
||||
"eknetto": { "type": ["number", "null"], "description": "Net purchase price per VPE in euro cents; null if missing" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "type": "null" }
|
||||
],
|
||||
"description": "New product line items."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
use draft_delivery_manifest tool to store parsed invoice
|
||||
@@ -28,6 +28,7 @@ import { createSearchArticlesTool } from '../tools/search-articles.js';
|
||||
import { createEanChecksumTool } from '../tools/ean-checksum.js';
|
||||
import { createNetGrossCalcTool } from '../tools/net-gross-calc.js';
|
||||
import { createSetUserRouteTool } from '../tools/set-user-route.js';
|
||||
import { createDraftDeliveryManifestTool } from '../tools/draft-delivery-manifest.js';
|
||||
import { createSubagentTool } from '../tools/subagent.js';
|
||||
import { resolveOpenRouterKey, resolveDefaultModel, resolveModelReasoning, RETIRED_MODELS, hasConfiguredOpenRouterKey } from '../tools/llm-key.js';
|
||||
|
||||
@@ -759,6 +760,7 @@ export class ConversationManager {
|
||||
this.broadcast('route', { route });
|
||||
},
|
||||
}),
|
||||
createDraftDeliveryManifestTool(),
|
||||
createSubagentTool({
|
||||
googleAuthId,
|
||||
companyId: this.companyId,
|
||||
|
||||
87
src/tools/draft-delivery-manifest.js
Normal file
87
src/tools/draft-delivery-manifest.js
Normal file
@@ -0,0 +1,87 @@
|
||||
import { defineTool } from 'libllmorbiter';
|
||||
|
||||
/**
|
||||
* Creates the draft_delivery_manifest tool.
|
||||
* Stores extracted invoice/delivery-note data: header metadata (basedata), notes, and product line items.
|
||||
*/
|
||||
export function createDraftDeliveryManifestTool() {
|
||||
return defineTool({
|
||||
name: 'draft_delivery_manifest',
|
||||
description:
|
||||
'Stores extracted invoice/delivery-note data: header metadata (basedata), notes, and product line items. Each component is strictly optional — only include the ones that carry new data.',
|
||||
strict: false,
|
||||
parameters: {
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
required: [],
|
||||
properties: {
|
||||
basedata: {
|
||||
anyOf: [
|
||||
{
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
date: { type: ['string', 'null'], description: 'Document date (ISO 8601)' },
|
||||
lieferant_id: { type: ['number', 'null'], description: 'Lieferant ID' },
|
||||
lieferantName: { type: 'string', description: 'Lieferant name' },
|
||||
manifestNr: { type: ['string', 'null'], description: 'Lieferscheinnummer or Rechnungsnummer' },
|
||||
manifestType: {
|
||||
anyOf: [
|
||||
{ type: 'string', enum: ['rechnung', 'lieferschein'] },
|
||||
{ type: 'null' },
|
||||
],
|
||||
description: 'Document type',
|
||||
},
|
||||
},
|
||||
},
|
||||
{ type: 'null' },
|
||||
],
|
||||
description: 'Header/metadata. Only include fields that are currently missing or changed.',
|
||||
},
|
||||
notes: {
|
||||
anyOf: [
|
||||
{ type: 'array', items: { type: 'string' } },
|
||||
{ type: 'null' },
|
||||
],
|
||||
description: 'New noteworthy details (in German), for a human to double-check the result.',
|
||||
},
|
||||
items: {
|
||||
anyOf: [
|
||||
{
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
numberOfItemsToAdd: { type: 'number', description: 'Number of NEW line items being added in this call.' },
|
||||
items: {
|
||||
type: 'array',
|
||||
description: 'Invoice/delivery product line items',
|
||||
items: {
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
required: ['position', 'count', 'vpe', 'unit', 'articleName', 'liefArtNr', 'mwst', 'eknetto'],
|
||||
properties: {
|
||||
position: { type: 'number', description: 'Position' },
|
||||
count: { type: 'number', description: 'Quantity (Menge)' },
|
||||
vpe: { type: 'number', description: 'Packaging unit size (VPE). Default: 1.' },
|
||||
unit: { type: 'string', description: 'Unit of the individual sellable item. NEVER "VE" or "VPE".' },
|
||||
articleName: { type: 'string', description: 'Article name' },
|
||||
liefArtNr: { type: 'string', description: 'Supplier article number' },
|
||||
mwst: {
|
||||
anyOf: [{ type: 'string', enum: ['7', '19'] }, { type: 'null' }],
|
||||
description: 'VAT rate; null if missing',
|
||||
},
|
||||
eknetto: { type: ['number', 'null'], description: 'Net price per vpe in euro cents; null if missing' },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{ type: 'null' },
|
||||
],
|
||||
description: 'New product line items.',
|
||||
},
|
||||
},
|
||||
},
|
||||
invoke: async () => ({ success: true }),
|
||||
});
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import { createApiSuggestionsOrIssuesTool } from './apisuggestionsorissues.js';
|
||||
import { createSearchArticlesTool } from './search-articles.js';
|
||||
import { createEanChecksumTool } from './ean-checksum.js';
|
||||
import { createNetGrossCalcTool } from './net-gross-calc.js';
|
||||
import { createDraftDeliveryManifestTool } from './draft-delivery-manifest.js';
|
||||
|
||||
/**
|
||||
* subagent — delegates a self-contained task to an isolated LLMOrbiter run that lives in
|
||||
@@ -179,6 +180,7 @@ function createSubagentTools({ googleAuthId, companyId, model }) {
|
||||
createSearchArticlesTool({ googleAuthId, companyId }),
|
||||
createEanChecksumTool(),
|
||||
createNetGrossCalcTool(),
|
||||
createDraftDeliveryManifestTool(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user