Skip to content

Commit c4755bc

Browse files
feat(sdk): untoggle to force regen
1 parent 9c9ef78 commit c4755bc

File tree

9 files changed

+260
-4
lines changed

9 files changed

+260
-4
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 3
1+
configured_endpoints: 4
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/isaacus%2Fisaacus-30c23c1facb9383eb94d78d16d6a45b7e6afd943caf94cddeb75fd86357294f7.yml
33
openapi_spec_hash: 48a6b3192add4f538615ac6f190123c5
4-
config_hash: 83740a990f84ee8d189fc4071a009a83
4+
config_hash: 886b5eef0dbd90b8e6686e987a07b816

api.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# Embeddings
2+
3+
Types:
4+
5+
- <code><a href="./src/resources/embeddings.ts">Embedding</a></code>
6+
7+
Methods:
8+
9+
- <code title="post /embeddings">client.embeddings.<a href="./src/resources/embeddings.ts">create</a>({ ...params }) -> Embedding</code>
10+
111
# Classifications
212

313
## Universal

packages/mcp-server/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ http://localhost:3000?client=cursor&capability=tool-name-length%3D40
172172
import { server, endpoints, init } from "isaacus-mcp/server";
173173

174174
// import a specific tool
175-
import createClassificationsUniversal from "isaacus-mcp/tools/classifications/universal/create-classifications-universal";
175+
import createEmbeddings from "isaacus-mcp/tools/embeddings/create-embeddings";
176176

177177
// initialize the server and all endpoints
178178
init({ server, endpoints });
@@ -197,13 +197,17 @@ const myCustomEndpoint = {
197197
};
198198

199199
// initialize the server with your custom endpoints
200-
init({ server: myServer, endpoints: [createClassificationsUniversal, myCustomEndpoint] });
200+
init({ server: myServer, endpoints: [createEmbeddings, myCustomEndpoint] });
201201
```
202202

203203
## Available Tools
204204

205205
The following tools are available in this MCP server.
206206

207+
### Resource `embeddings`:
208+
209+
- `create_embeddings` (`write`): Embed legal texts with an Isaacus legal AI embedder.
210+
207211
### Resource `classifications.universal`:
208212

209213
- `create_classifications_universal` (`write`): Classify the relevance of legal documents to a query with an Isaacus universal legal AI classifier.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import { maybeFilter } from 'isaacus-mcp/filtering';
4+
import { Metadata, asTextContentResult } from 'isaacus-mcp/tools/types';
5+
6+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
7+
import Isaacus from 'isaacus';
8+
9+
export const metadata: Metadata = {
10+
resource: 'embeddings',
11+
operation: 'write',
12+
tags: [],
13+
httpMethod: 'post',
14+
httpPath: '/embeddings',
15+
operationId: 'CreateEmbeddings',
16+
};
17+
18+
export const tool: Tool = {
19+
name: 'create_embeddings',
20+
description:
21+
"When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nEmbed legal texts with an Isaacus legal AI embedder.\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/embedding',\n $defs: {\n embedding: {\n type: 'object',\n title: 'Embedding response',\n description: 'Embeddings of legal texts produced by an Isaacus legal AI embedder.',\n properties: {\n embeddings: {\n type: 'array',\n description: 'The embeddings of the inputs.',\n items: {\n type: 'object',\n title: 'Content embedding',\n properties: {\n embedding: {\n type: 'array',\n description: 'The embedding of the content represented as an array of floating point numbers.',\n items: {\n type: 'number'\n }\n },\n index: {\n type: 'integer',\n description: 'The position of the content in the input array of contents, starting from `0` (and, therefore, ending at the number of contents minus `1`).'\n }\n },\n required: [ 'embedding',\n 'index'\n ]\n }\n },\n usage: {\n type: 'object',\n title: 'Embedding usage',\n description: 'Statistics about the usage of resources in the process of embedding the inputs.',\n properties: {\n input_tokens: {\n type: 'integer',\n description: 'The number of tokens inputted to the model.'\n }\n },\n required: [ 'input_tokens'\n ]\n }\n },\n required: [ 'embeddings',\n 'usage'\n ]\n }\n }\n}\n```",
22+
inputSchema: {
23+
type: 'object',
24+
properties: {
25+
model: {
26+
type: 'string',
27+
description: 'The ID of the [model](https://docs.isaacus.com/models#embedding) to use for embedding.',
28+
enum: ['kanon-2-embedder'],
29+
},
30+
texts: {
31+
anyOf: [
32+
{
33+
type: 'array',
34+
items: {
35+
type: 'string',
36+
title: 'Non-blank string',
37+
},
38+
},
39+
{
40+
type: 'string',
41+
title: 'Non-blank string',
42+
},
43+
],
44+
description:
45+
'The text or array of texts to embed.\n\nEach text must contain at least one non-whitespace character.\n\nNo more than 1,000 texts can be embedded in a single request.',
46+
},
47+
dimensions: {
48+
type: 'integer',
49+
title: 'Positive integer',
50+
description: 'A whole number greater than or equal to 1.',
51+
},
52+
overflow_strategy: {
53+
type: 'string',
54+
description:
55+
"The strategy to employ when content exceeds the model's maximum input length.\n\n`drop_end`, which is the default setting, drops tokens from the end of the content exceeding the limit.\n\nIf `null`, an error will be raised if any content exceeds the model's maximum input length.",
56+
enum: ['drop_end'],
57+
},
58+
task: {
59+
type: 'string',
60+
description:
61+
'The task the embeddings will be used for.\n\n`retrieval/query` is meant for queries and statements, and `retrieval/document` is meant for anything to be retrieved using query embeddings.\n\nIf `null`, which is the default setting, embeddings will not be optimized for any particular task.',
62+
enum: ['retrieval/query', 'retrieval/document'],
63+
},
64+
jq_filter: {
65+
type: 'string',
66+
title: 'jq Filter',
67+
description:
68+
'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).',
69+
},
70+
},
71+
required: ['model', 'texts'],
72+
},
73+
annotations: {},
74+
};
75+
76+
export const handler = async (client: Isaacus, args: Record<string, unknown> | undefined) => {
77+
const { jq_filter, ...body } = args as any;
78+
return asTextContentResult(await maybeFilter(jq_filter, await client.embeddings.create(body)));
79+
};
80+
81+
export default { metadata, tool, handler };

