diff --git a/.stats.yml b/.stats.yml
index 6c33430f..6641d6d9 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,2 +1,2 @@
-configured_endpoints: 18
+configured_endpoints: 21
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-1cc5cdee043b0cdaf8a02e3f4e2799f17a4b88dd843cf31eea423843f5bbd4b8.yml
diff --git a/api.md b/api.md
index 71b4e511..59765460 100644
--- a/api.md
+++ b/api.md
@@ -78,3 +78,33 @@ Methods:
- client.files.download(fileId) -> Response
- client.files.retry({ ...params }) -> FileRetryResponse
- client.files.upload({ ...params }) -> File
+
+# Tools
+
+Types:
+
+- ToolContextAwareSplittingResponse
+
+Methods:
+
+- client.tools.contextAwareSplitting({ ...params }) -> ToolContextAwareSplittingResponse
+
+## Medical
+
+Types:
+
+- MedicalCreateResponse
+
+Methods:
+
+- client.tools.medical.create({ ...params }) -> MedicalCreateResponse
+
+## PdfParser
+
+Types:
+
+- PdfParserParseResponse
+
+Methods:
+
+- client.tools.pdfParser.parse(fileId, { ...params }) -> PdfParserParseResponse
diff --git a/src/index.ts b/src/index.ts
index 2c9d06ba..7f845111 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -126,6 +126,7 @@ export class Writer extends Core.APIClient {
models: API.Models = new API.Models(this);
graphs: API.Graphs = new API.Graphs(this);
files: API.Files = new API.Files(this);
+ tools: API.Tools = new API.Tools(this);
protected override defaultQuery(): Core.DefaultQuery | undefined {
return this._options.defaultQuery;
@@ -232,6 +233,10 @@ export namespace Writer {
export import FileListParams = API.FileListParams;
export import FileRetryParams = API.FileRetryParams;
export import FileUploadParams = API.FileUploadParams;
+
+ export import Tools = API.Tools;
+ export import ToolContextAwareSplittingResponse = API.ToolContextAwareSplittingResponse;
+ export import ToolContextAwareSplittingParams = API.ToolContextAwareSplittingParams;
}
export default Writer;
diff --git a/src/resources/index.ts b/src/resources/index.ts
index d6fdbefd..dc36cd24 100644
--- a/src/resources/index.ts
+++ b/src/resources/index.ts
@@ -47,3 +47,4 @@ export {
Graphs,
} from './graphs';
export { ModelListResponse, Models } from './models';
+export { ToolContextAwareSplittingResponse, ToolContextAwareSplittingParams, Tools } from './tools/tools';
diff --git a/src/resources/tools/index.ts b/src/resources/tools/index.ts
new file mode 100644
index 00000000..2bccc334
--- /dev/null
+++ b/src/resources/tools/index.ts
@@ -0,0 +1,5 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+export { MedicalCreateResponse, MedicalCreateParams, Medical } from './medical';
+export { PdfParserParseResponse, PdfParserParseParams, PdfParser } from './pdf-parser';
+export { ToolContextAwareSplittingResponse, ToolContextAwareSplittingParams, Tools } from './tools';
diff --git a/src/resources/tools/medical.ts b/src/resources/tools/medical.ts
new file mode 100644
index 00000000..634d3d60
--- /dev/null
+++ b/src/resources/tools/medical.ts
@@ -0,0 +1,116 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../resource';
+import * as Core from '../../core';
+import * as MedicalAPI from './medical';
+
+export class Medical extends APIResource {
+ /**
+ * Create a completion using Palmyra medical model.
+ */
+ create(body: MedicalCreateParams, options?: Core.RequestOptions): Core.APIPromise {
+ return this._client.post('/v1/tools/comprehend/medical', { body, ...options });
+ }
+}
+
+export interface MedicalCreateResponse {
+ /**
+ * An array of medical entities extracted from the input text.
+ */
+ entities: Array;
+}
+
+export namespace MedicalCreateResponse {
+ export interface Entity {
+ attributes: Array;
+
+ begin_offset: number;
+
+ category: string;
+
+ concepts: Array;
+
+ end_offset: number;
+
+ score: number;
+
+ text: string;
+
+ traits: Array;
+
+ type: string;
+ }
+
+ export namespace Entity {
+ export interface Attribute {
+ begin_offset: number;
+
+ concepts: Array;
+
+ end_offset: number;
+
+ relationship_score: number;
+
+ score: number;
+
+ text: string;
+
+ traits: Array;
+
+ type: string;
+
+ category?: string;
+
+ relationship_type?: string;
+ }
+
+ export namespace Attribute {
+ export interface Concept {
+ code: string;
+
+ description: string;
+
+ score: number;
+ }
+
+ export interface Trait {
+ name: string;
+
+ score: number;
+ }
+ }
+
+ export interface Concept {
+ code: string;
+
+ description: string;
+
+ score: number;
+ }
+
+ export interface Trait {
+ name: string;
+
+ score: number;
+ }
+ }
+}
+
+export interface MedicalCreateParams {
+ /**
+ * The text to be analyzed.
+ */
+ content: string;
+
+ /**
+ * The structure of the response to be returned. `Entities` returns medical
+ * entities, `RxNorm` returns medication information, `ICD-10-CM` returns diagnosis
+ * codes, and `SNOMED CT` returns medical concepts.
+ */
+ response_type: 'Entities' | 'RxNorm' | 'ICD-10-CM' | 'SNOMED CT';
+}
+
+export namespace Medical {
+ export import MedicalCreateResponse = MedicalAPI.MedicalCreateResponse;
+ export import MedicalCreateParams = MedicalAPI.MedicalCreateParams;
+}
diff --git a/src/resources/tools/pdf-parser.ts b/src/resources/tools/pdf-parser.ts
new file mode 100644
index 00000000..dd89d0b3
--- /dev/null
+++ b/src/resources/tools/pdf-parser.ts
@@ -0,0 +1,37 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../resource';
+import * as Core from '../../core';
+import * as PdfParserAPI from './pdf-parser';
+
+export class PdfParser extends APIResource {
+ /**
+ * Parse PDF to other formats.
+ */
+ parse(
+ fileId: string,
+ body: PdfParserParseParams,
+ options?: Core.RequestOptions,
+ ): Core.APIPromise {
+ return this._client.post(`/v1/tools/pdf-parser/${fileId}`, { body, ...options });
+ }
+}
+
+export interface PdfParserParseResponse {
+ /**
+ * The extracted content from the PDF file, converted to the specified format.
+ */
+ content: string;
+}
+
+export interface PdfParserParseParams {
+ /**
+ * The format into which the PDF content should be converted.
+ */
+ format: 'text' | 'markdown';
+}
+
+export namespace PdfParser {
+ export import PdfParserParseResponse = PdfParserAPI.PdfParserParseResponse;
+ export import PdfParserParseParams = PdfParserAPI.PdfParserParseParams;
+}
diff --git a/src/resources/tools/tools.ts b/src/resources/tools/tools.ts
new file mode 100644
index 00000000..c530c111
--- /dev/null
+++ b/src/resources/tools/tools.ts
@@ -0,0 +1,56 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../resource';
+import * as Core from '../../core';
+import * as ToolsAPI from './tools';
+import * as MedicalAPI from './medical';
+import * as PdfParserAPI from './pdf-parser';
+
+export class Tools extends APIResource {
+ medical: MedicalAPI.Medical = new MedicalAPI.Medical(this._client);
+ pdfParser: PdfParserAPI.PdfParser = new PdfParserAPI.PdfParser(this._client);
+
+ /**
+ * Splits a long block of text (maximum 4000 words) into smaller chunks while
+ * preserving the semantic meaning of the text and context between the chunks.
+ */
+ contextAwareSplitting(
+ body: ToolContextAwareSplittingParams,
+ options?: Core.RequestOptions,
+ ): Core.APIPromise {
+ return this._client.post('/v1/tools/context-aware-splitting', { body, ...options });
+ }
+}
+
+export interface ToolContextAwareSplittingResponse {
+ /**
+ * An array of text chunks generated by splitting the input text based on the
+ * specified strategy.
+ */
+ chunks: Array;
+}
+
+export interface ToolContextAwareSplittingParams {
+ /**
+ * The strategy to be used for splitting the text into chunks. `llm_split` uses the
+ * language model to split the text, `fast_split` uses a fast heuristic-based
+ * approach, and `hybrid_split` combines both strategies.
+ */
+ strategy: 'llm_split' | 'fast_split' | 'hybrid_split';
+
+ /**
+ * The text to be split into chunks.
+ */
+ text: string;
+}
+
+export namespace Tools {
+ export import ToolContextAwareSplittingResponse = ToolsAPI.ToolContextAwareSplittingResponse;
+ export import ToolContextAwareSplittingParams = ToolsAPI.ToolContextAwareSplittingParams;
+ export import Medical = MedicalAPI.Medical;
+ export import MedicalCreateResponse = MedicalAPI.MedicalCreateResponse;
+ export import MedicalCreateParams = MedicalAPI.MedicalCreateParams;
+ export import PdfParser = PdfParserAPI.PdfParser;
+ export import PdfParserParseResponse = PdfParserAPI.PdfParserParseResponse;
+ export import PdfParserParseParams = PdfParserAPI.PdfParserParseParams;
+}
diff --git a/tests/api-resources/tools/medical.test.ts b/tests/api-resources/tools/medical.test.ts
new file mode 100644
index 00000000..06404ec5
--- /dev/null
+++ b/tests/api-resources/tools/medical.test.ts
@@ -0,0 +1,26 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import Writer from 'writer-sdk';
+import { Response } from 'node-fetch';
+
+const client = new Writer({
+ apiKey: 'My API Key',
+ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
+});
+
+describe('resource medical', () => {
+ test('create: only required params', async () => {
+ const responsePromise = client.tools.medical.create({ content: 'content', response_type: 'Entities' });
+ const rawResponse = await responsePromise.asResponse();
+ expect(rawResponse).toBeInstanceOf(Response);
+ const response = await responsePromise;
+ expect(response).not.toBeInstanceOf(Response);
+ const dataAndResponse = await responsePromise.withResponse();
+ expect(dataAndResponse.data).toBe(response);
+ expect(dataAndResponse.response).toBe(rawResponse);
+ });
+
+ test('create: required and optional params', async () => {
+ const response = await client.tools.medical.create({ content: 'content', response_type: 'Entities' });
+ });
+});
diff --git a/tests/api-resources/tools/pdf-parser.test.ts b/tests/api-resources/tools/pdf-parser.test.ts
new file mode 100644
index 00000000..730adae8
--- /dev/null
+++ b/tests/api-resources/tools/pdf-parser.test.ts
@@ -0,0 +1,26 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import Writer from 'writer-sdk';
+import { Response } from 'node-fetch';
+
+const client = new Writer({
+ apiKey: 'My API Key',
+ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
+});
+
+describe('resource pdfParser', () => {
+ test('parse: only required params', async () => {
+ const responsePromise = client.tools.pdfParser.parse('file_id', { format: 'text' });
+ const rawResponse = await responsePromise.asResponse();
+ expect(rawResponse).toBeInstanceOf(Response);
+ const response = await responsePromise;
+ expect(response).not.toBeInstanceOf(Response);
+ const dataAndResponse = await responsePromise.withResponse();
+ expect(dataAndResponse.data).toBe(response);
+ expect(dataAndResponse.response).toBe(rawResponse);
+ });
+
+ test('parse: required and optional params', async () => {
+ const response = await client.tools.pdfParser.parse('file_id', { format: 'text' });
+ });
+});
diff --git a/tests/api-resources/tools/tools.test.ts b/tests/api-resources/tools/tools.test.ts
new file mode 100644
index 00000000..a53849cf
--- /dev/null
+++ b/tests/api-resources/tools/tools.test.ts
@@ -0,0 +1,26 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import Writer from 'writer-sdk';
+import { Response } from 'node-fetch';
+
+const client = new Writer({
+ apiKey: 'My API Key',
+ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
+});
+
+describe('resource tools', () => {
+ test('contextAwareSplitting: only required params', async () => {
+ const responsePromise = client.tools.contextAwareSplitting({ strategy: 'llm_split', text: 'text' });
+ const rawResponse = await responsePromise.asResponse();
+ expect(rawResponse).toBeInstanceOf(Response);
+ const response = await responsePromise;
+ expect(response).not.toBeInstanceOf(Response);
+ const dataAndResponse = await responsePromise.withResponse();
+ expect(dataAndResponse.data).toBe(response);
+ expect(dataAndResponse.response).toBe(rawResponse);
+ });
+
+ test('contextAwareSplitting: required and optional params', async () => {
+ const response = await client.tools.contextAwareSplitting({ strategy: 'llm_split', text: 'text' });
+ });
+});