Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.5.1"
".": "0.6.0"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 2
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/isaacus%2Fisaacus-d58ccd91625a3b12fd8d1ceece128b604010bd840096000287c927cb5dcf79eb.yml
openapi_spec_hash: 22c8c973d55f26649e9df96c89ea537f
config_hash: 1d603d50b7183a492ad6df5f728a1863
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/isaacus%2Fisaacus-213d554b23f35e746460af23dd32bdde471230549ad223518c86d42ea917a180.yml
openapi_spec_hash: 3672281fe031a42fc59e3a2af758a8f8
config_hash: 1d15d860383a3f6da1ac388297687cc9
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 0.6.0 (2025-04-19)

Full Changelog: [v0.5.1...v0.6.0](https://github.com/isaacus-dev/isaacus-typescript/compare/v0.5.1...v0.6.0)

### ⚠ BREAKING CHANGES

* **api:** made universal classification endpoint multi-input only

### Features

* **api:** made universal classification endpoint multi-input only ([af242f4](https://github.com/isaacus-dev/isaacus-typescript/commit/af242f49a223c9521b713ff6f35343913a3d804f))

## 0.5.1 (2025-04-16)

Full Changelog: [v0.5.0...v0.5.1](https://github.com/isaacus-dev/isaacus-typescript/compare/v0.5.0...v0.5.1)
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ async function main() {
const universalClassification = await client.classifications.universal.create({
model: 'kanon-universal-classifier',
query: 'This is a confidentiality clause.',
text: 'I agree not to tell anyone about the document.',
texts: ['I agree not to tell anyone about the document.'],
});

console.log(universalClassification.chunks);
console.log(universalClassification.classifications);
}

main();
Expand All @@ -55,7 +55,7 @@ async function main() {
const params: Isaacus.Classifications.UniversalCreateParams = {
model: 'kanon-universal-classifier',
query: 'This is a confidentiality clause.',
text: 'I agree not to tell anyone about the document.',
texts: ['I agree not to tell anyone about the document.'],
};
const universalClassification: Isaacus.Classifications.UniversalClassification =
await client.classifications.universal.create(params);
Expand All @@ -79,7 +79,7 @@ async function main() {
.create({
model: 'kanon-universal-classifier',
query: 'This is a confidentiality clause.',
text: 'I agree not to tell anyone about the document.',
texts: ['I agree not to tell anyone about the document.'],
})
.catch(async (err) => {
if (err instanceof Isaacus.APIError) {
Expand Down Expand Up @@ -124,7 +124,7 @@ const client = new Isaacus({
});

// Or, configure per-request:
await client.classifications.universal.create({ model: 'kanon-universal-classifier', query: 'This is a confidentiality clause.', text: 'I agree not to tell anyone about the document.' }, {
await client.classifications.universal.create({ model: 'kanon-universal-classifier', query: 'This is a confidentiality clause.', texts: ['I agree not to tell anyone about the document.'] }, {
maxRetries: 5,
});
```
Expand All @@ -141,7 +141,7 @@ const client = new Isaacus({
});

// Override per-request:
await client.classifications.universal.create({ model: 'kanon-universal-classifier', query: 'This is a confidentiality clause.', text: 'I agree not to tell anyone about the document.' }, {
await client.classifications.universal.create({ model: 'kanon-universal-classifier', query: 'This is a confidentiality clause.', texts: ['I agree not to tell anyone about the document.'] }, {
timeout: 5 * 1000,
});
```
Expand All @@ -168,7 +168,7 @@ const response = await client.classifications.universal
.create({
model: 'kanon-universal-classifier',
query: 'This is a confidentiality clause.',
text: 'I agree not to tell anyone about the document.',
texts: ['I agree not to tell anyone about the document.'],
})
.asResponse();
console.log(response.headers.get('X-My-Header'));
Expand All @@ -178,11 +178,11 @@ const { data: universalClassification, response: raw } = await client.classifica
.create({
model: 'kanon-universal-classifier',
query: 'This is a confidentiality clause.',
text: 'I agree not to tell anyone about the document.',
texts: ['I agree not to tell anyone about the document.'],
})
.withResponse();
console.log(raw.headers.get('X-My-Header'));
console.log(universalClassification.chunks);
console.log(universalClassification.classifications);
```

### Logging
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "isaacus",
"version": "0.5.1",
"version": "0.6.0",
"description": "The official TypeScript library for the Isaacus API",
"author": "Isaacus <support@isaacus.com>",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/mcp-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ The following tools are available in this MCP server.

### Resource `classifications.universal`:

- `create_classifications_universal` (`write`): Classify the relevance of a legal document to a query with an Isaacus universal legal AI classifier.
- `create_classifications_universal` (`write`): Classify the relevance of legal documents to a query with an Isaacus universal legal AI classifier.

### Resource `rerankings`:

Expand Down
2 changes: 1 addition & 1 deletion packages/mcp-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "isaacus-mcp",
"version": "0.5.1",
"version": "0.6.0",
"description": "The official MCP Server for the Isaacus API",
"author": "Isaacus <support@isaacus.com>",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/mcp-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export { endpoints } from './tools';
export const server = new McpServer(
{
name: 'isaacus_api',
version: '0.5.1',
version: '0.6.0',
},
{
capabilities: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const metadata: Metadata = {
export const tool: Tool = {
name: 'create_classifications_universal',
description:
'Classify the relevance of a legal document to a query with an Isaacus universal legal AI classifier.',
'Classify the relevance of legal documents to a query with an Isaacus universal legal AI classifier.',
inputSchema: {
type: 'object',
properties: {
Expand All @@ -26,11 +26,16 @@ export const tool: Tool = {
query: {
type: 'string',
description:
'The [Isaacus Query Language (IQL)](https://docs.isaacus.com/iql) query or, if IQL is disabled, the statement, to evaluate the text against.\n\nThe query must contain at least one non-whitespace character.\n\nUnlike the text being classified, the query cannot be so long that it exceeds the maximum input length of the universal classifier.',
'The [Isaacus Query Language (IQL)](https://docs.isaacus.com/iql) query or, if IQL is disabled, the statement, to evaluate the texts against.\n\nThe query must contain at least one non-whitespace character.\n\nUnlike the texts being classified, the query cannot be so long that it exceeds the maximum input length of the universal classifier.',
},
text: {
type: 'string',
description: 'The text to classify.\n\nThe text must contain at least one non-whitespace character.',
texts: {
type: 'array',
description:
'The texts to classify.\n\nThe texts must contain at least one non-whitespace character.',
items: {
type: 'string',
title: 'Non-blank string',
},
},
chunking_options: {
type: 'object',
Expand Down Expand Up @@ -63,7 +68,7 @@ export const tool: Tool = {
scoring_method: {
type: 'string',
description:
"The method to use for producing an overall confidence score.\n\n`auto` is the default scoring method and is recommended for most use cases. Currently, it is equivalent to `chunk_max`. In the future, it will automatically select the best method based on the model and input.\n\n`chunk_max` uses the highest confidence score of all of the text's chunks.\n\n`chunk_avg` averages the confidence scores of all of the text's chunks.\n\n`chunk_min` uses the lowest confidence score of all of the text's chunks.",
"The method to use for producing an overall confidence score.\n\n`auto` is the default scoring method and is recommended for most use cases. Currently, it is equivalent to `chunk_max`. In the future, it will automatically select the best method based on the model and inputs.\n\n`chunk_max` uses the highest confidence score of all of the texts' chunks.\n\n`chunk_avg` averages the confidence scores of all of the texts' chunks.\n\n`chunk_min` uses the lowest confidence score of all of the texts' chunks.",
enum: ['auto', 'chunk_max', 'chunk_avg', 'chunk_min'],
},
},
Expand Down
106 changes: 63 additions & 43 deletions src/resources/classifications/universal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { RequestOptions } from '../../internal/request-options';

export class Universal extends APIResource {
/**
* Classify the relevance of a legal document to a query with an Isaacus universal
* Classify the relevance of legal documents to a query with an Isaacus universal
* legal AI classifier.
*/
create(body: UniversalCreateParams, options?: RequestOptions): APIPromise<UniversalClassification> {
Expand All @@ -15,27 +15,15 @@ export class Universal extends APIResource {
}

/**
* A classification of the relevance of a legal document to a query produced by an
* Classifications of the relevance of legal documents to a query produced by an
* Isaacus universal legal AI classifier.
*/
export interface UniversalClassification {
/**
* The text as broken into chunks by
* [semchunk](https://github.com/isaacus-dev/semchunk), each chunk with its own
* confidence score, ordered from highest to lowest score.
*
* If no chunking occurred, this will be `null`.
*/
chunks: Array<UniversalClassification.Chunk> | null;

/**
* A score of the likelihood that the query expressed about the text is supported
* by the text.
*
* A score greater than `0.5` indicates that the text supports the query, while a
* score less than `0.5` indicates that the text does not support the query.
* The classifications of the texts, by relevance to the query, in order from
* highest to lowest relevance score.
*/
score: number;
classifications: Array<UniversalClassification.Classification>;

/**
* Statistics about the usage of resources in the process of classifying the text.
Expand All @@ -44,35 +32,67 @@ export interface UniversalClassification {
}

export namespace UniversalClassification {
export interface Chunk {
export interface Classification {
/**
* The end index of the chunk in the original text.
* The text as broken into chunks by
* [semchunk](https://github.com/isaacus-dev/semchunk), each chunk with its own
* confidence score, ordered from highest to lowest score.
*
* If no chunking occurred, this will be `null`.
*/
end: number;
chunks: Array<Classification.Chunk> | null;

/**
* The index of the chunk in the list of chunks.
* The index of the text in the input array of texts, starting from `0` (and,
* therefore, ending at the number of texts minus `1`).
*/
index: number;

/**
* The model's score of the likelihood that the query expressed about the chunk is
* supported by the chunk.
* A score of the likelihood that the query expressed about the text is supported
* by the text.
*
* A score greater than `0.5` indicates that the chunk supports the query, while a
* score less than `0.5` indicates that the chunk does not support the query.
* A score greater than `0.5` indicates that the text supports the query, while a
* score less than `0.5` indicates that the text does not support the query.
*/
score: number;
}

/**
* The start index of the chunk in the original text.
*/
start: number;

/**
* The text of the chunk.
*/
text: string;
export namespace Classification {
export interface Chunk {
/**
* The index of the character in the original text where the chunk ends, beginning
* from `0` (such that, in Python, the chunk is equivalent to `text[start:end+1]`).
*/
end: number;

/**
* The original position of the chunk in the outputted list of chunks before
* sorting, starting from `0` (and, therefore, ending at the number of chunks minus
* `1`).
*/
index: number;

/**
* The model's score of the likelihood that the query expressed about the chunk is
* supported by the chunk.
*
* A score greater than `0.5` indicates that the chunk supports the query, while a
* score less than `0.5` indicates that the chunk does not support the query.
*/
score: number;

/**
* The index of the character in the original text where the chunk starts,
* beginning from `0`.
*/
start: number;

/**
* The text of the chunk.
*/
text: string;
}
}

/**
Expand All @@ -95,21 +115,21 @@ export interface UniversalCreateParams {

/**
* The [Isaacus Query Language (IQL)](https://docs.isaacus.com/iql) query or, if
* IQL is disabled, the statement, to evaluate the text against.
* IQL is disabled, the statement, to evaluate the texts against.
*
* The query must contain at least one non-whitespace character.
*
* Unlike the text being classified, the query cannot be so long that it exceeds
* Unlike the texts being classified, the query cannot be so long that it exceeds
* the maximum input length of the universal classifier.
*/
query: string;

/**
* The text to classify.
* The texts to classify.
*
* The text must contain at least one non-whitespace character.
* The texts must contain at least one non-whitespace character.
*/
text: string;
texts: Array<string>;

/**
* Options for how to split text into smaller chunks.
Expand All @@ -127,13 +147,13 @@ export interface UniversalCreateParams {
*
* `auto` is the default scoring method and is recommended for most use cases.
* Currently, it is equivalent to `chunk_max`. In the future, it will automatically
* select the best method based on the model and input.
* select the best method based on the model and inputs.
*
* `chunk_max` uses the highest confidence score of all of the text's chunks.
* `chunk_max` uses the highest confidence score of all of the texts' chunks.
*
* `chunk_avg` averages the confidence scores of all of the text's chunks.
* `chunk_avg` averages the confidence scores of all of the texts' chunks.
*
* `chunk_min` uses the lowest confidence score of all of the text's chunks.
* `chunk_min` uses the lowest confidence score of all of the texts' chunks.
*/
scoring_method?: 'auto' | 'chunk_max' | 'chunk_avg' | 'chunk_min';
}
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '0.5.1'; // x-release-please-version
export const VERSION = '0.6.0'; // x-release-please-version
4 changes: 2 additions & 2 deletions tests/api-resources/classifications/universal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('resource universal', () => {
const responsePromise = client.classifications.universal.create({
model: 'kanon-universal-classifier',
query: 'This is a confidentiality clause.',
text: 'I agree not to tell anyone about the document.',
texts: ['I agree not to tell anyone about the document.'],
});
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
Expand All @@ -29,7 +29,7 @@ describe('resource universal', () => {
const response = await client.classifications.universal.create({
model: 'kanon-universal-classifier',
query: 'This is a confidentiality clause.',
text: 'I agree not to tell anyone about the document.',
texts: ['I agree not to tell anyone about the document.'],
chunking_options: { overlap_ratio: 0.1, overlap_tokens: 0, size: 512 },
is_iql: true,
scoring_method: 'auto',
Expand Down