forked from gilbertofke/Klymate-AI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaiService.js
More file actions
71 lines (60 loc) · 2.18 KB
/
Copy pathaiService.js
File metadata and controls
71 lines (60 loc) · 2.18 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
60
61
62
63
64
65
66
67
68
69
70
71
import apiClient from './api'
export const aiService = {
// Chat with AI coach
chat: async (message, conversationId = null) => {
const response = await apiClient.post('/ai/chat', {
message,
conversation_id: conversationId
})
return response.data
},
// Get personalized suggestions
getSuggestions: async (category = null, limit = 5) => {
const params = new URLSearchParams()
if (category) params.append('category', category)
params.append('limit', limit)
const response = await apiClient.get(`/ai/suggestions?${params}`)
return response.data
},
// Get conversation history
getConversationHistory: async (conversationId, limit = 50) => {
const response = await apiClient.get(`/ai/conversations/${conversationId}?limit=${limit}`)
return response.data
},
// Get all user conversations
getConversations: async () => {
const response = await apiClient.get('/ai/conversations')
return response.data
},
// Create new conversation
createConversation: async (title = 'New Conversation') => {
const response = await apiClient.post('/ai/conversations', { title })
return response.data
},
// Delete conversation
deleteConversation: async (conversationId) => {
const response = await apiClient.delete(`/ai/conversations/${conversationId}`)
return response.data
},
// Get AI insights based on user data
getInsights: async (timeframe = 'week') => {
const response = await apiClient.get(`/ai/insights?timeframe=${timeframe}`)
return response.data
},
// Get personalized goals
getGoals: async () => {
const response = await apiClient.get('/ai/goals')
return response.data
},
// Update goal progress
updateGoalProgress: async (goalId, progress) => {
const response = await apiClient.put(`/ai/goals/${goalId}/progress`, { progress })
return response.data
},
// Get coaching tips based on current habits
getCoachingTips: async (category = null) => {
const params = category ? `?category=${category}` : ''
const response = await apiClient.get(`/ai/coaching-tips${params}`)
return response.data
}
}