diff --git a/.stats.yml b/.stats.yml
index a703388b..f9693fc9 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,2 +1,2 @@
-configured_endpoints: 16
+configured_endpoints: 18
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-5d34056e0e749d39a81c92ed4fb221da6ac627cff4cb9edcb6b054fa00abb335.yml
diff --git a/api.md b/api.md
index 5da59a6a..67ee050c 100644
--- a/api.md
+++ b/api.md
@@ -48,6 +48,7 @@ Types:
- GraphCreateResponse
- GraphUpdateResponse
- GraphDeleteResponse
+- GraphQuestionResponse
- GraphRemoveFileFromGraphResponse
Methods:
@@ -58,6 +59,7 @@ Methods:
- client.graphs.list({ ...params }) -> GraphsCursorPage
- client.graphs.delete(graphId) -> GraphDeleteResponse
- client.graphs.addFileToGraph(graphId, { ...params }) -> File
+- client.graphs.question({ ...params }) -> GraphQuestionResponse
- client.graphs.removeFileFromGraph(graphId, fileId) -> GraphRemoveFileFromGraphResponse
# Files
@@ -66,6 +68,7 @@ Types:
- File
- FileDeleteResponse
+- FileRetryResponse
Methods:
@@ -73,4 +76,5 @@ Methods:
- client.files.list({ ...params }) -> FilesCursorPage
- client.files.delete(fileId) -> FileDeleteResponse
- client.files.download(fileId) -> Response
+- client.files.retry({ ...params }) -> unknown
- client.files.upload({ ...params }) -> File
diff --git a/src/index.ts b/src/index.ts
index 08f29e07..9af63a7c 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -215,18 +215,22 @@ export namespace Writer {
export import GraphCreateResponse = API.GraphCreateResponse;
export import GraphUpdateResponse = API.GraphUpdateResponse;
export import GraphDeleteResponse = API.GraphDeleteResponse;
+ export import GraphQuestionResponse = API.GraphQuestionResponse;
export import GraphRemoveFileFromGraphResponse = API.GraphRemoveFileFromGraphResponse;
export import GraphsCursorPage = API.GraphsCursorPage;
export import GraphCreateParams = API.GraphCreateParams;
export import GraphUpdateParams = API.GraphUpdateParams;
export import GraphListParams = API.GraphListParams;
export import GraphAddFileToGraphParams = API.GraphAddFileToGraphParams;
+ export import GraphQuestionParams = API.GraphQuestionParams;
export import Files = API.Files;
export import File = API.File;
export import FileDeleteResponse = API.FileDeleteResponse;
+ export import FileRetryResponse = API.FileRetryResponse;
export import FilesCursorPage = API.FilesCursorPage;
export import FileListParams = API.FileListParams;
+ export import FileRetryParams = API.FileRetryParams;
export import FileUploadParams = API.FileUploadParams;
}
diff --git a/src/resources/files.ts b/src/resources/files.ts
index 68ad33e2..93c23aa2 100644
--- a/src/resources/files.ts
+++ b/src/resources/files.ts
@@ -44,6 +44,13 @@ export class Files extends APIResource {
return this._client.get(`/v1/files/${fileId}/download`, { ...options, __binaryResponse: true });
}
+ /**
+ * Retry failed files
+ */
+ retry(body: FileRetryParams, options?: Core.RequestOptions): Core.APIPromise {
+ return this._client.post('/v1/files/retry', { body, ...options });
+ }
+
/**
* Upload file
*/
@@ -103,6 +110,8 @@ export interface FileDeleteResponse {
deleted: boolean;
}
+export type FileRetryResponse = unknown;
+
export interface FileListParams extends CursorPageParams {
/**
* The unique identifier of the graph to which the files belong.
@@ -128,6 +137,13 @@ export interface FileListParams extends CursorPageParams {
status?: 'in_progress' | 'completed' | 'failed';
}
+export interface FileRetryParams {
+ /**
+ * The unique identifier of the files to be retried.
+ */
+ file_ids: Array;
+}
+
export interface FileUploadParams {
/**
* Body param:
@@ -145,7 +161,9 @@ export interface FileUploadParams {
export namespace Files {
export import File = FilesAPI.File;
export import FileDeleteResponse = FilesAPI.FileDeleteResponse;
+ export import FileRetryResponse = FilesAPI.FileRetryResponse;
export import FilesCursorPage = FilesAPI.FilesCursorPage;
export import FileListParams = FilesAPI.FileListParams;
+ export import FileRetryParams = FilesAPI.FileRetryParams;
export import FileUploadParams = FilesAPI.FileUploadParams;
}
diff --git a/src/resources/graphs.ts b/src/resources/graphs.ts
index 55fd4221..06623ef2 100644
--- a/src/resources/graphs.ts
+++ b/src/resources/graphs.ts
@@ -66,6 +66,13 @@ export class Graphs extends APIResource {
return this._client.post(`/v1/graphs/${graphId}/file`, { body, ...options });
}
+ /**
+ * Knowledge Graph question
+ */
+ question(body: GraphQuestionParams, options?: Core.RequestOptions): Core.APIPromise {
+ return this._client.post('/v1/graphs/question', { body, ...options });
+ }
+
/**
* Remove file from graph
*/
@@ -184,6 +191,64 @@ export interface GraphDeleteResponse {
deleted: boolean;
}
+export interface GraphQuestionResponse {
+ /**
+ * The answer to the question.
+ */
+ answer: string;
+
+ /**
+ * The question that was asked.
+ */
+ question: string;
+
+ sources: Array;
+
+ subqueries?: Array;
+}
+
+export namespace GraphQuestionResponse {
+ export interface Source {
+ /**
+ * The unique identifier of the file.
+ */
+ file_id: string;
+
+ /**
+ * A snippet of text from the source file.
+ */
+ snippet: string;
+ }
+
+ export interface Subquery {
+ /**
+ * The answer to the subquery.
+ */
+ answer: string;
+
+ /**
+ * The subquery that was asked.
+ */
+ query: string;
+
+ sources: Array;
+ }
+
+ export namespace Subquery {
+ export interface Source {
+ /**
+ * The unique identifier of the file.
+ */
+ file_id: string;
+
+ /**
+ * A snippet of text from the source file.
+ */
+ snippet: string;
+ }
+ }
+}
+
export interface GraphRemoveFileFromGraphResponse {
/**
* A unique identifier of the deleted file.
@@ -241,15 +306,41 @@ export interface GraphAddFileToGraphParams {
file_id: string;
}
+export interface GraphQuestionParams {
+ /**
+ * The unique identifiers of the Knowledge Graphs to be queried.
+ */
+ graph_ids: Array;
+
+ /**
+ * The question to be answered using the Knowledge Graph.
+ */
+ question: string;
+
+ /**
+ * Determines whether the model's output should be streamed. If true, the output is
+ * generated and sent incrementally, which can be useful for real-time
+ * applications.
+ */
+ stream: boolean;
+
+ /**
+ * Specify whether to include subqueries.
+ */
+ subqueries: boolean;
+}
+
export namespace Graphs {
export import Graph = GraphsAPI.Graph;
export import GraphCreateResponse = GraphsAPI.GraphCreateResponse;
export import GraphUpdateResponse = GraphsAPI.GraphUpdateResponse;
export import GraphDeleteResponse = GraphsAPI.GraphDeleteResponse;
+ export import GraphQuestionResponse = GraphsAPI.GraphQuestionResponse;
export import GraphRemoveFileFromGraphResponse = GraphsAPI.GraphRemoveFileFromGraphResponse;
export import GraphsCursorPage = GraphsAPI.GraphsCursorPage;
export import GraphCreateParams = GraphsAPI.GraphCreateParams;
export import GraphUpdateParams = GraphsAPI.GraphUpdateParams;
export import GraphListParams = GraphsAPI.GraphListParams;
export import GraphAddFileToGraphParams = GraphsAPI.GraphAddFileToGraphParams;
+ export import GraphQuestionParams = GraphsAPI.GraphQuestionParams;
}
diff --git a/src/resources/index.ts b/src/resources/index.ts
index ac91c1c8..159f4511 100644
--- a/src/resources/index.ts
+++ b/src/resources/index.ts
@@ -21,17 +21,28 @@ export {
CompletionCreateParamsStreaming,
Completions,
} from './completions';
-export { File, FileDeleteResponse, FileListParams, FileUploadParams, FilesCursorPage, Files } from './files';
+export {
+ File,
+ FileDeleteResponse,
+ FileRetryResponse,
+ FileListParams,
+ FileRetryParams,
+ FileUploadParams,
+ FilesCursorPage,
+ Files,
+} from './files';
export {
Graph,
GraphCreateResponse,
GraphUpdateResponse,
GraphDeleteResponse,
+ GraphQuestionResponse,
GraphRemoveFileFromGraphResponse,
GraphCreateParams,
GraphUpdateParams,
GraphListParams,
GraphAddFileToGraphParams,
+ GraphQuestionParams,
GraphsCursorPage,
Graphs,
} from './graphs';
diff --git a/tests/api-resources/files.test.ts b/tests/api-resources/files.test.ts
index 960e0582..70a1413d 100644
--- a/tests/api-resources/files.test.ts
+++ b/tests/api-resources/files.test.ts
@@ -88,6 +88,33 @@ describe('resource files', () => {
);
});
+ test('retry: only required params', async () => {
+ const responsePromise = client.files.retry({
+ file_ids: [
+ '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
+ '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
+ '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
+ ],
+ });
+ 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('retry: required and optional params', async () => {
+ const response = await client.files.retry({
+ file_ids: [
+ '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
+ '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
+ '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
+ ],
+ });
+ });
+
// requests with binary data not yet supported in test environment
test.skip('upload: only required params', async () => {
const responsePromise = client.files.upload({
diff --git a/tests/api-resources/graphs.test.ts b/tests/api-resources/graphs.test.ts
index 29d8fc62..2f2e8354 100644
--- a/tests/api-resources/graphs.test.ts
+++ b/tests/api-resources/graphs.test.ts
@@ -119,6 +119,31 @@ describe('resource graphs', () => {
});
});
+ test('question: only required params', async () => {
+ const responsePromise = client.graphs.question({
+ graph_ids: ['182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'],
+ question: 'question',
+ stream: true,
+ subqueries: true,
+ });
+ 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('question: required and optional params', async () => {
+ const response = await client.graphs.question({
+ graph_ids: ['182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'],
+ question: 'question',
+ stream: true,
+ subqueries: true,
+ });
+ });
+
test('removeFileFromGraph', async () => {
const responsePromise = client.graphs.removeFileFromGraph(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',