chatgptApi.js
1.55 KB
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
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-02-23 15:18:36
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-02-23 15:18:44
* @FilePath: \dj-scrm-wx-work-attachment-psd\src\api\chatgptApi.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
const url = '/rop-scrm-marketing/router'
import { utils } from 'glsx-common'
export default {
/**查询喜报战报推送日志分页列表 */
issueChatGpt(data) {
const method = 'scrm.api.knowledge.gptchat'
return httpRequest(method, data)
},
/**
* 获取AI id
*/
getAiId(data) {
data.method = 'marketing.api.scriptlibrary.ai.id'
return window.$HTTP({
url,
data,
returnAll: true
})
},
/**
* 新增聊天记录
*/
updatedAiRecord(data) {
data.method = 'marketing.api.scriptlibrary.ai.record.add'
return window.$HTTP({
url,
data
})
}
}
const httpRequest = (method, data) => {
const { secret, sign, request } = window.$fetchConfig
Object.assign(data, {
method,
...sign
})
return new Promise((resolve, reject) => {
window
.fetch(`${request.chatGptURL}/router/${method}/1.0.0`, {
method: 'POST',
headers: { 'Content-Type': 'application/json;charset=UTF-8' },
body: JSON.stringify(utils.createSign(data, secret))
})
.then(res => {
resolve(res.json())
})
.catch(err => {
reject(err)
})
})
}