@trainly/react 1.6.2 → 2.0.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/dist/TrainlyProvider.js +157 -1
- package/dist/api/AnalyticsClient.d.ts +33 -0
- package/dist/api/AnalyticsClient.js +160 -0
- package/dist/api/ConfigClient.d.ts +47 -0
- package/dist/api/ConfigClient.js +201 -0
- package/dist/api/FineTuningClient.d.ts +59 -0
- package/dist/api/FineTuningClient.js +279 -0
- package/dist/api/TestingClient.d.ts +51 -0
- package/dist/api/TestingClient.js +274 -0
- package/dist/api/TrainlyClient.d.ts +35 -1
- package/dist/api/TrainlyClient.js +346 -54
- package/dist/api/VersionsClient.d.ts +18 -0
- package/dist/api/VersionsClient.js +160 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +6 -0
- package/dist/types.d.ts +278 -0
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Versions client for publishing and managing configuration versions.
|
|
3
|
+
*/
|
|
4
|
+
import { PublishedVersion, VersionDiff } from "../types";
|
|
5
|
+
export declare class VersionsClient {
|
|
6
|
+
private baseUrl;
|
|
7
|
+
private chatId;
|
|
8
|
+
private getHeaders;
|
|
9
|
+
constructor(baseUrl: string, chatId: string, getHeaders: () => HeadersInit);
|
|
10
|
+
private request;
|
|
11
|
+
publish(version: string, description?: string): Promise<PublishedVersion>;
|
|
12
|
+
listVersions(page?: number, limit?: number): Promise<PublishedVersion[]>;
|
|
13
|
+
getVersion(versionId: string): Promise<PublishedVersion>;
|
|
14
|
+
rollback(versionId: string): Promise<boolean>;
|
|
15
|
+
compareVersions(versionA: string, versionB: string): Promise<VersionDiff>;
|
|
16
|
+
getUnpublishedChanges(): Promise<boolean>;
|
|
17
|
+
getActiveVersion(): Promise<PublishedVersion | null>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Versions client for publishing and managing configuration versions.
|
|
3
|
+
*/
|
|
4
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
7
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
8
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
9
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
10
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
14
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
15
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
16
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
17
|
+
function step(op) {
|
|
18
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
19
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
20
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
21
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
22
|
+
switch (op[0]) {
|
|
23
|
+
case 0: case 1: t = op; break;
|
|
24
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
25
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
26
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
27
|
+
default:
|
|
28
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
29
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
30
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
31
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
32
|
+
if (t[2]) _.ops.pop();
|
|
33
|
+
_.trys.pop(); continue;
|
|
34
|
+
}
|
|
35
|
+
op = body.call(thisArg, _);
|
|
36
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
37
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var VersionsClient = /** @class */ (function () {
|
|
41
|
+
function VersionsClient(baseUrl, chatId, getHeaders) {
|
|
42
|
+
this.baseUrl = baseUrl;
|
|
43
|
+
this.chatId = chatId;
|
|
44
|
+
this.getHeaders = getHeaders;
|
|
45
|
+
}
|
|
46
|
+
VersionsClient.prototype.request = function (method, endpoint, body, params) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
+
var queryString, url, response, error;
|
|
49
|
+
return __generator(this, function (_a) {
|
|
50
|
+
switch (_a.label) {
|
|
51
|
+
case 0:
|
|
52
|
+
queryString = params ? "?".concat(new URLSearchParams(params)) : "";
|
|
53
|
+
url = "".concat(this.baseUrl, "/").concat(endpoint).concat(queryString);
|
|
54
|
+
return [4 /*yield*/, fetch(url, {
|
|
55
|
+
method: method,
|
|
56
|
+
headers: this.getHeaders(),
|
|
57
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
58
|
+
})];
|
|
59
|
+
case 1:
|
|
60
|
+
response = _a.sent();
|
|
61
|
+
if (!!response.ok) return [3 /*break*/, 3];
|
|
62
|
+
return [4 /*yield*/, response.json().catch(function () { return ({ detail: response.statusText }); })];
|
|
63
|
+
case 2:
|
|
64
|
+
error = _a.sent();
|
|
65
|
+
throw new Error(error.detail || "HTTP ".concat(response.status));
|
|
66
|
+
case 3: return [2 /*return*/, response.json()];
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
// Publishing
|
|
72
|
+
VersionsClient.prototype.publish = function (version, description) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
+
return __generator(this, function (_a) {
|
|
75
|
+
return [2 /*return*/, this.request("POST", "v1/".concat(this.chatId, "/versions/publish"), {
|
|
76
|
+
version: version,
|
|
77
|
+
description: description,
|
|
78
|
+
})];
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
VersionsClient.prototype.listVersions = function () {
|
|
83
|
+
return __awaiter(this, arguments, void 0, function (page, limit) {
|
|
84
|
+
var result;
|
|
85
|
+
if (page === void 0) { page = 1; }
|
|
86
|
+
if (limit === void 0) { limit = 20; }
|
|
87
|
+
return __generator(this, function (_a) {
|
|
88
|
+
switch (_a.label) {
|
|
89
|
+
case 0: return [4 /*yield*/, this.request("GET", "v1/".concat(this.chatId, "/versions"), undefined, {
|
|
90
|
+
page: page.toString(),
|
|
91
|
+
limit: limit.toString(),
|
|
92
|
+
})];
|
|
93
|
+
case 1:
|
|
94
|
+
result = _a.sent();
|
|
95
|
+
return [2 /*return*/, result.versions];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
VersionsClient.prototype.getVersion = function (versionId) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
+
return __generator(this, function (_a) {
|
|
103
|
+
return [2 /*return*/, this.request("GET", "v1/".concat(this.chatId, "/versions/").concat(versionId))];
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
// Rollback
|
|
108
|
+
VersionsClient.prototype.rollback = function (versionId) {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
110
|
+
var result;
|
|
111
|
+
return __generator(this, function (_a) {
|
|
112
|
+
switch (_a.label) {
|
|
113
|
+
case 0: return [4 /*yield*/, this.request("POST", "v1/".concat(this.chatId, "/versions/").concat(versionId, "/rollback"))];
|
|
114
|
+
case 1:
|
|
115
|
+
result = _a.sent();
|
|
116
|
+
return [2 /*return*/, result.success];
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
VersionsClient.prototype.compareVersions = function (versionA, versionB) {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
123
|
+
return __generator(this, function (_a) {
|
|
124
|
+
return [2 /*return*/, this.request("GET", "v1/".concat(this.chatId, "/versions/compare"), undefined, {
|
|
125
|
+
version_a: versionA,
|
|
126
|
+
version_b: versionB,
|
|
127
|
+
})];
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
// Status
|
|
132
|
+
VersionsClient.prototype.getUnpublishedChanges = function () {
|
|
133
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
134
|
+
var result;
|
|
135
|
+
return __generator(this, function (_a) {
|
|
136
|
+
switch (_a.label) {
|
|
137
|
+
case 0: return [4 /*yield*/, this.request("GET", "v1/".concat(this.chatId, "/versions/unpublished-changes"))];
|
|
138
|
+
case 1:
|
|
139
|
+
result = _a.sent();
|
|
140
|
+
return [2 /*return*/, result.has_changes];
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
VersionsClient.prototype.getActiveVersion = function () {
|
|
146
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
147
|
+
var result;
|
|
148
|
+
return __generator(this, function (_a) {
|
|
149
|
+
switch (_a.label) {
|
|
150
|
+
case 0: return [4 /*yield*/, this.request("GET", "v1/".concat(this.chatId, "/versions/active"))];
|
|
151
|
+
case 1:
|
|
152
|
+
result = _a.sent();
|
|
153
|
+
return [2 /*return*/, result.version || null];
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
return VersionsClient;
|
|
159
|
+
}());
|
|
160
|
+
export { VersionsClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
export { TrainlyProvider } from "./TrainlyProvider";
|
|
2
2
|
export { useTrainly } from "./useTrainly";
|
|
3
3
|
export { TrainlyClient } from "./api/TrainlyClient";
|
|
4
|
+
export { TestingClient } from "./api/TestingClient";
|
|
5
|
+
export { FineTuningClient } from "./api/FineTuningClient";
|
|
6
|
+
export { ConfigClient } from "./api/ConfigClient";
|
|
7
|
+
export { AnalyticsClient } from "./api/AnalyticsClient";
|
|
8
|
+
export { VersionsClient } from "./api/VersionsClient";
|
|
4
9
|
export { TrainlyChat } from "./components/TrainlyChat";
|
|
5
10
|
export { TrainlyUpload } from "./components/TrainlyUpload";
|
|
6
11
|
export { TrainlyStatus } from "./components/TrainlyStatus";
|
|
7
12
|
export { TrainlyFileManager } from "./components/TrainlyFileManager";
|
|
8
|
-
export type { TrainlyProviderProps, TrainlyConfig, ChatMessage, Citation, UploadResult, TextContent, BulkUploadResult, BulkUploadFileResult, FileInfo, FileListResult, FileDeleteResult, TrainlyError, TrainlyFileManagerProps, } from "./types";
|
|
13
|
+
export type { TrainlyProviderProps, TrainlyConfig, ChatMessage, Citation, UploadResult, TextContent, BulkUploadResult, BulkUploadFileResult, FileInfo, FileListResult, FileDeleteResult, TrainlyError, TrainlyFileManagerProps, TestSuite, TestCase, TestRun, TestRunResults, TestResult, TestAnalytics, TestAssertion, PaginatedSuites, PreferencePair, TrainingJob, PaginatedPairs, BatchResult, ValidationResults, ChatSettings, RagConfig, ChunkingConfig, RetrievalConfig, RerankingConfig, ValidationPolicy, RepairLoopConfig, QueryTrace, QueryTraceDetails, TokenUsage, TimingBreakdown, ChunkInfo, MetricsSummary, CostBreakdown, PerformanceStats, PublishedVersion, VersionDiff, FileSnapshot, } from "./types";
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,12 @@ export { TrainlyProvider } from "./TrainlyProvider";
|
|
|
3
3
|
export { useTrainly } from "./useTrainly";
|
|
4
4
|
// Core client (for non-React usage)
|
|
5
5
|
export { TrainlyClient } from "./api/TrainlyClient";
|
|
6
|
+
// Feature sub-clients (for direct usage)
|
|
7
|
+
export { TestingClient } from "./api/TestingClient";
|
|
8
|
+
export { FineTuningClient } from "./api/FineTuningClient";
|
|
9
|
+
export { ConfigClient } from "./api/ConfigClient";
|
|
10
|
+
export { AnalyticsClient } from "./api/AnalyticsClient";
|
|
11
|
+
export { VersionsClient } from "./api/VersionsClient";
|
|
6
12
|
// Pre-built components
|
|
7
13
|
export { TrainlyChat } from "./components/TrainlyChat";
|
|
8
14
|
export { TrainlyUpload } from "./components/TrainlyUpload";
|
package/dist/types.d.ts
CHANGED
|
@@ -100,6 +100,10 @@ export interface TrainlyContextValue {
|
|
|
100
100
|
answer: string;
|
|
101
101
|
citations?: Citation[];
|
|
102
102
|
}>;
|
|
103
|
+
askStream: (question: string, options?: {
|
|
104
|
+
scope_filters?: Record<string, string | number | boolean>;
|
|
105
|
+
onChunk?: (chunk: string) => void;
|
|
106
|
+
}) => AsyncGenerator<string, void, unknown>;
|
|
103
107
|
askWithCitations: (question: string) => Promise<{
|
|
104
108
|
answer: string;
|
|
105
109
|
citations: Citation[];
|
|
@@ -110,6 +114,22 @@ export interface TrainlyContextValue {
|
|
|
110
114
|
deleteFile: (fileId: string) => Promise<FileDeleteResult>;
|
|
111
115
|
bulkUploadFiles: (files: File[], scopeValues?: Record<string, string | number | boolean>) => Promise<BulkUploadResult>;
|
|
112
116
|
bulkUploadText: (textContents: TextContent[], scopeValues?: Record<string, string | number | boolean>) => Promise<BulkUploadResult>;
|
|
117
|
+
getChatSettings: () => Promise<{
|
|
118
|
+
success: boolean;
|
|
119
|
+
chat_id?: string;
|
|
120
|
+
settings?: any;
|
|
121
|
+
}>;
|
|
122
|
+
updateChatSettings: (settings: {
|
|
123
|
+
custom_prompt?: string;
|
|
124
|
+
temperature?: number;
|
|
125
|
+
max_tokens?: number;
|
|
126
|
+
selected_model?: string;
|
|
127
|
+
}) => Promise<{
|
|
128
|
+
success: boolean;
|
|
129
|
+
chat_id?: string;
|
|
130
|
+
updated?: any;
|
|
131
|
+
message?: string;
|
|
132
|
+
}>;
|
|
113
133
|
connectWithOAuthToken: (idToken: string) => Promise<void>;
|
|
114
134
|
isLoading: boolean;
|
|
115
135
|
isConnected: boolean;
|
|
@@ -120,3 +140,261 @@ export interface TrainlyContextValue {
|
|
|
120
140
|
sendMessage: (content: string) => Promise<void>;
|
|
121
141
|
clearMessages: () => void;
|
|
122
142
|
}
|
|
143
|
+
export interface TestAssertion {
|
|
144
|
+
type: "contains" | "exact" | "regex" | "semantic" | "negative";
|
|
145
|
+
value: string;
|
|
146
|
+
match_threshold?: number;
|
|
147
|
+
}
|
|
148
|
+
export interface TestResult {
|
|
149
|
+
case_id: string;
|
|
150
|
+
case_name: string;
|
|
151
|
+
passed: boolean;
|
|
152
|
+
actual_answer: string;
|
|
153
|
+
expected_answer: string;
|
|
154
|
+
failure_reason?: string;
|
|
155
|
+
execution_time_ms?: number;
|
|
156
|
+
assertions_passed?: number;
|
|
157
|
+
assertions_failed?: number;
|
|
158
|
+
}
|
|
159
|
+
export interface TestCase {
|
|
160
|
+
case_id: string;
|
|
161
|
+
name: string;
|
|
162
|
+
query: string;
|
|
163
|
+
expected_answer: string;
|
|
164
|
+
category: "golden" | "contradiction" | "multi_hop" | "numerical" | "negation" | "distractor" | "adversarial" | "paraphrase";
|
|
165
|
+
suite_id?: string;
|
|
166
|
+
expected_decision?: "ANSWER" | "NEEDS_INFO" | "REFUSE";
|
|
167
|
+
assertions?: TestAssertion[];
|
|
168
|
+
expected_source_file?: string;
|
|
169
|
+
last_result?: TestResult;
|
|
170
|
+
created_at?: string;
|
|
171
|
+
}
|
|
172
|
+
export interface TestSuite {
|
|
173
|
+
suite_id: string;
|
|
174
|
+
name: string;
|
|
175
|
+
description?: string;
|
|
176
|
+
test_count: number;
|
|
177
|
+
pass_rate?: number;
|
|
178
|
+
last_run_at?: string;
|
|
179
|
+
last_run_status?: "passed" | "failed" | "partial" | "running";
|
|
180
|
+
tags?: string[];
|
|
181
|
+
created_at?: string;
|
|
182
|
+
}
|
|
183
|
+
export interface PaginatedSuites {
|
|
184
|
+
suites: TestSuite[];
|
|
185
|
+
total: number;
|
|
186
|
+
page: number;
|
|
187
|
+
limit: number;
|
|
188
|
+
has_more: boolean;
|
|
189
|
+
}
|
|
190
|
+
export interface TestRun {
|
|
191
|
+
run_id: string;
|
|
192
|
+
suite_id: string;
|
|
193
|
+
status: "pending" | "running" | "completed" | "failed" | "cancelled";
|
|
194
|
+
started_at?: string;
|
|
195
|
+
completed_at?: string;
|
|
196
|
+
}
|
|
197
|
+
export interface TestRunResults {
|
|
198
|
+
run_id: string;
|
|
199
|
+
suite_id: string;
|
|
200
|
+
status: "running" | "completed" | "failed" | "cancelled";
|
|
201
|
+
passed: number;
|
|
202
|
+
failed: number;
|
|
203
|
+
total: number;
|
|
204
|
+
pass_rate: number;
|
|
205
|
+
started_at: string;
|
|
206
|
+
completed_at?: string;
|
|
207
|
+
duration_ms?: number;
|
|
208
|
+
results: TestResult[];
|
|
209
|
+
}
|
|
210
|
+
export interface TestAnalytics {
|
|
211
|
+
suite_id: string;
|
|
212
|
+
total_runs: number;
|
|
213
|
+
average_pass_rate: number;
|
|
214
|
+
average_duration_ms: number;
|
|
215
|
+
total_tests: number;
|
|
216
|
+
pass_trend?: number[];
|
|
217
|
+
}
|
|
218
|
+
export interface ValidationResults {
|
|
219
|
+
preferred_passed: boolean;
|
|
220
|
+
non_preferred_passed: boolean;
|
|
221
|
+
validators_failed?: string[];
|
|
222
|
+
}
|
|
223
|
+
export interface PreferencePair {
|
|
224
|
+
pair_id: string;
|
|
225
|
+
input_messages: Array<{
|
|
226
|
+
role: string;
|
|
227
|
+
content: string;
|
|
228
|
+
}>;
|
|
229
|
+
preferred_output: string;
|
|
230
|
+
non_preferred_output: string;
|
|
231
|
+
status: "draft" | "approved" | "rejected" | "used_in_training";
|
|
232
|
+
source: "manual" | "ai_generated" | "from_test_run" | "from_query_logs";
|
|
233
|
+
validation_results?: ValidationResults;
|
|
234
|
+
notes?: string;
|
|
235
|
+
created_at?: string;
|
|
236
|
+
}
|
|
237
|
+
export interface PaginatedPairs {
|
|
238
|
+
pairs: PreferencePair[];
|
|
239
|
+
total: number;
|
|
240
|
+
page: number;
|
|
241
|
+
limit: number;
|
|
242
|
+
has_more: boolean;
|
|
243
|
+
}
|
|
244
|
+
export interface BatchResult {
|
|
245
|
+
success: boolean;
|
|
246
|
+
total: number;
|
|
247
|
+
successful: number;
|
|
248
|
+
failed: number;
|
|
249
|
+
errors?: string[];
|
|
250
|
+
}
|
|
251
|
+
export interface TrainingJob {
|
|
252
|
+
job_id: string;
|
|
253
|
+
openai_job_id?: string;
|
|
254
|
+
base_model: string;
|
|
255
|
+
fine_tuned_model_id?: string;
|
|
256
|
+
status: "preparing" | "uploading" | "queued" | "running" | "succeeded" | "failed" | "cancelled";
|
|
257
|
+
num_pairs: number;
|
|
258
|
+
progress?: number;
|
|
259
|
+
started_at?: string;
|
|
260
|
+
completed_at?: string;
|
|
261
|
+
error?: string;
|
|
262
|
+
suffix?: string;
|
|
263
|
+
beta: number;
|
|
264
|
+
}
|
|
265
|
+
export interface ChunkingConfig {
|
|
266
|
+
strategy: "auto" | "fixed_size" | "semantic" | "sentence" | "paragraph" | "code" | "custom";
|
|
267
|
+
chunk_size?: number;
|
|
268
|
+
chunk_overlap?: number;
|
|
269
|
+
max_chunk_size?: number;
|
|
270
|
+
}
|
|
271
|
+
export interface RetrievalConfig {
|
|
272
|
+
mode: "hybrid" | "vector" | "keyword";
|
|
273
|
+
vector_weight?: number;
|
|
274
|
+
keyword_weight?: number;
|
|
275
|
+
top_k: number;
|
|
276
|
+
similarity_threshold: number;
|
|
277
|
+
}
|
|
278
|
+
export interface RerankingConfig {
|
|
279
|
+
enabled: boolean;
|
|
280
|
+
model: "cohere" | "cross_encoder" | "none";
|
|
281
|
+
top_n?: number;
|
|
282
|
+
}
|
|
283
|
+
export interface RagConfig {
|
|
284
|
+
chunking: ChunkingConfig;
|
|
285
|
+
retrieval: RetrievalConfig;
|
|
286
|
+
reranking: RerankingConfig;
|
|
287
|
+
}
|
|
288
|
+
export interface ValidationPolicy {
|
|
289
|
+
forbidden_phrases?: string[];
|
|
290
|
+
required_phrases?: string[];
|
|
291
|
+
pii_detection_enabled: boolean;
|
|
292
|
+
banned_packages?: string[];
|
|
293
|
+
required_packages?: string[];
|
|
294
|
+
require_error_handling: boolean;
|
|
295
|
+
max_response_length?: number;
|
|
296
|
+
require_citations: boolean;
|
|
297
|
+
}
|
|
298
|
+
export interface RepairLoopConfig {
|
|
299
|
+
enabled: boolean;
|
|
300
|
+
max_retries: number;
|
|
301
|
+
}
|
|
302
|
+
export interface ChatSettings {
|
|
303
|
+
chat_id: string;
|
|
304
|
+
model?: string;
|
|
305
|
+
temperature?: number;
|
|
306
|
+
max_tokens?: number;
|
|
307
|
+
custom_prompt?: string;
|
|
308
|
+
repair_loop?: RepairLoopConfig;
|
|
309
|
+
rag_config?: RagConfig;
|
|
310
|
+
validation_policy?: ValidationPolicy;
|
|
311
|
+
}
|
|
312
|
+
export interface TokenUsage {
|
|
313
|
+
prompt_tokens: number;
|
|
314
|
+
completion_tokens: number;
|
|
315
|
+
total_tokens: number;
|
|
316
|
+
}
|
|
317
|
+
export interface TimingBreakdown {
|
|
318
|
+
preprocessing_time: number;
|
|
319
|
+
embedding_time: number;
|
|
320
|
+
retrieval_time: number;
|
|
321
|
+
reranking_time: number;
|
|
322
|
+
context_assembly_time: number;
|
|
323
|
+
prompt_construction_time: number;
|
|
324
|
+
llm_time: number;
|
|
325
|
+
postprocessing_time: number;
|
|
326
|
+
total_time: number;
|
|
327
|
+
}
|
|
328
|
+
export interface ChunkInfo {
|
|
329
|
+
chunk_id: string;
|
|
330
|
+
score: number;
|
|
331
|
+
source_file: string;
|
|
332
|
+
chunk_text: string;
|
|
333
|
+
rank_before_rerank?: number;
|
|
334
|
+
rank_after_rerank?: number;
|
|
335
|
+
}
|
|
336
|
+
export interface QueryTrace {
|
|
337
|
+
trace_id: string;
|
|
338
|
+
query: string;
|
|
339
|
+
response: string;
|
|
340
|
+
status: "success" | "error";
|
|
341
|
+
total_time_ms: number;
|
|
342
|
+
tokens: TokenUsage;
|
|
343
|
+
cost: number;
|
|
344
|
+
timestamp: string;
|
|
345
|
+
}
|
|
346
|
+
export interface QueryTraceDetails extends QueryTrace {
|
|
347
|
+
timing: TimingBreakdown;
|
|
348
|
+
chunks: ChunkInfo[];
|
|
349
|
+
full_prompt?: string;
|
|
350
|
+
}
|
|
351
|
+
export interface MetricsSummary {
|
|
352
|
+
total_queries: number;
|
|
353
|
+
successful_queries: number;
|
|
354
|
+
failed_queries: number;
|
|
355
|
+
average_response_time_ms: number;
|
|
356
|
+
total_cost: number;
|
|
357
|
+
average_cost_per_query: number;
|
|
358
|
+
date_range_start: string;
|
|
359
|
+
date_range_end: string;
|
|
360
|
+
}
|
|
361
|
+
export interface CostBreakdown {
|
|
362
|
+
total_cost: number;
|
|
363
|
+
embedding_cost: number;
|
|
364
|
+
llm_cost: number;
|
|
365
|
+
reranking_cost: number;
|
|
366
|
+
date_range_start: string;
|
|
367
|
+
date_range_end: string;
|
|
368
|
+
}
|
|
369
|
+
export interface PerformanceStats {
|
|
370
|
+
p50_response_time_ms: number;
|
|
371
|
+
p95_response_time_ms: number;
|
|
372
|
+
p99_response_time_ms: number;
|
|
373
|
+
average_chunks_retrieved: number;
|
|
374
|
+
average_tokens_per_query: number;
|
|
375
|
+
}
|
|
376
|
+
export interface FileSnapshot {
|
|
377
|
+
file_id: string;
|
|
378
|
+
filename: string;
|
|
379
|
+
size_bytes: number;
|
|
380
|
+
chunk_count: number;
|
|
381
|
+
}
|
|
382
|
+
export interface PublishedVersion {
|
|
383
|
+
version_id: string;
|
|
384
|
+
version: string;
|
|
385
|
+
status: "active" | "superseded" | "corrupted";
|
|
386
|
+
description?: string;
|
|
387
|
+
settings_snapshot?: Record<string, any>;
|
|
388
|
+
file_snapshots?: FileSnapshot[];
|
|
389
|
+
total_files: number;
|
|
390
|
+
published_at?: string;
|
|
391
|
+
published_by?: string;
|
|
392
|
+
}
|
|
393
|
+
export interface VersionDiff {
|
|
394
|
+
version_a: string;
|
|
395
|
+
version_b: string;
|
|
396
|
+
settings_changed: string[];
|
|
397
|
+
files_added: string[];
|
|
398
|
+
files_removed: string[];
|
|
399
|
+
files_modified: string[];
|
|
400
|
+
}
|