Skip to main content

Method-based Inference

Call a specific sub-method on a custom or fine-tuned model using the Knowledgator TypeScript SDK.

Method-based inference invokes dedicated sub-endpoints: POST /inference/{model_id}/{method}/.


Example Usage​

Shorthand Model Client​

You can bind a method directly when obtaining the model client:

import { createClient } from '@knowledgator/typescript-sdk';

const kg = createClient();

// Connect to model with 'relations' method binding
const extractor = kg.model('m-d9be7ede307943439a30c6f814026566', 'relations');

const result = await extractor.predict({
text: 'Apple released the new iPhone in Cupertino.',
entities: ['organization', 'product', 'location'],
relations: ['released_in', 'produced_by']
});

console.log(result);

Explicit call() on Model Instance​

Alternatively, invoke model.call(method, payload) dynamically:

import { createClient } from '@knowledgator/typescript-sdk';

const kg = createClient();

const model = kg.model('m-d9be7ede307943439a30c6f814026566');

const result = await model.call('relations', {
text: 'Apple released the new iPhone in Cupertino.',
entities: ['organization', 'product', 'location'],
relations: ['released_in', 'produced_by']
});

console.log(result);