-
Notifications
You must be signed in to change notification settings - Fork 0
/
docs.ts
155 lines (120 loc) · 3.46 KB
/
docs.ts
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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../resource';
import { isRequestOptions } from '../../core';
import * as Core from '../../core';
import * as AgentsDocsAPI from './docs';
import * as DocsAPI from '../docs';
import { DocsOffsetPagination } from '../docs';
import * as Shared from '../shared';
import { type OffsetPaginationParams } from '../../pagination';
export class Docs extends APIResource {
/**
* Create Agent Doc
*/
create(
agentId: string,
body: DocCreateParams,
options?: Core.RequestOptions,
): Core.APIPromise<Shared.ResourceCreated> {
return this._client.post(`/agents/${agentId}/docs`, { body, ...options });
}
/**
* List Agent Docs
*/
list(
agentId: string,
query?: DocListParams,
options?: Core.RequestOptions,
): Core.PagePromise<DocsOffsetPagination, DocsAPI.Doc>;
list(agentId: string, options?: Core.RequestOptions): Core.PagePromise<DocsOffsetPagination, DocsAPI.Doc>;
list(
agentId: string,
query: DocListParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.PagePromise<DocsOffsetPagination, DocsAPI.Doc> {
if (isRequestOptions(query)) {
return this.list(agentId, {}, query);
}
return this._client.getAPIList(`/agents/${agentId}/docs`, DocsOffsetPagination, { query, ...options });
}
/**
* Delete Agent Doc
*/
delete(
agentId: string,
docId: string,
options?: Core.RequestOptions,
): Core.APIPromise<Shared.ResourceDeleted> {
return this._client.delete(`/agents/${agentId}/docs/${docId}`, options);
}
/**
* Search Agent Docs
*/
search(
agentId: string,
body: DocSearchParams,
options?: Core.RequestOptions,
): Core.APIPromise<DocSearchResponse> {
return this._client.post(`/agents/${agentId}/search`, { body, ...options });
}
}
export interface DocSearchResponse {
docs: Array<DocSearchResponse.Doc>;
time: number;
}
export namespace DocSearchResponse {
export interface Doc {
id: string;
owner: Doc.Owner;
snippets: Array<DocsAPI.Snippet>;
distance?: number | null;
title?: string | null;
}
export namespace Doc {
export interface Owner {
id: string;
role: 'user' | 'agent';
}
}
}
export interface DocCreateParams {
content: string | Array<string>;
title: string;
metadata?: unknown | null;
}
export interface DocListParams extends OffsetPaginationParams {
direction?: 'asc' | 'desc';
sort_by?: 'created_at' | 'updated_at';
}
export type DocSearchParams =
| DocSearchParams.TextOnlyDocSearchRequest
| DocSearchParams.VectorDocSearchRequest
| DocSearchParams.HybridDocSearchRequest;
export namespace DocSearchParams {
export interface TextOnlyDocSearchRequest {
text: string;
lang?: 'en-US';
limit?: number;
}
export interface VectorDocSearchRequest {
vector: Array<number>;
confidence?: number;
lang?: 'en-US';
limit?: number;
}
export interface HybridDocSearchRequest {
text: string;
vector: Array<number>;
alpha?: number;
confidence?: number;
lang?: 'en-US';
limit?: number;
}
}
export namespace Docs {
export import DocSearchResponse = AgentsDocsAPI.DocSearchResponse;
export import DocCreateParams = AgentsDocsAPI.DocCreateParams;
export import DocListParams = AgentsDocsAPI.DocListParams;
export import DocSearchParams = AgentsDocsAPI.DocSearchParams;
}
export { DocsOffsetPagination };