mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-09-01 21:00:58 +00:00
refactor(ai): extract assistant into an official module (#749)
* feat(modules): expose host data boundaries * feat(modules): add frontend extension surfaces * refactor(ai): remove assistant from core * chore(ai): prepare the module extraction * fix(modules): load extension styles after the host bundle * chore(modules): lock SDK 3.3.0
This commit is contained in:
@@ -116,25 +116,6 @@ export const API = {
|
||||
COMPANY_MAIL_CONFIG: '/api/v1/company/mail/company-config',
|
||||
COMPANY_MAIL_TEST: '/api/v1/company/mail/company-test',
|
||||
|
||||
// AI Configuration (global)
|
||||
AI_DRIVERS: '/api/v1/ai/drivers',
|
||||
AI_CONFIG: '/api/v1/ai/config',
|
||||
AI_TEST: '/api/v1/ai/test',
|
||||
|
||||
// Company AI Configuration
|
||||
COMPANY_AI_CONFIG: '/api/v1/company/ai/config',
|
||||
COMPANY_AI_TEST: '/api/v1/company/ai/test',
|
||||
|
||||
// Installer AI Configuration
|
||||
INSTALLATION_AI_CONFIG: '/api/v1/installation/ai/config',
|
||||
|
||||
// AI Chat (Phase 2)
|
||||
AI_CHAT: '/api/v1/ai/chat',
|
||||
AI_CONVERSATIONS: '/api/v1/ai/conversations',
|
||||
|
||||
// AI Text Generation (Phase 3)
|
||||
AI_GENERATE: '/api/v1/ai/generate',
|
||||
|
||||
// PDF Configuration
|
||||
PDF_DRIVERS: '/api/v1/pdf/drivers',
|
||||
PDF_CONFIG: '/api/v1/pdf/config',
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
import { client } from '../client'
|
||||
import { API } from '../endpoints'
|
||||
import type {
|
||||
AiChatSendResponse,
|
||||
AiConfig,
|
||||
AiConversationDetail,
|
||||
AiConversationSummary,
|
||||
AiDriversResponse,
|
||||
AiGenerateRequest,
|
||||
AiGenerateResponse,
|
||||
AiTestPayload,
|
||||
AiTestResponse,
|
||||
CompanyAiConfig,
|
||||
} from '@/scripts/types/ai-config'
|
||||
|
||||
export const aiService = {
|
||||
// Driver catalog — same shape across admin, company, installer contexts.
|
||||
async getDrivers(): Promise<AiDriversResponse> {
|
||||
const { data } = await client.get(API.AI_DRIVERS)
|
||||
return data
|
||||
},
|
||||
|
||||
// --- Global (admin) ---
|
||||
|
||||
async getGlobalConfig(): Promise<AiConfig> {
|
||||
const { data } = await client.get(API.AI_CONFIG)
|
||||
return data
|
||||
},
|
||||
|
||||
async saveGlobalConfig(payload: AiConfig): Promise<{ success?: string; error?: string }> {
|
||||
const { data } = await client.post(API.AI_CONFIG, payload)
|
||||
return data
|
||||
},
|
||||
|
||||
async testGlobalConnection(payload: AiTestPayload): Promise<AiTestResponse> {
|
||||
const { data } = await client.post(API.AI_TEST, payload)
|
||||
return data
|
||||
},
|
||||
|
||||
// --- Per-company ---
|
||||
|
||||
async getCompanyConfig(): Promise<CompanyAiConfig> {
|
||||
const { data } = await client.get(API.COMPANY_AI_CONFIG)
|
||||
return data
|
||||
},
|
||||
|
||||
async saveCompanyConfig(payload: CompanyAiConfig): Promise<{ success?: boolean; error?: string }> {
|
||||
const { data } = await client.post(API.COMPANY_AI_CONFIG, payload)
|
||||
return data
|
||||
},
|
||||
|
||||
async testCompanyConnection(payload: AiTestPayload): Promise<AiTestResponse> {
|
||||
const { data } = await client.post(API.COMPANY_AI_TEST, payload)
|
||||
return data
|
||||
},
|
||||
|
||||
// --- Phase 2: chat ---
|
||||
|
||||
async sendChatMessage(
|
||||
conversationId: number | null,
|
||||
message: string,
|
||||
): Promise<AiChatSendResponse> {
|
||||
const { data } = await client.post(API.AI_CHAT, {
|
||||
conversation_id: conversationId,
|
||||
message,
|
||||
})
|
||||
return data
|
||||
},
|
||||
|
||||
async listConversations(): Promise<{ conversations: AiConversationSummary[] }> {
|
||||
const { data } = await client.get(API.AI_CONVERSATIONS)
|
||||
return data
|
||||
},
|
||||
|
||||
async getConversation(id: number): Promise<AiConversationDetail> {
|
||||
const { data } = await client.get(`${API.AI_CONVERSATIONS}/${id}`)
|
||||
return data
|
||||
},
|
||||
|
||||
async renameConversation(id: number, title: string): Promise<{ success: boolean }> {
|
||||
const { data } = await client.patch(`${API.AI_CONVERSATIONS}/${id}`, { title })
|
||||
return data
|
||||
},
|
||||
|
||||
async deleteConversation(id: number): Promise<{ success: boolean }> {
|
||||
const { data } = await client.delete(`${API.AI_CONVERSATIONS}/${id}`)
|
||||
return data
|
||||
},
|
||||
|
||||
// --- Phase 3: text generation ---
|
||||
|
||||
async generateText(payload: AiGenerateRequest): Promise<AiGenerateResponse> {
|
||||
const { data } = await client.post(API.AI_GENERATE, payload)
|
||||
return data
|
||||
},
|
||||
}
|
||||
@@ -29,11 +29,6 @@ export interface BootstrapResponse {
|
||||
config: Record<string, unknown>
|
||||
global_settings: Record<string, string>
|
||||
modules: string[]
|
||||
ai?: {
|
||||
enabled: boolean
|
||||
chat_enabled: boolean
|
||||
text_generation_enabled: boolean
|
||||
}
|
||||
user_menu?: Array<{ title: string; link: string; icon: string; priority: number; name: string }>
|
||||
admin_mode?: boolean
|
||||
pending_invitations?: Array<{
|
||||
|
||||
Reference in New Issue
Block a user