@weaviate/agents 0.0.0-stage → 1.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.
Files changed (35) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +130 -2
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +1 -0
  5. package/dist/query/agent.d.ts +539 -0
  6. package/dist/query/agent.js +373 -0
  7. package/dist/query/agent.test.d.ts +1 -0
  8. package/dist/query/agent.test.js +1118 -0
  9. package/dist/query/collection.d.ts +22 -0
  10. package/dist/query/collection.js +12 -0
  11. package/dist/query/connection.d.ts +10 -0
  12. package/dist/query/connection.js +19 -0
  13. package/dist/query/filter.d.ts +2 -0
  14. package/dist/query/filter.js +20 -0
  15. package/dist/query/index.d.ts +4 -0
  16. package/dist/query/index.js +3 -0
  17. package/dist/query/media.d.ts +25 -0
  18. package/dist/query/media.js +24 -0
  19. package/dist/query/response/api-response-mapping.d.ts +3 -0
  20. package/dist/query/response/api-response-mapping.js +172 -0
  21. package/dist/query/response/api-response.d.ts +219 -0
  22. package/dist/query/response/api-response.js +1 -0
  23. package/dist/query/response/error.d.ts +6 -0
  24. package/dist/query/response/error.js +34 -0
  25. package/dist/query/response/index.d.ts +2 -0
  26. package/dist/query/response/index.js +2 -0
  27. package/dist/query/response/response-mapping.d.ts +23 -0
  28. package/dist/query/response/response-mapping.js +308 -0
  29. package/dist/query/response/response.d.ts +332 -0
  30. package/dist/query/response/response.js +44 -0
  31. package/dist/query/response/server-sent-events.d.ts +14 -0
  32. package/dist/query/response/server-sent-events.js +85 -0
  33. package/dist/query/search.d.ts +37 -0
  34. package/dist/query/search.js +87 -0
  35. package/package.json +46 -3
