This commit is contained in:
xds
2026-02-04 14:43:22 +03:00
commit 4f460b2876
40 changed files with 11425 additions and 0 deletions

70
src/services/aiService.js Normal file
View File

@@ -0,0 +1,70 @@
import api from './api'
// Mock responses for demo purposes since we don't have real backend/keys yet
const mockResponses = {
'chatgpt': "I'm ChatGPT. I can help you with code, writing, and more.",
'gemini': "I'm Gemini. I can reason across text, code, images, and video.",
'nana-banana': "I'm Nana Banana! Let's make something fun and creative.",
'kling': "I'm Kling. I specialize in high-quality video generation."
}
export const aiService = {
// Send message to specific AI model
async sendMessage(modelId, message, history = []) {
// In a real app, this would be:
// return api.post(`/ai/${modelId}/chat`, { message, history })
// Simulating API call
return new Promise((resolve) => {
setTimeout(() => {
const response = mockResponses[modelId] || "I'm an AI assistant.";
resolve({
id: Date.now(),
role: 'assistant',
content: `${response} (Response to: "${message.substring(0, 20)}...")`,
timestamp: new Date()
})
}, 1000 + Math.random() * 1000)
})
},
// Get available models
async getModels() {
// return api.get('/models')
return [
{ id: 'chatgpt', name: 'ChatGPT', provider: 'OpenAI' },
{ id: 'gemini', name: 'Gemini', provider: 'Google' },
{ id: 'nana-banana', name: 'Nana Banana', provider: 'Custom' },
{ id: 'kling', name: 'Kling', provider: 'Kling AI' }
]
},
// Run generation task
async runGeneration(payload) {
const response = await api.post('/generations/_run', payload)
return response.data
},
// Get generation status
async getGenerationStatus(id) {
const response = await api.get(`/generations/${id}`)
return response.data
},
// Get generations history
async getGenerations(limit, offset, characterId) {
const params = { limit, offset }
if (characterId) params.character_id = characterId
const response = await api.get('/generations', { params })
return response.data
},
// Improve prompt using assistant
async improvePrompt(prompt, linkedAssets = []) {
const response = await api.post('/generations/prompt-assistant', {
prompt,
linked_assets: linkedAssets
})
return response.data
}
}

20
src/services/api.js Normal file
View File

@@ -0,0 +1,20 @@
import axios from 'axios'
const api = axios.create({
baseURL: import.meta.env.VITE_API_URL || '/api',
timeout: 60000,
headers: {
'Content-Type': 'application/json'
}
})
// Request interceptor handling can be added here if needed
api.interceptors.response.use(
response => response,
error => {
return Promise.reject(error)
}
)
export default api

View File

@@ -0,0 +1,45 @@
import api from './api'
export const dataService = {
getAssets: async (limit, offset, type) => {
const params = { limit, offset }
if (type && type !== 'all') params.type = type
const response = await api.get('/assets', { params })
return response.data
},
getAsset: async (id) => {
const response = await api.get(`/assets/${id}`)
return response.data
},
getCharacters: async () => {
// Spec says /api/characters/ (with trailing slash) but usually client shouldn't matter too much if config is good,
// but let's follow spec if strictly needed. Axios usually handles this.
const response = await api.get('/characters/')
return response.data
},
getCharacterById: async (id) => {
const response = await api.get(`/characters/${id}`)
return response.data
},
getAssetsByCharacterId: async (charId, limit, offset) => {
const response = await api.get(`/characters/${charId}/assets`, { params: { limit, offset } })
return response.data
},
uploadAsset: async (file, linkedCharId) => {
const formData = new FormData()
formData.append('file', file)
if (linkedCharId) formData.append('linked_char_id', linkedCharId)
const response = await api.post('/assets/upload', formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
})
return response.data
}
}