graphor 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/LICENSE +1 -1
- package/client.d.mts +9 -9
- package/client.d.mts.map +1 -1
- package/client.d.ts +9 -9
- package/client.d.ts.map +1 -1
- package/client.js +34 -34
- package/client.js.map +1 -1
- package/client.mjs +32 -32
- package/client.mjs.map +1 -1
- package/core/api-promise.d.mts +2 -2
- package/core/api-promise.d.mts.map +1 -1
- package/core/api-promise.d.ts +2 -2
- package/core/api-promise.d.ts.map +1 -1
- package/core/api-promise.js.map +1 -1
- package/core/api-promise.mjs.map +1 -1
- package/core/error.d.mts +2 -2
- package/core/error.d.mts.map +1 -1
- package/core/error.d.ts +2 -2
- package/core/error.d.ts.map +1 -1
- package/core/error.js +4 -4
- package/core/error.js.map +1 -1
- package/core/error.mjs +2 -2
- package/core/error.mjs.map +1 -1
- package/core/resource.d.mts +3 -3
- package/core/resource.d.mts.map +1 -1
- package/core/resource.d.ts +3 -3
- package/core/resource.d.ts.map +1 -1
- package/core/resource.js.map +1 -1
- package/core/resource.mjs.map +1 -1
- package/index.d.mts +3 -3
- package/index.d.mts.map +1 -1
- package/index.d.ts +3 -3
- package/index.d.ts.map +1 -1
- package/index.js +4 -4
- package/index.js.map +1 -1
- package/index.mjs +3 -3
- package/index.mjs.map +1 -1
- package/internal/parse.d.mts +2 -2
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts +2 -2
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs.map +1 -1
- package/internal/shims.js +1 -1
- package/internal/shims.js.map +1 -1
- package/internal/shims.mjs +1 -1
- package/internal/shims.mjs.map +1 -1
- package/internal/uploads.d.mts +4 -4
- package/internal/uploads.d.mts.map +1 -1
- package/internal/uploads.d.ts +4 -4
- package/internal/uploads.d.ts.map +1 -1
- package/internal/uploads.js.map +1 -1
- package/internal/uploads.mjs.map +1 -1
- package/internal/utils/base64.js +2 -2
- package/internal/utils/base64.js.map +1 -1
- package/internal/utils/base64.mjs +3 -3
- package/internal/utils/base64.mjs.map +1 -1
- package/internal/utils/log.d.mts +3 -3
- package/internal/utils/log.d.mts.map +1 -1
- package/internal/utils/log.d.ts +3 -3
- package/internal/utils/log.d.ts.map +1 -1
- package/internal/utils/log.js.map +1 -1
- package/internal/utils/log.mjs.map +1 -1
- package/internal/utils/path.js +1 -1
- package/internal/utils/path.js.map +1 -1
- package/internal/utils/path.mjs +2 -2
- package/internal/utils/path.mjs.map +1 -1
- package/internal/utils/values.js +5 -5
- package/internal/utils/values.js.map +1 -1
- package/internal/utils/values.mjs +6 -6
- package/internal/utils/values.mjs.map +1 -1
- package/package.json +3 -3
- package/resources/sources.d.mts +418 -60
- package/resources/sources.d.mts.map +1 -1
- package/resources/sources.d.ts +418 -60
- package/resources/sources.d.ts.map +1 -1
- package/resources/sources.js +348 -19
- package/resources/sources.js.map +1 -1
- package/resources/sources.mjs +348 -19
- package/resources/sources.mjs.map +1 -1
- package/src/client.ts +16 -16
- package/src/core/api-promise.ts +4 -4
- package/src/core/error.ts +2 -2
- package/src/core/resource.ts +3 -3
- package/src/index.ts +3 -3
- package/src/internal/parse.ts +2 -2
- package/src/internal/shims.ts +1 -1
- package/src/internal/uploads.ts +5 -5
- package/src/internal/utils/base64.ts +3 -3
- package/src/internal/utils/log.ts +3 -3
- package/src/internal/utils/path.ts +2 -2
- package/src/internal/utils/values.ts +6 -6
- package/src/resources/sources.ts +418 -60
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/resources/sources.d.ts
CHANGED
|
@@ -4,59 +4,388 @@ import { type Uploadable } from "../core/uploads.js";
|
|
|
4
4
|
import { RequestOptions } from "../internal/request-options.js";
|
|
5
5
|
export declare class Sources extends APIResource {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* List all sources in the project's knowledge graph.
|
|
8
|
+
*
|
|
9
|
+
* Returns every source node currently stored in the knowledge graph for the
|
|
10
|
+
* authenticated project. Each item includes the file metadata (ID, name, size,
|
|
11
|
+
* type, origin) along with its current processing status and a human-readable
|
|
12
|
+
* status message.
|
|
13
|
+
*
|
|
14
|
+
* **Status messages returned per source:**
|
|
15
|
+
*
|
|
16
|
+
* - `"completed"` → _"Source processed successfully"_
|
|
17
|
+
* - `"processing"` → _"Source is being processed"_
|
|
18
|
+
* - `"failed"` → _"Source processing failed"_
|
|
19
|
+
* - `"new"` → _"Source uploaded, awaiting processing"_
|
|
20
|
+
*
|
|
21
|
+
* **Returns** a JSON array of `PublicSourceResponse` objects.
|
|
22
|
+
*
|
|
23
|
+
* **Error responses:**
|
|
24
|
+
*
|
|
25
|
+
* - `500` — Unexpected internal error while retrieving sources.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const publicSources = await client.sources.list();
|
|
30
|
+
* ```
|
|
8
31
|
*/
|
|
9
32
|
list(options?: RequestOptions): APIPromise<SourceListResponse>;
|
|
10
33
|
/**
|
|
11
|
-
* Delete a source from the project
|
|
34
|
+
* Delete a source from the project's knowledge graph and all associated data.
|
|
35
|
+
*
|
|
36
|
+
* Removes the source node, its partitions/chunks, embeddings, and any stored files
|
|
37
|
+
* from the knowledge graph and object storage. The operation is irreversible.
|
|
38
|
+
*
|
|
39
|
+
* **Parameters (JSON body):**
|
|
40
|
+
*
|
|
41
|
+
* - **file_id** (str, optional — preferred): The unique identifier of the source
|
|
42
|
+
* to delete.
|
|
43
|
+
* - **file_name** (str, optional — deprecated): The display name of the source.
|
|
44
|
+
* Use `file_id` instead when possible. At least one of `file_id` or `file_name`
|
|
45
|
+
* must be provided.
|
|
46
|
+
*
|
|
47
|
+
* **Returns** a `PublicDeleteSourceResponse` with the deletion status, file ID,
|
|
48
|
+
* file name, project ID, and project name.
|
|
49
|
+
*
|
|
50
|
+
* **Error responses:**
|
|
51
|
+
*
|
|
52
|
+
* - `400` — Invalid input (e.g. neither identifier provided).
|
|
53
|
+
* - `403` — Permission denied.
|
|
54
|
+
* - `404` — Source not found.
|
|
55
|
+
* - `500` — Unexpected internal error.
|
|
12
56
|
*
|
|
13
|
-
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const source = await client.sources.delete();
|
|
60
|
+
* ```
|
|
14
61
|
*/
|
|
15
62
|
delete(body: SourceDeleteParams, options?: RequestOptions): APIPromise<SourceDeleteResponse>;
|
|
16
63
|
/**
|
|
17
|
-
*
|
|
64
|
+
* Ask a natural-language question grounded on the project's ingested sources.
|
|
65
|
+
*
|
|
66
|
+
* This is the primary Q&A endpoint. It sends the question through the GenAI File
|
|
67
|
+
* Search pipeline, which retrieves relevant chunks from the knowledge graph,
|
|
68
|
+
* grounds the answer in the source documents, and returns a natural-language
|
|
69
|
+
* response. Optionally, you can request a structured JSON output by supplying an
|
|
70
|
+
* `output_schema`.
|
|
71
|
+
*
|
|
72
|
+
* Conversation memory is supported: pass a `conversation_id` to continue an
|
|
73
|
+
* existing conversation, or set `reset` to `true` to start fresh.
|
|
74
|
+
*
|
|
75
|
+
* **Parameters (JSON body):**
|
|
76
|
+
*
|
|
77
|
+
* - **question** (str, required): The question to ask about the sources.
|
|
78
|
+
* - **conversation_id** (str, optional): An existing conversation identifier to
|
|
79
|
+
* maintain context across multiple turns.
|
|
80
|
+
* - **reset** (bool, optional, default `false`): When `true`, starts a new
|
|
81
|
+
* conversation discarding any previous history.
|
|
82
|
+
* - **file_ids** (list[str], optional — preferred): Restrict the search scope to
|
|
83
|
+
* specific source file IDs.
|
|
84
|
+
* - **file_names** (list[str], optional — deprecated): Restrict the search scope
|
|
85
|
+
* to specific source file names. Use `file_ids` when possible.
|
|
86
|
+
* - **output_schema** (dict, optional): A JSON Schema for requesting structured
|
|
87
|
+
* output. When provided, the response includes a `structured_output` field
|
|
88
|
+
* validated against this schema and the `raw_json` produced by the model.
|
|
89
|
+
* - **thinking_level** (str, optional, default `"accurate"`): Controls the
|
|
90
|
+
* model/thinking budget — one of `"fast"`, `"balanced"`, or `"accurate"`.
|
|
91
|
+
*
|
|
92
|
+
* **Returns** a `PublicAskSourcesResponse` containing:
|
|
93
|
+
*
|
|
94
|
+
* - `answer` — the natural-language answer (or a status message when
|
|
95
|
+
* `output_schema` is provided).
|
|
96
|
+
* - `structured_output` — the validated structured object (when `output_schema` is
|
|
97
|
+
* provided).
|
|
98
|
+
* - `raw_json` — the raw JSON text before validation (when `output_schema` is
|
|
99
|
+
* provided).
|
|
100
|
+
* - `conversation_id` — the conversation identifier for follow-up questions.
|
|
101
|
+
*
|
|
102
|
+
* **Error responses:**
|
|
103
|
+
*
|
|
104
|
+
* - `500` — Unexpected internal error while asking sources.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* const response = await client.sources.ask({
|
|
109
|
+
* question: 'question',
|
|
110
|
+
* });
|
|
111
|
+
* ```
|
|
18
112
|
*/
|
|
19
113
|
ask(body: SourceAskParams, options?: RequestOptions): APIPromise<SourceAskResponse>;
|
|
20
114
|
/**
|
|
21
|
-
* Run a one-off
|
|
115
|
+
* Run a one-off structured data extraction against one or more sources.
|
|
116
|
+
*
|
|
117
|
+
* This endpoint uses the GenAI File Search pipeline to read the specified sources,
|
|
118
|
+
* apply the user-provided instruction, and return structured JSON output
|
|
119
|
+
* conforming to the supplied `output_schema`. Internally it builds a grounded
|
|
120
|
+
* prompt, queries the model, and validates/corrects the raw JSON against the
|
|
121
|
+
* schema.
|
|
122
|
+
*
|
|
123
|
+
* **Parameters (JSON body):**
|
|
124
|
+
*
|
|
125
|
+
* - **file_ids** (list[str], optional — preferred): List of source file IDs to
|
|
126
|
+
* extract from.
|
|
127
|
+
* - **file_names** (list[str], optional — deprecated): List of source file names
|
|
128
|
+
* to extract from. Use `file_ids` when possible. At least one of the two lists
|
|
129
|
+
* must be provided and non-empty.
|
|
130
|
+
* - **user_instruction** (str, required): A natural-language instruction that
|
|
131
|
+
* guides what information to extract from the documents.
|
|
132
|
+
* - **output_schema** (dict, required): A JSON Schema object describing the
|
|
133
|
+
* desired structured output shape. The model will produce data conforming to
|
|
134
|
+
* this schema.
|
|
135
|
+
* - **thinking_level** (str, optional, default `"accurate"`): Controls the
|
|
136
|
+
* model/thinking budget — one of `"fast"`, `"balanced"`, or `"accurate"`.
|
|
137
|
+
*
|
|
138
|
+
* **Returns** a `PublicRunExtractionResultResponse` containing:
|
|
139
|
+
*
|
|
140
|
+
* - `structured_output` — the validated structured object.
|
|
141
|
+
* - `raw_json` — the raw JSON text produced by the model before validation.
|
|
142
|
+
*
|
|
143
|
+
* **Error responses:**
|
|
144
|
+
*
|
|
145
|
+
* - `500` — Unexpected internal error during extraction.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```ts
|
|
149
|
+
* const response = await client.sources.extract({
|
|
150
|
+
* output_schema: { foo: 'bar' },
|
|
151
|
+
* user_instruction: 'user_instruction',
|
|
152
|
+
* });
|
|
153
|
+
* ```
|
|
22
154
|
*/
|
|
23
155
|
extract(body: SourceExtractParams, options?: RequestOptions): APIPromise<SourceExtractResponse>;
|
|
24
156
|
/**
|
|
25
|
-
*
|
|
157
|
+
* Retrieve the parsed elements (chunks/partitions) of a specific source with
|
|
158
|
+
* pagination.
|
|
159
|
+
*
|
|
160
|
+
* Returns the individual document partitions (text chunks) that were generated
|
|
161
|
+
* during ingestion for a given source. This is useful for inspecting how a file
|
|
162
|
+
* was segmented, reviewing chunk content, or building custom retrieval logic on
|
|
163
|
+
* top of the raw partitions.
|
|
164
|
+
*
|
|
165
|
+
* **Parameters (JSON body):**
|
|
166
|
+
*
|
|
167
|
+
* - **file_id** (str, optional — preferred): The unique identifier of the source
|
|
168
|
+
* whose elements to retrieve.
|
|
169
|
+
* - **file_name** (str, optional — deprecated): The display name of the source.
|
|
170
|
+
* Use `file_id` when possible. At least one of `file_id` or `file_name` must be
|
|
171
|
+
* provided.
|
|
172
|
+
* - **page** (int, optional): The 1-based page number for pagination.
|
|
173
|
+
* - **page_size** (int, optional): The number of elements per page. Both `page`
|
|
174
|
+
* and `page_size` must be provided together to enable pagination.
|
|
175
|
+
* - **filter** (object, optional): An optional filter object with:
|
|
176
|
+
* - `type` — filter by element type.
|
|
177
|
+
* - `page_numbers` — restrict to specific source page numbers.
|
|
178
|
+
* - `elementsToRemove` — list of element types to exclude.
|
|
179
|
+
*
|
|
180
|
+
* **Returns** a `PaginatedResponse[Document]` containing:
|
|
181
|
+
*
|
|
182
|
+
* - `items` — list of `Document` objects (LangChain format) with `page_content`
|
|
183
|
+
* and `metadata`.
|
|
184
|
+
* - `total` — total number of matching elements.
|
|
185
|
+
* - `page`, `page_size`, `total_pages` — pagination metadata.
|
|
186
|
+
*
|
|
187
|
+
* **Error responses:**
|
|
188
|
+
*
|
|
189
|
+
* - `400` — Invalid input (e.g. neither identifier provided).
|
|
190
|
+
* - `404` — Source file not found.
|
|
191
|
+
* - `500` — Unexpected internal error.
|
|
26
192
|
*
|
|
27
|
-
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* const response = await client.sources.loadElements();
|
|
196
|
+
* ```
|
|
28
197
|
*/
|
|
29
198
|
loadElements(body: SourceLoadElementsParams, options?: RequestOptions): APIPromise<SourceLoadElementsResponse>;
|
|
30
199
|
/**
|
|
31
|
-
*
|
|
200
|
+
* Re-process (re-parse) an existing source that has already been uploaded.
|
|
32
201
|
*
|
|
33
|
-
*
|
|
202
|
+
* Use this endpoint to re-run the data-ingestion pipeline on a source that is
|
|
203
|
+
* already present in the knowledge graph — for example, after changing the
|
|
204
|
+
* partitioning strategy. The endpoint locates the source node, sets its status to
|
|
205
|
+
* `PROCESSING`, applies the requested partition method, and executes the full
|
|
206
|
+
* ingestion pipeline synchronously (partitioning, chunking, embedding, and graph
|
|
207
|
+
* persistence).
|
|
208
|
+
*
|
|
209
|
+
* **Parameters (JSON body):**
|
|
210
|
+
*
|
|
211
|
+
* - **file_id** (str, optional — preferred): The unique identifier of the source
|
|
212
|
+
* to re-process.
|
|
213
|
+
* - **file_name** (str, optional — deprecated): The display name of the source.
|
|
214
|
+
* Use `file_id` instead when possible. At least one of `file_id` or `file_name`
|
|
215
|
+
* must be provided.
|
|
216
|
+
* - **partition_method** (str, default `"basic"`): The partitioning strategy to
|
|
217
|
+
* apply (e.g. `"basic"`, `"hi_res"`, `"fast"`).
|
|
218
|
+
*
|
|
219
|
+
* **Returns** a `PublicSourceResponse` with the updated source metadata.
|
|
220
|
+
*
|
|
221
|
+
* **Error responses:**
|
|
222
|
+
*
|
|
223
|
+
* - `404` — Source node not found for the given identifier.
|
|
224
|
+
* - `500` — Processing or unexpected internal error.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```ts
|
|
228
|
+
* const publicSource = await client.sources.parse();
|
|
229
|
+
* ```
|
|
34
230
|
*/
|
|
35
231
|
parse(body: SourceParseParams, options?: RequestOptions): APIPromise<PublicSource>;
|
|
36
232
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
233
|
+
* Retrieve relevant document chunks from the prebuilt RAG vector store.
|
|
234
|
+
*
|
|
235
|
+
* Performs a semantic similarity search over the project's prebuilt RAG store
|
|
236
|
+
* using Google File Search with grounding. Returns the most relevant text chunks
|
|
237
|
+
* along with their source metadata (file name, page number, relevance score). This
|
|
238
|
+
* is a pure retrieval endpoint — it does **not** generate an answer; use
|
|
239
|
+
* `/ask-sources` for Q&A.
|
|
240
|
+
*
|
|
241
|
+
* **Parameters (JSON body):**
|
|
242
|
+
*
|
|
243
|
+
* - **query** (str, required): The natural-language search query used to find
|
|
244
|
+
* relevant chunks.
|
|
245
|
+
* - **file_ids** (list[str], optional — preferred): Restrict retrieval to specific
|
|
246
|
+
* source file IDs.
|
|
247
|
+
* - **file_names** (list[str], optional — deprecated): Restrict retrieval to
|
|
248
|
+
* specific source file names. Use `file_ids` when possible.
|
|
249
|
+
*
|
|
250
|
+
* **Returns** a `PublicRetrieveResponse` containing:
|
|
251
|
+
*
|
|
252
|
+
* - `query` — the original search query.
|
|
253
|
+
* - `chunks` — a list of `PublicRetrieveChunk` objects, each with `text`,
|
|
254
|
+
* `file_name`, `page_number`, `score`, and additional `metadata`.
|
|
255
|
+
* - `total` — the total number of chunks returned.
|
|
256
|
+
*
|
|
257
|
+
* **Error responses:**
|
|
39
258
|
*
|
|
40
|
-
*
|
|
259
|
+
* - `500` — Unexpected internal error during retrieval.
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```ts
|
|
263
|
+
* const response = await client.sources.retrieveChunks({
|
|
264
|
+
* query: 'query',
|
|
265
|
+
* });
|
|
266
|
+
* ```
|
|
41
267
|
*/
|
|
42
268
|
retrieveChunks(body: SourceRetrieveChunksParams, options?: RequestOptions): APIPromise<SourceRetrieveChunksResponse>;
|
|
43
269
|
/**
|
|
44
|
-
* Upload
|
|
270
|
+
* Upload a local file and ingest it as a source into the project's knowledge
|
|
271
|
+
* graph.
|
|
272
|
+
*
|
|
273
|
+
* This endpoint accepts a multipart file upload, validates the file size (max 100
|
|
274
|
+
* MB) and extension against the list of allowed ingestion types, stores the file,
|
|
275
|
+
* and then runs the full data-ingestion pipeline synchronously — including
|
|
276
|
+
* partitioning, chunking, embedding, and graph persistence.
|
|
277
|
+
*
|
|
278
|
+
* **Parameters:**
|
|
279
|
+
*
|
|
280
|
+
* - **file** (multipart): The file to upload. Must include a `Content-Length`
|
|
281
|
+
* header and have a supported extension (e.g. pdf, docx, txt, csv, etc.).
|
|
282
|
+
* - **partition_method** (form, optional): The partitioning strategy to apply to
|
|
283
|
+
* the document. When omitted the system default is used.
|
|
284
|
+
*
|
|
285
|
+
* **Returns** a `PublicSourceResponse` with the resulting source metadata (file
|
|
286
|
+
* ID, name, size, type, source origin, partition method, and processing status).
|
|
287
|
+
*
|
|
288
|
+
* **Error responses:**
|
|
289
|
+
*
|
|
290
|
+
* - `400` — Unsupported file type or missing file name.
|
|
291
|
+
* - `411` — Missing `Content-Length` header (file size cannot be determined).
|
|
292
|
+
* - `413` — File exceeds the 100 MB size limit.
|
|
293
|
+
* - `403` — Permission denied.
|
|
294
|
+
* - `404` — File not found during processing.
|
|
295
|
+
* - `500` — Unexpected internal error.
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```ts
|
|
299
|
+
* const publicSource = await client.sources.upload({
|
|
300
|
+
* file: fs.createReadStream('path/to/file'),
|
|
301
|
+
* });
|
|
302
|
+
* ```
|
|
45
303
|
*/
|
|
46
304
|
upload(body: SourceUploadParams, options?: RequestOptions): APIPromise<PublicSource>;
|
|
47
305
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
306
|
+
* Ingest a GitHub repository as a source into the project's knowledge graph.
|
|
307
|
+
*
|
|
308
|
+
* The endpoint clones or fetches the repository at the given URL, extracts its
|
|
309
|
+
* text-based files, partitions them using the system default method, generates
|
|
310
|
+
* embeddings, and persists everything in the knowledge graph synchronously.
|
|
311
|
+
*
|
|
312
|
+
* **Parameters (JSON body):**
|
|
313
|
+
*
|
|
314
|
+
* - **url** (str, required): The GitHub repository URL to ingest (e.g.
|
|
315
|
+
* `https://github.com/owner/repo`).
|
|
316
|
+
*
|
|
317
|
+
* **Returns** a `PublicSourceResponse` with the resulting source metadata (file
|
|
318
|
+
* ID, name, size, type, source origin, partition method, and processing status).
|
|
319
|
+
*
|
|
320
|
+
* **Error responses:**
|
|
321
|
+
*
|
|
322
|
+
* - `500` — Unexpected internal error during GitHub source processing.
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```ts
|
|
326
|
+
* const publicSource = await client.sources.uploadGitHub({
|
|
327
|
+
* url: 'url',
|
|
328
|
+
* });
|
|
329
|
+
* ```
|
|
50
330
|
*/
|
|
51
331
|
uploadGitHub(body: SourceUploadGitHubParams, options?: RequestOptions): APIPromise<PublicSource>;
|
|
52
332
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
333
|
+
* Ingest a web page (or a set of crawled pages) as a source into the project's
|
|
334
|
+
* knowledge graph.
|
|
335
|
+
*
|
|
336
|
+
* The endpoint fetches the content at the given URL, optionally crawls linked
|
|
337
|
+
* pages (when `crawlUrls` is `true`), partitions the resulting HTML/text,
|
|
338
|
+
* generates embeddings, and persists everything in the knowledge graph
|
|
339
|
+
* synchronously.
|
|
340
|
+
*
|
|
341
|
+
* **Parameters (JSON body):**
|
|
342
|
+
*
|
|
343
|
+
* - **url** (str, required): The web page URL to ingest.
|
|
344
|
+
* - **crawlUrls** (bool, optional, default `false`): When `true`, the system will
|
|
345
|
+
* also follow and ingest links found on the page.
|
|
346
|
+
* - **partition_method** (str, optional): The partitioning strategy to use. When
|
|
347
|
+
* omitted the system default is applied.
|
|
348
|
+
*
|
|
349
|
+
* **Returns** a `PublicSourceResponse` with the resulting source metadata (file
|
|
350
|
+
* ID, name, size, type, source origin, partition method, and processing status).
|
|
351
|
+
*
|
|
352
|
+
* **Error responses:**
|
|
353
|
+
*
|
|
354
|
+
* - `500` — Unexpected internal error during URL processing.
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* ```ts
|
|
358
|
+
* const publicSource = await client.sources.uploadURL({
|
|
359
|
+
* url: 'url',
|
|
360
|
+
* });
|
|
361
|
+
* ```
|
|
55
362
|
*/
|
|
56
363
|
uploadURL(body: SourceUploadURLParams, options?: RequestOptions): APIPromise<PublicSource>;
|
|
57
364
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
365
|
+
* Ingest a YouTube video as a source into the project's knowledge graph.
|
|
366
|
+
*
|
|
367
|
+
* The endpoint downloads the transcript/captions of the given YouTube video,
|
|
368
|
+
* partitions the text using the system default method, generates embeddings, and
|
|
369
|
+
* persists everything in the knowledge graph synchronously.
|
|
370
|
+
*
|
|
371
|
+
* **Parameters (JSON body):**
|
|
372
|
+
*
|
|
373
|
+
* - **url** (str, required): The YouTube video URL to ingest (e.g.
|
|
374
|
+
* `https://www.youtube.com/watch?v=...`).
|
|
375
|
+
*
|
|
376
|
+
* **Returns** a `PublicSourceResponse` with the resulting source metadata (file
|
|
377
|
+
* ID, name, size, type, source origin, partition method, and processing status).
|
|
378
|
+
*
|
|
379
|
+
* **Error responses:**
|
|
380
|
+
*
|
|
381
|
+
* - `500` — Unexpected internal error during YouTube source processing.
|
|
382
|
+
*
|
|
383
|
+
* @example
|
|
384
|
+
* ```ts
|
|
385
|
+
* const publicSource = await client.sources.uploadYoutube({
|
|
386
|
+
* url: 'url',
|
|
387
|
+
* });
|
|
388
|
+
* ```
|
|
60
389
|
*/
|
|
61
390
|
uploadYoutube(body: SourceUploadYoutubeParams, options?: RequestOptions): APIPromise<PublicSource>;
|
|
62
391
|
}
|
|
@@ -65,44 +394,72 @@ export declare class Sources extends APIResource {
|
|
|
65
394
|
*/
|
|
66
395
|
export type PublicPartitionMethod = 'basic' | 'hi_res' | 'hi_res_ft' | 'mai' | 'graphorlm';
|
|
67
396
|
export interface PublicSource {
|
|
397
|
+
/**
|
|
398
|
+
* Display name of the source file
|
|
399
|
+
*/
|
|
68
400
|
file_name: string;
|
|
401
|
+
/**
|
|
402
|
+
* File size in bytes
|
|
403
|
+
*/
|
|
69
404
|
file_size: number;
|
|
405
|
+
/**
|
|
406
|
+
* Origin of the file (e.g. local_file, url, github, youtube)
|
|
407
|
+
*/
|
|
70
408
|
file_source: string;
|
|
409
|
+
/**
|
|
410
|
+
* File extension / type (e.g. pdf, docx, txt)
|
|
411
|
+
*/
|
|
71
412
|
file_type: string;
|
|
413
|
+
/**
|
|
414
|
+
* Human-readable status message
|
|
415
|
+
*/
|
|
72
416
|
message: string;
|
|
417
|
+
/**
|
|
418
|
+
* UUID of the project this source belongs to
|
|
419
|
+
*/
|
|
73
420
|
project_id: string;
|
|
421
|
+
/**
|
|
422
|
+
* Display name of the project
|
|
423
|
+
*/
|
|
74
424
|
project_name: string;
|
|
425
|
+
/**
|
|
426
|
+
* Current processing status of the source (e.g. completed, processing, failed,
|
|
427
|
+
* new)
|
|
428
|
+
*/
|
|
75
429
|
status: string;
|
|
76
430
|
/**
|
|
77
431
|
* Unique identifier for the source
|
|
78
432
|
*/
|
|
79
433
|
file_id?: string | null;
|
|
434
|
+
/**
|
|
435
|
+
* Partitioning strategy used during ingestion
|
|
436
|
+
*/
|
|
80
437
|
partition_method?: 'basic' | 'hi_res' | 'hi_res_ft' | 'mai' | 'graphorlm' | 'ocr' | 'advanced' | 'yolox' | null;
|
|
81
438
|
}
|
|
82
439
|
export type SourceListResponse = Array<PublicSource>;
|
|
83
440
|
export interface SourceDeleteResponse {
|
|
84
441
|
/**
|
|
85
|
-
*
|
|
442
|
+
* Display name of the deleted file
|
|
86
443
|
*/
|
|
87
444
|
file_name: string;
|
|
88
445
|
/**
|
|
89
|
-
*
|
|
446
|
+
* Human-readable result message
|
|
90
447
|
*/
|
|
91
448
|
message: string;
|
|
92
449
|
/**
|
|
93
|
-
*
|
|
450
|
+
* UUID of the project
|
|
94
451
|
*/
|
|
95
452
|
project_id: string;
|
|
96
453
|
/**
|
|
97
|
-
*
|
|
454
|
+
* Display name of the project
|
|
98
455
|
*/
|
|
99
456
|
project_name: string;
|
|
100
457
|
/**
|
|
101
|
-
*
|
|
458
|
+
* Result status of the deletion (e.g. 'success')
|
|
102
459
|
*/
|
|
103
460
|
status: string;
|
|
104
461
|
/**
|
|
105
|
-
* Unique identifier
|
|
462
|
+
* Unique identifier of the deleted source
|
|
106
463
|
*/
|
|
107
464
|
file_id?: string | null;
|
|
108
465
|
}
|
|
@@ -110,7 +467,7 @@ export interface SourceAskResponse {
|
|
|
110
467
|
/**
|
|
111
468
|
* The answer to the question. When output_schema is provided, this will be a short
|
|
112
469
|
* status message and the structured data will be in structured_output (and the raw
|
|
113
|
-
* JSON-text
|
|
470
|
+
* JSON-text in raw_json).
|
|
114
471
|
*/
|
|
115
472
|
answer: string;
|
|
116
473
|
/**
|
|
@@ -206,7 +563,7 @@ export interface SourceRetrieveChunksResponse {
|
|
|
206
563
|
*/
|
|
207
564
|
total: number;
|
|
208
565
|
/**
|
|
209
|
-
* List of retrieved chunks
|
|
566
|
+
* List of retrieved chunks ordered by relevance
|
|
210
567
|
*/
|
|
211
568
|
chunks?: Array<SourceRetrieveChunksResponse.Chunk>;
|
|
212
569
|
}
|
|
@@ -225,17 +582,17 @@ export declare namespace SourceRetrieveChunksResponse {
|
|
|
225
582
|
*/
|
|
226
583
|
file_name?: string | null;
|
|
227
584
|
/**
|
|
228
|
-
* Additional metadata for the chunk
|
|
585
|
+
* Additional metadata for the chunk (e.g. element type, coordinates)
|
|
229
586
|
*/
|
|
230
587
|
metadata?: {
|
|
231
588
|
[key: string]: unknown;
|
|
232
589
|
} | null;
|
|
233
590
|
/**
|
|
234
|
-
* The page number
|
|
591
|
+
* The page number where this chunk appears in the original document
|
|
235
592
|
*/
|
|
236
593
|
page_number?: number | null;
|
|
237
594
|
/**
|
|
238
|
-
*
|
|
595
|
+
* Relevance score between 0 and 1 (higher is more relevant)
|
|
239
596
|
*/
|
|
240
597
|
score?: number | null;
|
|
241
598
|
}
|
|
@@ -252,50 +609,50 @@ export interface SourceDeleteParams {
|
|
|
252
609
|
}
|
|
253
610
|
export interface SourceAskParams {
|
|
254
611
|
/**
|
|
255
|
-
* The question to ask about the sources
|
|
612
|
+
* The natural-language question to ask about the sources
|
|
256
613
|
*/
|
|
257
614
|
question: string;
|
|
258
615
|
/**
|
|
259
|
-
* Conversation identifier to maintain memory context
|
|
616
|
+
* Conversation identifier to maintain memory context across multiple turns
|
|
260
617
|
*/
|
|
261
618
|
conversation_id?: string | null;
|
|
262
619
|
/**
|
|
263
|
-
* Optional list of file IDs to restrict search
|
|
264
|
-
* (preferred)
|
|
620
|
+
* Optional list of file IDs to restrict search scope (preferred)
|
|
265
621
|
*/
|
|
266
622
|
file_ids?: Array<string> | null;
|
|
267
623
|
/**
|
|
268
|
-
* Optional list of file display names to restrict search
|
|
269
|
-
*
|
|
624
|
+
* Optional list of file display names to restrict search scope (deprecated, use
|
|
625
|
+
* file_ids)
|
|
270
626
|
*/
|
|
271
627
|
file_names?: Array<string> | null;
|
|
272
628
|
/**
|
|
273
|
-
* Optional JSON Schema
|
|
274
|
-
*
|
|
275
|
-
*
|
|
629
|
+
* Optional JSON Schema for requesting structured output. When provided, the answer
|
|
630
|
+
* field will contain a short status message and the structured data will be in
|
|
631
|
+
* structured_output.
|
|
276
632
|
*/
|
|
277
633
|
output_schema?: {
|
|
278
634
|
[key: string]: unknown;
|
|
279
635
|
} | null;
|
|
280
636
|
/**
|
|
281
|
-
* When true, starts a new conversation
|
|
637
|
+
* When true, starts a new conversation discarding any previous history
|
|
282
638
|
*/
|
|
283
639
|
reset?: boolean | null;
|
|
284
640
|
/**
|
|
285
|
-
* Controls model and thinking
|
|
641
|
+
* Controls model and thinking budget: 'fast' (cheapest/fastest), 'balanced', or
|
|
642
|
+
* 'accurate' (most thorough)
|
|
286
643
|
*/
|
|
287
644
|
thinking_level?: 'fast' | 'balanced' | 'accurate' | null;
|
|
288
645
|
}
|
|
289
646
|
export interface SourceExtractParams {
|
|
290
647
|
/**
|
|
291
|
-
* JSON Schema
|
|
292
|
-
*
|
|
648
|
+
* JSON Schema describing the desired structured output shape. The model will
|
|
649
|
+
* produce data conforming to this schema.
|
|
293
650
|
*/
|
|
294
651
|
output_schema: {
|
|
295
652
|
[key: string]: unknown;
|
|
296
653
|
};
|
|
297
654
|
/**
|
|
298
|
-
*
|
|
655
|
+
* Natural-language instruction guiding what information to extract
|
|
299
656
|
*/
|
|
300
657
|
user_instruction: string;
|
|
301
658
|
/**
|
|
@@ -307,7 +664,8 @@ export interface SourceExtractParams {
|
|
|
307
664
|
*/
|
|
308
665
|
file_names?: Array<string> | null;
|
|
309
666
|
/**
|
|
310
|
-
* Controls model and thinking
|
|
667
|
+
* Controls model and thinking budget: 'fast' (cheapest/fastest), 'balanced', or
|
|
668
|
+
* 'accurate' (most thorough)
|
|
311
669
|
*/
|
|
312
670
|
thinking_level?: 'fast' | 'balanced' | 'accurate' | null;
|
|
313
671
|
}
|
|
@@ -321,7 +679,7 @@ export interface SourceLoadElementsParams {
|
|
|
321
679
|
*/
|
|
322
680
|
file_name?: string | null;
|
|
323
681
|
/**
|
|
324
|
-
*
|
|
682
|
+
* Optional filter to narrow down the returned elements
|
|
325
683
|
*/
|
|
326
684
|
filter?: SourceLoadElementsParams.Filter | null;
|
|
327
685
|
/**
|
|
@@ -335,19 +693,19 @@ export interface SourceLoadElementsParams {
|
|
|
335
693
|
}
|
|
336
694
|
export declare namespace SourceLoadElementsParams {
|
|
337
695
|
/**
|
|
338
|
-
*
|
|
696
|
+
* Optional filter to narrow down the returned elements
|
|
339
697
|
*/
|
|
340
698
|
interface Filter {
|
|
341
699
|
/**
|
|
342
|
-
*
|
|
700
|
+
* List of element types to exclude from the results
|
|
343
701
|
*/
|
|
344
702
|
elementsToRemove?: Array<string> | null;
|
|
345
703
|
/**
|
|
346
|
-
*
|
|
704
|
+
* Restrict results to specific page numbers from the original document
|
|
347
705
|
*/
|
|
348
706
|
page_numbers?: Array<number> | null;
|
|
349
707
|
/**
|
|
350
|
-
*
|
|
708
|
+
* Filter by element type (e.g. NarrativeText, Title, Table)
|
|
351
709
|
*/
|
|
352
710
|
type?: string | null;
|
|
353
711
|
}
|
|
@@ -362,23 +720,22 @@ export interface SourceParseParams {
|
|
|
362
720
|
*/
|
|
363
721
|
file_name?: string | null;
|
|
364
722
|
/**
|
|
365
|
-
* The
|
|
723
|
+
* The partitioning strategy to apply (basic, hi_res, hi_res_ft, mai, graphorlm)
|
|
366
724
|
*/
|
|
367
725
|
partition_method?: PublicPartitionMethod;
|
|
368
726
|
}
|
|
369
727
|
export interface SourceRetrieveChunksParams {
|
|
370
728
|
/**
|
|
371
|
-
* The search query to
|
|
729
|
+
* The natural-language search query to find relevant chunks
|
|
372
730
|
*/
|
|
373
731
|
query: string;
|
|
374
732
|
/**
|
|
375
|
-
* Optional list of file IDs to restrict retrieval
|
|
376
|
-
* (preferred)
|
|
733
|
+
* Optional list of file IDs to restrict retrieval scope (preferred)
|
|
377
734
|
*/
|
|
378
735
|
file_ids?: Array<string> | null;
|
|
379
736
|
/**
|
|
380
|
-
* Optional list of file names to restrict retrieval
|
|
381
|
-
*
|
|
737
|
+
* Optional list of file names to restrict retrieval scope (deprecated, use
|
|
738
|
+
* file_ids)
|
|
382
739
|
*/
|
|
383
740
|
file_names?: Array<string> | null;
|
|
384
741
|
}
|
|
@@ -391,17 +748,17 @@ export interface SourceUploadParams {
|
|
|
391
748
|
}
|
|
392
749
|
export interface SourceUploadGitHubParams {
|
|
393
750
|
/**
|
|
394
|
-
* The
|
|
751
|
+
* The GitHub repository URL to ingest (e.g. https://github.com/owner/repo)
|
|
395
752
|
*/
|
|
396
753
|
url: string;
|
|
397
754
|
}
|
|
398
755
|
export interface SourceUploadURLParams {
|
|
399
756
|
/**
|
|
400
|
-
* The
|
|
757
|
+
* The web page URL to ingest
|
|
401
758
|
*/
|
|
402
759
|
url: string;
|
|
403
760
|
/**
|
|
404
|
-
*
|
|
761
|
+
* When true, also follows and ingests links found on the page
|
|
405
762
|
*/
|
|
406
763
|
crawlUrls?: boolean;
|
|
407
764
|
/**
|
|
@@ -411,7 +768,8 @@ export interface SourceUploadURLParams {
|
|
|
411
768
|
}
|
|
412
769
|
export interface SourceUploadYoutubeParams {
|
|
413
770
|
/**
|
|
414
|
-
* The
|
|
771
|
+
* The YouTube video URL to ingest (e.g.
|
|
772
|
+
* https://www.youtube.com/watch?v=dQw4w9WgXcQ)
|
|
415
773
|
*/
|
|
416
774
|
url: string;
|
|
417
775
|
}
|