@@ -0,0 +1,308 @@
1
+ /**
2
+ * Duck-types a value as a Zod schema (as opposed to a raw JSON Schema object):
3
+ * only a Zod schema carries a `parse` method, and a function value can never
4
+ * appear in a JSON-serialisable schema, so this reliably tells the two apart.
5
+ */
6
+ export const isZodSchema = (value) => typeof value.parse === "function";
7
+ export function mapAskModeResponse(response, outputFormat) {
8
+ const properties = {
9
+ outputType: "finalState",
10
+ searches: mapSearches(response.searches),
11
+ aggregations: response.aggregations.map((aggregation) => ({
12
+ groupbyProperty: aggregation.groupby_property,
13
+ aggregation: mapPropertyAggregation(aggregation.aggregation),
14
+ filters: aggregation.filters ? mapFilter(aggregation.filters) : undefined,
15
+ collection: aggregation.collection,
16
+ })),
17
+ usage: mapUsage(response.usage),
18
+ totalTime: response.total_time,
19
+ isPartialAnswer: response.is_partial_answer,
20
+ missingInformation: response.missing_information,
21
+ finalAnswer: response.final_answer,
22
+ sources: response.sources ? mapSources(response.sources) : undefined,
23
+ };
24
+ if (outputFormat === undefined) {
25
+ return Object.assign(Object.assign({}, properties), { display: () => display(properties) });
26
+ }
27
+ // A Zod schema parses and validates; a raw JSON Schema only parses the JSON.
28
+ const finalAnswerParsed = isZodSchema(outputFormat)
29
+ ? outputFormat.parse(JSON.parse(response.final_answer))
30
+ : JSON.parse(response.final_answer);
31
+ const parsedProperties = Object.assign(Object.assign({}, properties), { finalAnswerParsed });
32
+ return Object.assign(Object.assign({}, parsedProperties), { display: () => display(parsedProperties) });
33
+ }
34
+ const mapSearches = (searches) => searches.map((search) => ({
35
+ query: search.query,
36
+ filters: search.filters ? mapFilter(search.filters) : undefined,
37
+ collection: search.collection,
38
+ sortProperty: search.sort_property
39
+ ? mapQuerySort(search.sort_property)
40
+ : undefined,
41
+ uuidValue: search.uuid_value,
42
+ }));
43
+ const mapQuerySort = (sort) => ({
44
+ propertyName: sort.property_name,
45
+ order: sort.order,
46
+ tieBreak: sort.tie_break ? mapQuerySort(sort.tie_break) : undefined,
47
+ });
48
+ const mapUsage = (usage) => ({
49
+ modelUnits: usage.model_units,
50
+ usageInPlan: usage.usage_in_plan,
51
+ remainingPlanRequests: usage.remaining_plan_requests,
52
+ });
53
+ export const mapResponse = (response) => {
54
+ const properties = {
55
+ outputType: "finalState",
56
+ originalQuery: response.original_query,
57
+ collectionNames: response.collection_names,
58
+ searches: response.searches.map((searches) => searches.map((result) => ({
59
+ collection: result.collection,
60
+ queries: result.queries,
61
+ filters: result.filters.map((filter) => filter.map(mapPropertyFilter)),
62
+ filterOperators: result.filter_operators,
63
+ }))),
64
+ aggregations: mapAggregations(response.aggregations),
65
+ usage: {
66
+ requests: response.usage.requests,
67
+ requestTokens: response.usage.request_tokens,
68
+ responseTokens: response.usage.response_tokens,
69
+ totalTokens: response.usage.total_tokens,
70
+ details: response.usage.details,
71
+ },
72
+ totalTime: response.total_time,
73
+ isPartialAnswer: response.is_partial_answer,
74
+ missingInformation: response.missing_information,
75
+ finalAnswer: response.final_answer,
76
+ sources: mapSources(response.sources),
77
+ };
78
+ return Object.assign(Object.assign({}, properties), { display: () => display(properties) });
79
+ };
80
+ const mapDatePropertyFilter = (filterValue) => {
81
+ if ("exact_timestamp" in filterValue) {
82
+ return {
83
+ exactTimestamp: filterValue.exact_timestamp,
84
+ operator: filterValue.operator,
85
+ };
86
+ }
87
+ else if ("date_from" in filterValue &&
88
+ "date_to" in filterValue &&
89
+ filterValue.date_from != null &&
90
+ filterValue.date_to != null) {
91
+ return {
92
+ dateFrom: filterValue.date_from,
93
+ dateTo: filterValue.date_to,
94
+ inclusiveFrom: filterValue.inclusive_from,
95
+ inclusiveTo: filterValue.inclusive_to,
96
+ };
97
+ }
98
+ else if ("date_from" in filterValue && filterValue.date_from != null) {
99
+ return {
100
+ dateFrom: filterValue.date_from,
101
+ inclusiveFrom: filterValue.inclusive_from,
102
+ };
103
+ }
104
+ else if ("date_to" in filterValue && filterValue.date_to != null) {
105
+ return {
106
+ dateTo: filterValue.date_to,
107
+ inclusiveTo: filterValue.inclusive_to,
108
+ };
109
+ }
110
+ return undefined;
111
+ };
112
+ const mapFilter = (filter) => multiFilter(filter)
113
+ ? { combine: filter.combine, filters: filter.filters.map(mapFilter) }
114
+ : mapPropertyFilter(filter);
115
+ const mapPropertyFilter = (filter) => {
116
+ switch (filter.filter_type) {
117
+ case "integer":
118
+ return {
119
+ filterType: "integer",
120
+ propertyName: filter.property_name,
121
+ operator: filter.operator,
122
+ value: filter.value,
123
+ };
124
+ case "integer_array":
125
+ return {
126
+ filterType: "integerArray",
127
+ propertyName: filter.property_name,
128
+ operator: filter.operator,
129
+ value: filter.value,
130
+ };
131
+ case "text":
132
+ return {
133
+ filterType: "text",
134
+ propertyName: filter.property_name,
135
+ operator: filter.operator,
136
+ value: filter.value,
137
+ };
138
+ case "text_array":
139
+ return {
140
+ filterType: "textArray",
141
+ propertyName: filter.property_name,
142
+ operator: filter.operator,
143
+ value: filter.value,
144
+ };
145
+ case "boolean":
146
+ return {
147
+ filterType: "boolean",
148
+ propertyName: filter.property_name,
149
+ operator: filter.operator,
150
+ value: filter.value,
151
+ };
152
+ case "boolean_array":
153
+ return {
154
+ filterType: "booleanArray",
155
+ propertyName: filter.property_name,
156
+ operator: filter.operator,
157
+ value: filter.value,
158
+ };
159
+ case "date_range":
160
+ const value = mapDatePropertyFilter(filter.value);
161
+ if (!value) {
162
+ return {
163
+ filterType: "unknown",
164
+ propertyName: filter.property_name,
165
+ };
166
+ }
167
+ return {
168
+ filterType: "dateRange",
169
+ propertyName: filter.property_name,
170
+ value,
171
+ };
172
+ case "date_array":
173
+ return {
174
+ filterType: "dateArray",
175
+ propertyName: filter.property_name,
176
+ operator: filter.operator,
177
+ value: filter.value,
178
+ };
179
+ case "geo":
180
+ return {
181
+ filterType: "geo",
182
+ propertyName: filter.property_name,
183
+ latitude: filter.latitude,
184
+ longitude: filter.longitude,
185
+ maxDistanceMeters: filter.max_distance_meters,
186
+ };
187
+ case "is_null":
188
+ return {
189
+ filterType: "isNull",
190
+ propertyName: filter.property_name,
191
+ isNull: filter.is_null,
192
+ };
193
+ case "uuid":
194
+ return {
195
+ filterType: "uuid",
196
+ propertyName: filter.property_name,
197
+ operator: filter.operator,
198
+ value: filter.value,
199
+ };
200
+ case "uuid_array":
201
+ return {
202
+ filterType: "uuidArray",
203
+ propertyName: filter.property_name,
204
+ operator: filter.operator,
205
+ value: filter.value,
206
+ };
207
+ default:
208
+ return {
209
+ filterType: "unknown",
210
+ propertyName: filter.property_name,
211
+ };
212
+ }
213
+ };
214
+ const multiFilter = (filter) => "combine" in filter;
215
+ const mapAggregations = (aggregations) => aggregations.map((aggregationGroup) => aggregationGroup.map((result) => ({
216
+ collection: result.collection,
217
+ searchQuery: result.search_query,
218
+ groupbyProperty: result.groupby_property,
219
+ aggregations: result.aggregations.map(mapPropertyAggregation),
220
+ filters: result.filters.map(mapPropertyFilter),
221
+ })));
222
+ const mapPropertyAggregation = (aggregation) => ({
223
+ propertyName: aggregation.property_name,
224
+ metrics: aggregation.metrics,
225
+ topOccurrencesLimit: "top_occurrences_limit" in aggregation
226
+ ? aggregation.top_occurrences_limit
227
+ : undefined,
228
+ });
229
+ const mapSources = (sources) => sources.map((source) => ({
230
+ objectId: source.object_id,
231
+ collection: source.collection,
232
+ }));
233
+ const display = (response) => {
234
+ console.log(JSON.stringify(response, undefined, 2));
235
+ };
236
+ export const mapProgressMessageFromSSE = (sse) => {
237
+ const data = JSON.parse(sse.data);
238
+ if (data.output_type !== "progress_message") {
239
+ throw new Error(`Expected output_type "progress_message", got ${data.output_type}`);
240
+ }
241
+ return {
242
+ outputType: "progressMessage",
243
+ stage: data.stage,
244
+ message: data.message,
245
+ details: data.details,
246
+ };
247
+ };
248
+ export const mapStreamedTokensFromSSE = (sse) => {
249
+ const data = JSON.parse(sse.data);
250
+ if (data.output_type !== "streamed_tokens") {
251
+ throw new Error(`Expected output_type "streamed_tokens", got ${data.output_type}`);
252
+ }
253
+ return {
254
+ outputType: "streamedTokens",
255
+ delta: data.delta,
256
+ };
257
+ };
258
+ const mapWeaviateObject = (object) => {
259
+ const metadata = {
260
+ creationTime: object.metadata.creation_time !== null
261
+ ? object.metadata.creation_time
262
+ : undefined,
263
+ updateTime: object.metadata.update_time !== null
264
+ ? object.metadata.update_time
265
+ : undefined,
266
+ distance: object.metadata.distance !== null ? object.metadata.distance : undefined,
267
+ certainty: object.metadata.certainty !== null
268
+ ? object.metadata.certainty
269
+ : undefined,
270
+ score: object.metadata.score !== null ? object.metadata.score : undefined,
271
+ explainScore: object.metadata.explain_score !== null
272
+ ? object.metadata.explain_score
273
+ : undefined,
274
+ rerankScore: object.metadata.rerank_score !== null
275
+ ? object.metadata.rerank_score
276
+ : undefined,
277
+ isConsistent: object.metadata.is_consistent !== null
278
+ ? object.metadata.is_consistent
279
+ : undefined,
280
+ };
281
+ return {
282
+ properties: object.properties,
283
+ metadata,
284
+ references: undefined,
285
+ uuid: object.uuid,
286
+ vectors: object.vector,
287
+ collection: object.collection,
288
+ };
289
+ };
290
+ export const mapWeviateSearchResults = (response) => ({
291
+ objects: response.objects.map(mapWeaviateObject),
292
+ });
293
+ export const mapSuggestQueryResponse = (response) => ({
294
+ queries: response.queries,
295
+ collectionCount: response.collection_count,
296
+ usage: mapUsage(response.usage),
297
+ totalTime: response.total_time,
298
+ });
299
+ export const mapSearchOnlyResponse = (response) => {
300
+ const apiSearches = response.searches;
301
+ const mappedResponse = {
302
+ searches: apiSearches ? mapSearches(apiSearches) : undefined,
303
+ usage: mapUsage(response.usage),
304
+ totalTime: response.total_time,
305
+ searchResults: mapWeviateSearchResults(response.search_results),
306
+ };
307
+ return { mappedResponse, apiSearches };
308
+ };
@@ -0,0 +1,332 @@
1
+ import { WeaviateReturn, WeaviateObject } from "@weaviate/core";
2
+ import { z } from "zod";
3
+ export type AskModeResponse = {
4
+ outputType: "finalState";
5
+ searches: Search[];
6
+ aggregations: Aggregation[];
7
+ usage: ModelUnitUsage;
8
+ totalTime: number;
9
+ isPartialAnswer?: boolean;
10
+ missingInformation?: string[];
11
+ finalAnswer: string;
12
+ sources?: Source[];
13
+ display(): void;
14
+ };
15
+ /**
16
+ * A structured output format for the ask mode.
17
+ *
18
+ * Either a Zod schema (the equivalent of a Pydantic model — the final answer is
19
+ * parsed and validated into the inferred type), or a plain object holding a
20
+ * Draft 2020-12 JSON Schema (the final answer is parsed as JSON). Pass nothing
21
+ * for no structured output.
22
+ */
23
+ export type OutputFormat = z.ZodType | Record<string, unknown>;
24
+ /**
25
+ * An {@link AskModeResponse} where the final answer has been parsed into the
26
+ * requested structured output format.
27
+ *
28
+ * `T` is the inferred type of the Zod schema (`z.infer<typeof schema>`) when a
29
+ * schema was passed, or `Record<string, unknown>` when a raw JSON Schema was.
30
+ */
31
+ export type ParsedAskModeResponse<T> = AskModeResponse & {
32
+ /** The final answer parsed into the requested output format. */
33
+ finalAnswerParsed: T;
34
+ };
35
+ export type Search = {
36
+ query?: string;
37
+ filters?: PropertyFilter | FilterAndOr;
38
+ collection: string;
39
+ sortProperty?: QuerySort;
40
+ uuidValue?: string;
41
+ };
42
+ export type Aggregation = {
43
+ groupbyProperty?: string;
44
+ aggregation: PropertyAggregation;
45
+ filters?: PropertyFilter | FilterAndOr;
46
+ collection: string;
47
+ };
48
+ export type FilterAndOr = {
49
+ combine: "AND" | "OR";
50
+ filters: (PropertyFilter | FilterAndOr)[];
51
+ };
52
+ export type ModelUnitUsage = {
53
+ modelUnits: number;
54
+ usageInPlan: boolean;
55
+ remainingPlanRequests: number;
56
+ };
57
+ export type QuerySort = {
58
+ propertyName: string;
59
+ order: "ascending" | "descending";
60
+ tieBreak?: QuerySort;
61
+ };
62
+ export type QueryAgentResponse = {
63
+ outputType: "finalState";
64
+ originalQuery: string;
65
+ collectionNames: string[];
66
+ searches: SearchResult[][];
67
+ aggregations: AggregationResult[][];
68
+ usage: Usage;
69
+ totalTime: number;
70
+ isPartialAnswer: boolean;
71
+ missingInformation: string[];
72
+ finalAnswer: string;
73
+ sources: Source[];
74
+ display(): void;
75
+ };
76
+ export type SearchResult = {
77
+ collection: string;
78
+ queries: (string | null)[];
79
+ filters: PropertyFilter[][];
80
+ filterOperators: "AND" | "OR";
81
+ };
82
+ export type PropertyFilter = IntegerPropertyFilter | IntegerArrayPropertyFilter | TextPropertyFilter | TextArrayPropertyFilter | BooleanPropertyFilter | BooleanArrayPropertyFilter | DatePropertyFilter | DateArrayPropertyFilter | GeoPropertyFilter | IsNullPropertyFilter | UuidPropertyFilter | UuidArrayPropertyFilter | UnknownPropertyFilter;
83
+ type PropertyFilterBase = {
84
+ filterType: string;
85
+ propertyName: string;
86
+ };
87
+ /** Filter numeric properties using comparison operators */
88
+ export type IntegerPropertyFilter = PropertyFilterBase & {
89
+ filterType: "integer";
90
+ operator: ComparisonOperator;
91
+ value: number;
92
+ };
93
+ /** Filter numeric array properties using comparison operators */
94
+ export type IntegerArrayPropertyFilter = PropertyFilterBase & {
95
+ filterType: "integerArray";
96
+ operator: ComparisonOperator;
97
+ value: number[];
98
+ };
99
+ /** Filter text properties using equality or LIKE operators */
100
+ export type TextPropertyFilter = PropertyFilterBase & {
101
+ filterType: "text";
102
+ operator: ComparisonOperator;
103
+ value: string;
104
+ };
105
+ /** Filter text array properties using equality or LIKE operators */
106
+ export type TextArrayPropertyFilter = PropertyFilterBase & {
107
+ filterType: "textArray";
108
+ operator: ComparisonOperator;
109
+ value: string[];
110
+ };
111
+ /** Filter boolean properties using equality operators */
112
+ export type BooleanPropertyFilter = PropertyFilterBase & {
113
+ filterType: "boolean";
114
+ operator: ComparisonOperator;
115
+ value: boolean;
116
+ };
117
+ /** Filter boolean array properties using equality operators */
118
+ export type BooleanArrayPropertyFilter = PropertyFilterBase & {
119
+ filterType: "booleanArray";
120
+ operator: ComparisonOperator;
121
+ value: boolean[];
122
+ };
123
+ /** Filter date properties using equality / range operators */
124
+ export type DateExact = {
125
+ exactTimestamp: string;
126
+ operator: ComparisonOperator;
127
+ };
128
+ export type DateRangeFrom = {
129
+ dateFrom: string;
130
+ inclusiveFrom: boolean;
131
+ };
132
+ export type DateRangeTo = {
133
+ dateTo: string;
134
+ inclusiveTo: boolean;
135
+ };
136
+ export type DateRangeBetween = {
137
+ dateFrom: string;
138
+ dateTo: string;
139
+ inclusiveFrom: boolean;
140
+ inclusiveTo: boolean;
141
+ };
142
+ export type DateFilterValue = DateExact | DateRangeFrom | DateRangeTo | DateRangeBetween;
143
+ export type DatePropertyFilter = PropertyFilterBase & {
144
+ filterType: "dateRange";
145
+ value: DateFilterValue;
146
+ };
147
+ export type DateArrayPropertyFilter = PropertyFilterBase & {
148
+ filterType: "dateArray";
149
+ operator: ComparisonOperator;
150
+ value: string[];
151
+ };
152
+ /** Filter geo-coordinates properties. */
153
+ export type GeoPropertyFilter = PropertyFilterBase & {
154
+ filterType: "geo";
155
+ latitude: number;
156
+ longitude: number;
157
+ maxDistanceMeters: number;
158
+ };
159
+ /** Filter properties by their null state. */
160
+ export type IsNullPropertyFilter = PropertyFilterBase & {
161
+ filterType: "isNull";
162
+ isNull: boolean;
163
+ };
164
+ /** Filter UUID properties using comparison operators. */
165
+ export type UuidPropertyFilter = PropertyFilterBase & {
166
+ filterType: "uuid";
167
+ operator: ComparisonOperator;
168
+ value: string;
169
+ };
170
+ /** Filter UUID array properties using comparison operators. */
171
+ export type UuidArrayPropertyFilter = PropertyFilterBase & {
172
+ filterType: "uuidArray";
173
+ operator: ComparisonOperator;
174
+ value: string[];
175
+ };
176
+ export type UnknownPropertyFilter = PropertyFilterBase & {
177
+ filterType: "unknown";
178
+ };
179
+ export declare enum ComparisonOperator {
180
+ Equals = "=",
181
+ LessThan = "<",
182
+ GreaterThan = ">",
183
+ LessEqual = "<=",
184
+ GreaterEqual = ">=",
185
+ NotEquals = "!=",
186
+ Like = "LIKE"
187
+ }
188
+ /**
189
+ * The aggregations performed on a collection in a vector database.
190
+ *
191
+ * They should be based on the original user query and can include multiple
192
+ * aggregations across different properties and metrics.
193
+ */
194
+ export type AggregationResult = {
195
+ collection: string;
196
+ searchQuery?: string;
197
+ groupbyProperty?: string;
198
+ aggregations: PropertyAggregation[];
199
+ filters: PropertyFilter[];
200
+ };
201
+ export type PropertyAggregation = IntegerPropertyAggregation | TextPropertyAggregation | BooleanPropertyAggregation | DatePropertyAggregation;
202
+ type PropertyAggregationBase = {
203
+ propertyName: string;
204
+ };
205
+ /** Aggregate numeric properties using statistical functions */
206
+ export type IntegerPropertyAggregation = PropertyAggregationBase & {
207
+ metrics: NumericMetrics;
208
+ };
209
+ /** Aggregate text properties using frequency analysis */
210
+ export type TextPropertyAggregation = PropertyAggregationBase & {
211
+ metrics: TextMetrics;
212
+ topOccurrencesLimit?: number;
213
+ };
214
+ /** Aggregate boolean properties using statistical functions */
215
+ export type BooleanPropertyAggregation = PropertyAggregationBase & {
216
+ metrics: BooleanMetrics;
217
+ };
218
+ /** Aggregate date properties using statistical functions */
219
+ export type DatePropertyAggregation = PropertyAggregationBase & {
220
+ metrics: DateMetrics;
221
+ };
222
+ export declare enum NumericMetrics {
223
+ Count = "COUNT",
224
+ Maximum = "MAXIMUM",
225
+ Mean = "MEAN",
226
+ Median = "MEDIAN",
227
+ Minimum = "MINIMUM",
228
+ Mode = "MODE",
229
+ Sum = "SUM",
230
+ Type = "TYPE"
231
+ }
232
+ export declare enum TextMetrics {
233
+ Count = "COUNT",
234
+ Type = "TYPE",
235
+ TopOccurrences = "TOP_OCCURRENCES"
236
+ }
237
+ export declare enum BooleanMetrics {
238
+ Count = "COUNT",
239
+ Type = "TYPE",
240
+ TotalTrue = "TOTAL_TRUE",
241
+ TotalFalse = "TOTAL_FALSE",
242
+ PercentageTrue = "PERCENTAGE_TRUE",
243
+ PercentageFalse = "PERCENTAGE_FALSE"
244
+ }
245
+ export declare enum DateMetrics {
246
+ Count = "COUNT",
247
+ Maximum = "MAXIMUM",
248
+ Median = "MEDIAN",
249
+ Minimum = "MINIMUM",
250
+ Mode = "MODE"
251
+ }
252
+ export type Usage = {
253
+ requests: number;
254
+ requestTokens?: number;
255
+ responseTokens?: number;
256
+ totalTokens?: number;
257
+ details?: Record<string, number>;
258
+ };
259
+ export type Source = {
260
+ objectId: string;
261
+ collection: string;
262
+ };
263
+ export type QueryWithCollection = {
264
+ query: string;
265
+ collection: string;
266
+ };
267
+ export type ProgressDetails = {
268
+ queries?: QueryWithCollection[];
269
+ };
270
+ export type ProgressMessage = {
271
+ outputType: "progressMessage";
272
+ stage: string;
273
+ message: string;
274
+ details: ProgressDetails;
275
+ };
276
+ export type StreamedTokens = {
277
+ outputType: "streamedTokens";
278
+ delta: string;
279
+ };
280
+ export type WeaviateObjectWithCollection = WeaviateObject<undefined, undefined> & {
281
+ collection: string;
282
+ };
283
+ export type WeaviateReturnWithCollection = WeaviateReturn<undefined, undefined> & {
284
+ objects: WeaviateObjectWithCollection[];
285
+ };
286
+ /** Options for executing a prepared QueryAgent search. */
287
+ export type SearchExecutionOptions = {
288
+ /** The maximum number of results to return. Defaults to 20 if not specified. */
289
+ limit?: number;
290
+ /** The offset to start from, for paginating through query result sets. */
291
+ offset: number;
292
+ };
293
+ /**
294
+ * Response for the Query Agent search-only mode.
295
+ *
296
+ * Contains the results of the search, the usage, and the underlying searches performed. You can
297
+ * paginate through the result set by calling {@link SearchModeResponse.next} on this response with
298
+ * different `limit` / `offset` values. This will reuse the same underlying searches each time,
299
+ * resulting in a consistent result set across pages.
300
+ */
301
+ export type SearchModeResponse = {
302
+ /** The underlying searches performed by the agent to produce this result set. */
303
+ searches?: Search[];
304
+ /** Model unit usage for this invocation. */
305
+ usage: ModelUnitUsage;
306
+ /** Total time taken for the agent to produce this result set, in seconds. */
307
+ totalTime: number;
308
+ /** The objects returned by the underlying searches, paginated by `limit` and `offset`. */
309
+ searchResults: WeaviateReturnWithCollection;
310
+ /**
311
+ * Paginate the search-only results with the given `limit` and `offset` values.
312
+ *
313
+ * Reuses the same underlying searches as the originating request, so successive calls produce
314
+ * a consistent result set across pages.
315
+ *
316
+ * @param options - Pagination options.
317
+ * @param options.limit - The maximum number of results to return. Defaults to 20.
318
+ * @param options.offset - The offset to start from.
319
+ * @returns The next {@link SearchModeResponse} page.
320
+ */
321
+ next: (options: SearchExecutionOptions) => Promise<SearchModeResponse>;
322
+ };
323
+ export type SuggestedQuery = {
324
+ query: string;
325
+ };
326
+ export type SuggestQueryResponse = {
327
+ queries: SuggestedQuery[];
328
+ collectionCount: number;
329
+ usage: ModelUnitUsage;
330
+ totalTime: number;
331
+ };
332
+ export {};
@@ -0,0 +1,44 @@
1
+ export var ComparisonOperator;
2
+ (function (ComparisonOperator) {
3
+ ComparisonOperator["Equals"] = "=";
4
+ ComparisonOperator["LessThan"] = "<";
5
+ ComparisonOperator["GreaterThan"] = ">";
6
+ ComparisonOperator["LessEqual"] = "<=";
7
+ ComparisonOperator["GreaterEqual"] = ">=";
8
+ ComparisonOperator["NotEquals"] = "!=";
9
+ ComparisonOperator["Like"] = "LIKE";
10
+ })(ComparisonOperator || (ComparisonOperator = {}));
11
+ export var NumericMetrics;
12
+ (function (NumericMetrics) {
13
+ NumericMetrics["Count"] = "COUNT";
14
+ NumericMetrics["Maximum"] = "MAXIMUM";
15
+ NumericMetrics["Mean"] = "MEAN";
16
+ NumericMetrics["Median"] = "MEDIAN";
17
+ NumericMetrics["Minimum"] = "MINIMUM";
18
+ NumericMetrics["Mode"] = "MODE";
19
+ NumericMetrics["Sum"] = "SUM";
20
+ NumericMetrics["Type"] = "TYPE";
21
+ })(NumericMetrics || (NumericMetrics = {}));
22
+ export var TextMetrics;
23
+ (function (TextMetrics) {
24
+ TextMetrics["Count"] = "COUNT";
25
+ TextMetrics["Type"] = "TYPE";
26
+ TextMetrics["TopOccurrences"] = "TOP_OCCURRENCES";
27
+ })(TextMetrics || (TextMetrics = {}));
28
+ export var BooleanMetrics;
29
+ (function (BooleanMetrics) {
30
+ BooleanMetrics["Count"] = "COUNT";
31
+ BooleanMetrics["Type"] = "TYPE";
32
+ BooleanMetrics["TotalTrue"] = "TOTAL_TRUE";
33
+ BooleanMetrics["TotalFalse"] = "TOTAL_FALSE";
34
+ BooleanMetrics["PercentageTrue"] = "PERCENTAGE_TRUE";
35
+ BooleanMetrics["PercentageFalse"] = "PERCENTAGE_FALSE";
36
+ })(BooleanMetrics || (BooleanMetrics = {}));
37
+ export var DateMetrics;
38
+ (function (DateMetrics) {
39
+ DateMetrics["Count"] = "COUNT";
40
+ DateMetrics["Maximum"] = "MAXIMUM";
41
+ DateMetrics["Median"] = "MEDIAN";
42
+ DateMetrics["Minimum"] = "MINIMUM";
43
+ DateMetrics["Mode"] = "MODE";
44
+ })(DateMetrics || (DateMetrics = {}));
@@ -0,0 +1,14 @@
1
+ export type ServerSentEvent = {
2
+ event: string;
3
+ data: string;
4
+ };
5
+ /**
6
+ * Fetch Server-Sent Events (SSE) from a URL.
7
+ *
8
+ * All fields other than "event" and "data" are ignored
9
+ *
10
+ * @param input - The URL to fetch the SSE from.
11
+ * @param init - The request init options.
12
+ * @returns An async generator of ServerSentEvent objects.
13
+ */
14
+ export declare function fetchServerSentEvents(input: string | URL | globalThis.Request, init?: RequestInit): AsyncGenerator<ServerSentEvent>;