|
| 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 }; |
0 commit comments