-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathpassages.ts
More file actions
124 lines (108 loc) · 3.23 KB
/
passages.ts
File metadata and controls
124 lines (108 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../core/resource';
import * as PassagesAPI from '../passages';
import { APIPromise } from '../../core/api-promise';
import { buildHeaders } from '../../internal/headers';
import { RequestOptions } from '../../internal/request-options';
import { path } from '../../internal/utils/path';
export class Passages extends APIResource {
/**
* Create a new passage in an archive.
*
* This adds a passage to the archive and creates embeddings for vector storage.
*/
create(
archiveID: string,
body: PassageCreateParams,
options?: RequestOptions,
): APIPromise<PassagesAPI.Passage> {
return this._client.post(path`/v1/archives/${archiveID}/passages`, { body, ...options });
}
/**
* Delete a passage from an archive.
*
* This permanently removes the passage from both the database and vector storage
* (if applicable).
*/
delete(passageID: string, params: PassageDeleteParams, options?: RequestOptions): APIPromise<void> {
const { archive_id } = params;
return this._client.delete(path`/v1/archives/${archive_id}/passages/${passageID}`, {
...options,
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
});
}
/**
* Create multiple passages in an archive.
*
* This adds passages to the archive and creates embeddings for vector storage.
*/
createMany(
archiveID: string,
body: PassageCreateManyParams,
options?: RequestOptions,
): APIPromise<PassageCreateManyResponse> {
return this._client.post(path`/v1/archives/${archiveID}/passages/batch`, { body, ...options });
}
}
export type PassageCreateManyResponse = Array<PassagesAPI.Passage>;
export interface PassageCreateParams {
/**
* The text content of the passage
*/
text: string;
/**
* Optional creation datetime for the passage (ISO 8601 format)
*/
created_at?: string | null;
/**
* Optional metadata for the passage
*/
metadata?: { [key: string]: unknown } | null;
/**
* Optional tags for categorizing the passage
*/
tags?: Array<string> | null;
}
export interface PassageDeleteParams {
/**
* The ID of the archive in the format 'archive-<uuid4>'
*/
archive_id: string;
}
export interface PassageCreateManyParams {
/**
* Passages to create in the archive
*/
passages: Array<PassageCreateManyParams.Passage>;
}
export namespace PassageCreateManyParams {
/**
* Request model for creating a passage in an archive.
*/
export interface Passage {
/**
* The text content of the passage
*/
text: string;
/**
* Optional creation datetime for the passage (ISO 8601 format)
*/
created_at?: string | null;
/**
* Optional metadata for the passage
*/
metadata?: { [key: string]: unknown } | null;
/**
* Optional tags for categorizing the passage
*/
tags?: Array<string> | null;
}
}
export declare namespace Passages {
export {
type PassageCreateManyResponse as PassageCreateManyResponse,
type PassageCreateParams as PassageCreateParams,
type PassageDeleteParams as PassageDeleteParams,
type PassageCreateManyParams as PassageCreateManyParams,
};
}