-
Notifications
You must be signed in to change notification settings - Fork 341
/
Copy pathchatdoc.ts
87 lines (73 loc) · 1.99 KB
/
chatdoc.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
import { ACTION_CREATE, ACTION_DELETE, ACTION_UPDATE, ROLE_ASSISTANT, ROLE_SYSTEM, ROLE_USER } from '@/constants';
export interface IError {
code: string;
detail?: string;
}
export interface IChatdocRepository {
id: string;
name?: string;
description?: string;
deleting?: boolean;
editing?: boolean;
documents?: IChatdocDocument[];
conversations?: IChatdocConversation[];
}
export interface IChatdocRepositoryRequest extends IChatdocRepository {
action: typeof ACTION_CREATE | typeof ACTION_UPDATE | typeof ACTION_DELETE;
}
export interface IChatdocRepositoryResponse extends IChatdocRepository {}
export type IChatdocRepositoriesResponse = {
items: IChatdocRepository[];
count: number;
};
export interface IChatdocDocument {
id: string;
repository_id: string;
file_url: string;
file_name: string;
}
export interface IChatdocDocumentRequest extends IChatdocDocument {
action: typeof ACTION_CREATE | typeof ACTION_UPDATE | typeof ACTION_DELETE;
callback_url?: string;
}
export interface IChatdocDocumentResponse extends IChatdocDocument {}
export type IChatdocDocumentsResponse = {
items: IChatdocDocument[];
count: number;
};
export interface IChatdocConversation {
id: string;
repository_id: string;
messages: IChatdocMessage[];
question: string;
editing?: boolean;
deleting?: boolean;
}
export interface IChatdocMessage {
content?: string;
error?: IError;
state?: IChatdocMessageState;
role?: typeof ROLE_SYSTEM | typeof ROLE_ASSISTANT | typeof ROLE_USER;
}
export enum IChatdocMessageState {
PENDING = 'pending',
ANSWERING = 'answering',
FINISHED = 'finished',
FAILED = 'failed'
}
export interface IChatdocConversationRequest {
id: string;
repository_id: string;
question: string;
temperature?: number;
knowledge_fallback?: boolean;
}
export type IChatdocConversationsResponse = {
items: IChatdocConversation[];
count: number;
};
export interface IChatdocConversationResponse {
id: string;
answer: string;
delta_answer?: string;
}