-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathpassages.ts
More file actions
196 lines (166 loc) · 4.94 KB
/
passages.ts
File metadata and controls
196 lines (166 loc) · 4.94 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// 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 { RequestOptions } from '../../internal/request-options';
import { path } from '../../internal/utils/path';
export class Passages extends APIResource {
/**
* Insert a memory into an agent's archival memory store.
*/
create(
agentID: string,
body: PassageCreateParams,
options?: RequestOptions,
): APIPromise<PassageCreateResponse> {
return this._client.post(path`/v1/agents/${agentID}/archival-memory`, { body, ...options });
}
/**
* Retrieve the memories in an agent's archival memory store (paginated query).
*/
list(
agentID: string,
query: PassageListParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<PassageListResponse> {
return this._client.get(path`/v1/agents/${agentID}/archival-memory`, { query, ...options });
}
/**
* Delete a memory from an agent's archival memory store.
*/
delete(memoryID: string, params: PassageDeleteParams, options?: RequestOptions): APIPromise<unknown> {
const { agent_id } = params;
return this._client.delete(path`/v1/agents/${agent_id}/archival-memory/${memoryID}`, options);
}
/**
* Search archival memory using semantic (embedding-based) search with optional
* temporal filtering.
*
* This endpoint allows manual triggering of archival memory searches, enabling
* users to query an agent's archival memory store directly via the API. The search
* uses the same functionality as the agent's archival_memory_search tool but is
* accessible for external API usage.
*/
search(
agentID: string,
query: PassageSearchParams,
options?: RequestOptions,
): APIPromise<PassageSearchResponse> {
return this._client.get(path`/v1/agents/${agentID}/archival-memory/search`, { query, ...options });
}
}
export type PassageCreateResponse = Array<PassagesAPI.Passage>;
export type PassageListResponse = Array<PassagesAPI.Passage>;
export type PassageDeleteResponse = unknown;
export interface PassageSearchResponse {
/**
* Total number of results returned
*/
count: number;
/**
* List of search results matching the query
*/
results: Array<PassageSearchResponse.Result>;
}
export namespace PassageSearchResponse {
export interface Result {
/**
* Unique identifier of the archival memory passage
*/
id: string;
/**
* Text content of the archival memory passage
*/
content: string;
/**
* Timestamp of when the memory was created, formatted in agent's timezone
*/
timestamp: string;
/**
* List of tags associated with this memory
*/
tags?: Array<string>;
}
}
export interface PassageCreateParams {
/**
* Text to write to archival memory.
*/
text: string;
/**
* Optional timestamp for the memory (defaults to current UTC time).
*/
created_at?: string | null;
/**
* Optional list of tags to attach to the memory.
*/
tags?: Array<string> | null;
}
export interface PassageListParams {
/**
* Unique ID of the memory to start the query range at.
*/
after?: string | null;
/**
* Whether to sort passages oldest to newest (True, default) or newest to oldest
* (False)
*/
ascending?: boolean | null;
/**
* Unique ID of the memory to end the query range at.
*/
before?: string | null;
/**
* How many results to include in the response.
*/
limit?: number | null;
/**
* Search passages by text
*/
search?: string | null;
}
export interface PassageDeleteParams {
/**
* The ID of the agent in the format 'agent-<uuid4>'
*/
agent_id: string;
}
export interface PassageSearchParams {
/**
* String to search for using semantic similarity
*/
query: string;
/**
* Filter results to passages created before this datetime
*/
end_datetime?: string | null;
/**
* Filter results to passages created after this datetime
*/
start_datetime?: string | null;
/**
* How to match tags - 'any' to match passages with any of the tags, 'all' to match
* only passages with all tags
*/
tag_match_mode?: 'any' | 'all';
/**
* Optional list of tags to filter search results
*/
tags?: Array<string> | null;
/**
* Maximum number of results to return. Uses system default if not specified
*/
top_k?: number | null;
}
export declare namespace Passages {
export {
type PassageCreateResponse as PassageCreateResponse,
type PassageListResponse as PassageListResponse,
type PassageDeleteResponse as PassageDeleteResponse,
type PassageSearchResponse as PassageSearchResponse,
type PassageCreateParams as PassageCreateParams,
type PassageListParams as PassageListParams,
type PassageDeleteParams as PassageDeleteParams,
type PassageSearchParams as PassageSearchParams,
};
}