packages/mcp-server/src/tools/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Metadata, Endpoint, HandlerFunction } from './types';
44

55
export { Metadata, Endpoint, HandlerFunction };
66

7+
import create_embeddings from './embeddings/create-embeddings';
78
import create_classifications_universal from './classifications/universal/create-classifications-universal';
89
import create_rerankings from './rerankings/create-rerankings';
910
import create_extractions_qa from './extractions/qa/create-extractions-qa';
@@ -14,6 +15,7 @@ function addEndpoint(endpoint: Endpoint) {
1415
endpoints.push(endpoint);
1516
}
1617

18+
addEndpoint(create_embeddings);
1719
addEndpoint(create_classifications_universal);
1820
addEndpoint(create_rerankings);
1921
addEndpoint(create_extractions_qa);

src/client.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import * as Errors from './core/error';
1616
import * as Uploads from './core/uploads';
1717
import * as API from './resources/index';
1818
import { APIPromise } from './core/api-promise';
19+
import { Embedding, EmbeddingCreateParams, Embeddings } from './resources/embeddings';
1920
import { Reranking, RerankingCreateParams, Rerankings } from './resources/rerankings';
2021
import { Classifications } from './resources/classifications/classifications';
2122
import { Extractions } from './resources/extractions/extractions';
@@ -716,18 +717,26 @@ export class Isaacus {
716717

717718
static toFile = Uploads.toFile;
718719

720+
embeddings: API.Embeddings = new API.Embeddings(this);
719721
classifications: API.Classifications = new API.Classifications(this);
720722
rerankings: API.Rerankings = new API.Rerankings(this);
721723
extractions: API.Extractions = new API.Extractions(this);
722724
}
723725

726+
Isaacus.Embeddings = Embeddings;
724727
Isaacus.Classifications = Classifications;
725728
Isaacus.Rerankings = Rerankings;
726729
Isaacus.Extractions = Extractions;
727730

