Skip to main content

Instruct-it

The instruct_inference tool enables LLMs and autonomous agents to perform instruction-driven information extraction conforming to custom JSON schemas or desired output formats.


Tool Overview​

  • Tool Name: instruct_inference
  • Underlying Endpoint: POST /inference/instruct/
  • SDK Methods: kg.instruct.it (Python) / kg.instruct.it (TypeScript)
LoRA Adapters vs. Open Models

adapter_id is for fine-tuned LoRA adapters attached to the base Instruct-it service. If you trained or deployed a standalone Open Model, use the open_model_inference tool instead.


Parameters​

ParameterTypeRequiredDescription
textStringYesMain prompt instruction or text query.
templateString or ObjectYesJSON schema template string or dictionary that the output should adhere to.
output_typeStringNoDesired output format hint (json, string, markdown, etc.).
adapter_idStringNoOptional LoRA adapter ID for fine-tuned adapters (attaches KnowledgatorAPI-Model-ID header).
timeout_msIntegerNoRequest timeout in milliseconds (default: 60000 = 60s).

Example Usage​

Natural Language Prompt to Agent​

"Parse this invoice snippet using Knowledgator Instruct-it into structured JSON: 'Invoice #INV-2024-001 issued to Acme Corp on 2024-01-15 for the total sum of $1,250.00.'"

Tool Call Arguments​

{
"name": "instruct_inference",
"arguments": {
"text": "Invoice #INV-2024-001 issued to Acme Corp on 2024-01-15 for the total sum of $1,250.00.",
"output_type": "json",
"template": {
"invoice_id": "string",
"customer": "string",
"date": "YYYY-MM-DD",
"total": "number"
}
}
}

Tool Response​

{
"outputs": {
"invoice_id": "INV-2024-001",
"customer": "Acme Corp",
"date": "2024-01-15",
"total": 1250.00
}
}