-
Notifications
You must be signed in to change notification settings - Fork 264
/
Copy pathAiIntergrationsService.js
48 lines (42 loc) · 1.1 KB
/
AiIntergrationsService.js
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
import { generateUrl } from '@nextcloud/router'
import axios from '@nextcloud/axios'
import { convertAxiosError } from '../errors/convert.js'
export const summarizeThread = async (threadId) => {
const url = generateUrl('/apps/mail/api/thread/{threadId}/summary', {
threadId,
})
try {
const resp = await axios.get(url)
if (resp.status === 204) {
throw new Error('Thread summary failed, error in the llm service')
}
return resp.data.data
} catch (e) {
throw convertAxiosError(e)
}
}
export const generateEventData = async (threadId) => {
const url = generateUrl('/apps/mail/api/thread/{threadId}/eventdata', {
threadId,
})
try {
const resp = await axios.get(url)
return resp.data.data
} catch (e) {
throw convertAxiosError(e)
}
}
export const smartReply = async (messageId) => {
const url = generateUrl('/apps/mail/api/messages/{messageId}/smartreply', {
messageId,
})
try {
const resp = await axios.get(url)
if (resp.status === 204) {
throw new Error('Thread summary failed, error in the llm service')
}
return resp.data
} catch (e) {
throw convertAxiosError(e)
}
}