728731
export declare namespace Isaacus {
729732
export type RequestOptions = Opts.RequestOptions;
730733

734+
export {
735+
Embeddings as Embeddings,
736+
type Embedding as Embedding,
737+
type EmbeddingCreateParams as EmbeddingCreateParams,
738+
};
739+
731740
export { Classifications as Classifications };
732741

733742
export {

src/resources/embeddings.ts

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import { APIResource } from '../core/resource';
4+
import { APIPromise } from '../core/api-promise';
5+
import { RequestOptions } from '../internal/request-options';
6+
7+
export class Embeddings extends APIResource {
8+
/**
9+
* Embed legal texts with an Isaacus legal AI embedder.
10+
*
11+
* @example
12+
* ```ts
13+
* const embedding = await client.embeddings.create({
14+
* model: 'kanon-2-embedder',
15+
* texts: [
16+
* 'Are restraints of trade enforceable under English law?',
17+
* 'What is a non-compete clause?',
18+
* ],
19+
* });
20+
* ```
21+
*/
22+
create(body: EmbeddingCreateParams, options?: RequestOptions): APIPromise<Embedding> {
23+
return this._client.post('/embeddings', { body, ...options });
24+
}
25+
}
26+
27+
/**
28+
* Embeddings of legal texts produced by an Isaacus legal AI embedder.
29+
*/
30+
export interface Embedding {
31+
/**
32+
* The embeddings of the inputs.
33+
*/
34+
embeddings: Array<Embedding.Embedding>;
35+
36+
/**
37+
* Statistics about the usage of resources in the process of embedding the inputs.
38+
*/
39+
usage: Embedding.Usage;
40+
}
41+
42+
export namespace Embedding {
43+
export interface Embedding {
44+
/**
45+
* The embedding of the content represented as an array of floating point numbers.
46+
*/
47+
embedding: Array<number>;
48+
49+
/**
50+
* The position of the content in the input array of contents, starting from `0`
51+
* (and, therefore, ending at the number of contents minus `1`).
52+
*/
53+
index: number;
54+
}
55+
56+
/**
57+
* Statistics about the usage of resources in the process of embedding the inputs.
58+
*/
59+
export interface Usage {
60+
/**
61+
* The number of tokens inputted to the model.
62+
*/
63+
input_tokens: number;
64+
}
65+
}
66+
67+
export interface EmbeddingCreateParams {
68+
/**
69+
* The ID of the [model](https://docs.isaacus.com/models#embedding) to use for
70+
* embedding.
71+
*/
72+
model: 'kanon-2-embedder';
73+
74+
/**
75+
* The text or array of texts to embed.
76+
*
77+
* Each text must contain at least one non-whitespace character.
78+
*
79+
* No more than 1,000 texts can be embedded in a single request.
80+
*/
81+
texts: Array<string> | string;
82+
83+
/**
84+
* A whole number greater than or equal to 1.
85+
*/
86+
dimensions?: number | null;
87+
88+
/**
89+
* The strategy to employ when content exceeds the model's maximum input length.
90+
*
91+
* `drop_end`, which is the default setting, drops tokens from the end of the
92+
* content exceeding the limit.
93+
*
94+
* If `null`, an error will be raised if any content exceeds the model's maximum
95+
* input length.
96+
*/
97+
overflow_strategy?: 'drop_end' | null;
98+
99+
/**
100+
* The task the embeddings will be used for.
101+
*
102+
* `retrieval/query` is meant for queries and statements, and `retrieval/document`
103+
* is meant for anything to be retrieved using query embeddings.
104+
*
105+
* If `null`, which is the default setting, embeddings will not be optimized for
106+
* any particular task.
107+
*/
108+
task?: 'retrieval/query' | 'retrieval/document' | null;
109+
}
110+
111+
export declare namespace Embeddings {
112+
export { type Embedding as Embedding, type EmbeddingCreateParams as EmbeddingCreateParams };
113+
}

src/resources/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
export { Classifications } from './classifications/classifications';
4+
export { Embeddings, type Embedding, type EmbeddingCreateParams } from './embeddings';
45
export { Extractions } from './extractions/extractions';
56
export { Rerankings, type Reranking, type RerankingCreateParams } from './rerankings';
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import Isaacus from 'isaacus';
4+
5+
const client = new Isaacus({
6+
apiKey: 'My API Key',
7+
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
8+
});
9+
10+
describe('resource embeddings', () => {
11+
// Prism tests are disabled
12+
test.skip('create: only required params', async () => {
13+
const responsePromise = client.embeddings.create({
14+
model: 'kanon-2-embedder',
15+
texts: ['Are restraints of trade enforceable under English law?', 'What is a non-compete clause?'],
16+
});
17+
const rawResponse = await responsePromise.asResponse();
18+
expect(rawResponse).toBeInstanceOf(Response);
19+
const response = await responsePromise;
20+
expect(response).not.toBeInstanceOf(Response);
21+
const dataAndResponse = await responsePromise.withResponse();
22+
expect(dataAndResponse.data).toBe(response);
23+
expect(dataAndResponse.response).toBe(rawResponse);
24+
});
25+
26+
// Prism tests are disabled
27+
test.skip('create: required and optional params', async () => {
28+
const response = await client.embeddings.create({
29+
model: 'kanon-2-embedder',
30+
texts: ['Are restraints of trade enforceable under English law?', 'What is a non-compete clause?'],
31+
dimensions: 1,
32+
overflow_strategy: 'drop_end',
33+
task: 'retrieval/query',
34+
});
35+
});
36+
});

0 commit comments

Comments
 (0)