|
| 1 | +import { Result } from '@/request/Result' |
| 2 | +import { |
| 3 | + get, |
| 4 | + post, |
| 5 | + exportExcelPost, |
| 6 | + postStream, |
| 7 | + del, |
| 8 | + put, |
| 9 | + request, |
| 10 | + download, |
| 11 | + exportFile, |
| 12 | +} from '@/request/index' |
| 13 | +import type { pageRequest } from '@/api/type/common' |
| 14 | +import type { ApplicationFormType } from '@/api/type/application' |
| 15 | +import { type Ref } from 'vue' |
| 16 | + |
| 17 | +const prefix = '/workspace/' + localStorage.getItem('workspace_id') + '/application' |
| 18 | +/** |
| 19 | + * 对话记录提交至知识库 |
| 20 | + * @param data |
| 21 | + * @param loading |
| 22 | + * @param application_id |
| 23 | + * @param knowledge_id |
| 24 | + */ |
| 25 | + |
| 26 | +const postChatLogAddKnowledge: ( |
| 27 | + application_id: string, |
| 28 | + data: any, |
| 29 | + loading?: Ref<boolean>, |
| 30 | +) => Promise<Result<any>> = (application_id, data, loading) => { |
| 31 | + return post(`${prefix}/${application_id}/add_knowledge`, data, undefined, loading) |
| 32 | +} |
| 33 | + |
| 34 | +/** |
| 35 | + * 对话日志 |
| 36 | + * @param 参数 |
| 37 | + * application_id |
| 38 | + * param { |
| 39 | + "start_time": "string", |
| 40 | + "end_time": "string", |
| 41 | + } |
| 42 | + */ |
| 43 | +const getChatLog: ( |
| 44 | + application_id: String, |
| 45 | + page: pageRequest, |
| 46 | + param: any, |
| 47 | + loading?: Ref<boolean>, |
| 48 | +) => Promise<Result<any>> = (application_id, page, param, loading) => { |
| 49 | + return get( |
| 50 | + `${prefix}/${application_id}/chat/${page.current_page}/${page.page_size}`, |
| 51 | + param, |
| 52 | + loading, |
| 53 | + ) |
| 54 | +} |
| 55 | + |
| 56 | +/** |
| 57 | + * 获得对话日志记录 |
| 58 | + * @param 参数 |
| 59 | + * application_id, chart_id,order_asc |
| 60 | + */ |
| 61 | +const getChatRecordLog: ( |
| 62 | + application_id: String, |
| 63 | + chart_id: String, |
| 64 | + page: pageRequest, |
| 65 | + loading?: Ref<boolean>, |
| 66 | + order_asc?: boolean, |
| 67 | +) => Promise<Result<any>> = (application_id, chart_id, page, loading, order_asc) => { |
| 68 | + return get( |
| 69 | + `${prefix}/${application_id}/chat/${chart_id}/chat_record/${page.current_page}/${page.page_size}`, |
| 70 | + { order_asc: order_asc !== undefined ? order_asc : true }, |
| 71 | + loading, |
| 72 | + ) |
| 73 | +} |
| 74 | + |
| 75 | +/** |
| 76 | + * 获取标注段落列表信息 |
| 77 | + * @param 参数 |
| 78 | + * application_id, chart_id, chart_record_id, knowledge_id, document_id |
| 79 | + */ |
| 80 | +const getMarkChatRecord: ( |
| 81 | + application_id: String, |
| 82 | + chart_id: String, |
| 83 | + chart_record_id: String, |
| 84 | + knowledge_id: String, |
| 85 | + document_id: String, |
| 86 | + loading?: Ref<boolean>, |
| 87 | +) => Promise<Result<any>> = ( |
| 88 | + application_id, |
| 89 | + chart_id, |
| 90 | + chart_record_id, |
| 91 | + knowledge_id, |
| 92 | + document_id, |
| 93 | + loading, |
| 94 | +) => { |
| 95 | + return get( |
| 96 | + `${prefix}/${application_id}/chat/${chart_id}/chat_record/${chart_record_id}/knowledge/${knowledge_id}/document/${document_id}/improve`, |
| 97 | + undefined, |
| 98 | + loading, |
| 99 | + ) |
| 100 | +} |
| 101 | + |
| 102 | +/** |
| 103 | + * 修改日志记录内容 |
| 104 | + * @param 参数 |
| 105 | + * application_id, chart_id, chart_record_id, knowledge_id, document_id |
| 106 | + * data { |
| 107 | + "title": "string", |
| 108 | + "content": "string", |
| 109 | + "problem_text": "string" |
| 110 | + } |
| 111 | + */ |
| 112 | +const putChatRecordLog: ( |
| 113 | + application_id: String, |
| 114 | + chart_id: String, |
| 115 | + chart_record_id: String, |
| 116 | + knowledge_id: String, |
| 117 | + document_id: String, |
| 118 | + data: any, |
| 119 | + loading?: Ref<boolean>, |
| 120 | +) => Promise<Result<any>> = ( |
| 121 | + application_id, |
| 122 | + chart_id, |
| 123 | + chart_record_id, |
| 124 | + knowledge_id, |
| 125 | + document_id, |
| 126 | + data, |
| 127 | + loading, |
| 128 | +) => { |
| 129 | + return put( |
| 130 | + `${prefix}/${application_id}/chat/${chart_id}/chat_record/${chart_record_id}/dataset/${knowledge_id}/document/${document_id}/improve`, |
| 131 | + data, |
| 132 | + undefined, |
| 133 | + loading, |
| 134 | + ) |
| 135 | +} |
| 136 | + |
| 137 | +/** |
| 138 | + * 删除标注 |
| 139 | + * @param 参数 |
| 140 | + * application_id, chart_id, chart_record_id, dataset_id, document_id,paragraph_id |
| 141 | + */ |
| 142 | +const delMarkChatRecord: ( |
| 143 | + application_id: String, |
| 144 | + chart_id: String, |
| 145 | + chart_record_id: String, |
| 146 | + knowledge_id: String, |
| 147 | + document_id: String, |
| 148 | + paragraph_id: String, |
| 149 | + loading?: Ref<boolean>, |
| 150 | +) => Promise<Result<any>> = ( |
| 151 | + application_id, |
| 152 | + chart_id, |
| 153 | + chart_record_id, |
| 154 | + knowledge_id, |
| 155 | + document_id, |
| 156 | + paragraph_id, |
| 157 | + loading, |
| 158 | +) => { |
| 159 | + return del( |
| 160 | + `${prefix}/${application_id}/chat/${chart_id}/chat_record/${chart_record_id}/knowledge/${knowledge_id}/document/${document_id}/paragraph/${paragraph_id}/improve`, |
| 161 | + undefined, |
| 162 | + {}, |
| 163 | + loading, |
| 164 | + ) |
| 165 | +} |
| 166 | + |
| 167 | +/** |
| 168 | + * 导出对话日志 |
| 169 | + * @param 参数 |
| 170 | + * application_id |
| 171 | + * param { |
| 172 | + "start_time": "string", |
| 173 | + "end_time": "string", |
| 174 | + } |
| 175 | + */ |
| 176 | +const postExportChatLog: ( |
| 177 | + application_id: string, |
| 178 | + application_name: string, |
| 179 | + param: any, |
| 180 | + data: any, |
| 181 | + loading?: Ref<boolean>, |
| 182 | +) => void = (application_id, application_name, param, data, loading) => { |
| 183 | + exportExcelPost( |
| 184 | + application_name + '.xlsx', |
| 185 | + `${prefix}/${application_id}/chat/export`, |
| 186 | + param, |
| 187 | + data, |
| 188 | + loading, |
| 189 | + ) |
| 190 | +} |
| 191 | + |
| 192 | +export default { |
| 193 | + postChatLogAddKnowledge, |
| 194 | + getChatLog, |
| 195 | + getChatRecordLog, |
| 196 | + getMarkChatRecord, |
| 197 | + putChatRecordLog, |
| 198 | + delMarkChatRecord, |
| 199 | + postExportChatLog, |
| 200 | +} |
0 commit comments