File size: 4,551 Bytes
1f7ead8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import axios from 'axios';

const instance = axios.create({
    baseURL: import.meta.env.VITE_BACKEND_URL || 'http://localhost:8000',
    timeout: 300000, // 5 minutes timeout
});

const API_URL = import.meta.env.VITE_BACKEND_URL || 'http://localhost:8000';

// Notebooks
export const createNotebook = async (name, description) => {
    const response = await instance.post(`/notebooks`, { name, description });
    return response.data;
};

export const listNotebooks = async () => {
    const response = await instance.get(`/notebooks`);
    return response.data;
};

export const getNotebook = async (id) => {
    const response = await instance.get(`/notebooks/${id}`);
    return response.data;
};

export const deleteNotebook = async (id) => {
    const response = await instance.delete(`/notebooks/${id}`);
    return response.data;
};

export const getNotebookChat = async (id) => {
    const response = await instance.get(`/notebooks/${id}/chat`);
    return response.data;
};

export const getNotebookDocuments = async (id) => {
    const response = await instance.get(`/notebooks/${id}/documents`);
    return response.data;
};

// Search & Import
export const searchPapers = async (query, mode = 'academic') => {
    const response = await instance.post(`/search`, { query, mode });
    return response.data;
};

export const importPaper = async (notebookId, paperData) => {
    // paperData: { title, url, source, ... }
    const response = await instance.post(`/import_paper`, { notebookId, ...paperData });
    return response.data;
};

// Ingestion
export const ingestPDF = async (file, notebookId) => {
    const formData = new FormData();
    formData.append('file', file);
    formData.append('notebook_id', notebookId);
    const response = await instance.post(`/ingest`, formData, {
        headers: {
            'Content-Type': 'multipart/form-data',
        },
    });
    return response.data;
};

export const querySystem = async (query, notebookId) => {
    const response = await instance.post(`/query`, {
        query,
        notebook_id: notebookId
    });
    return response.data;
};

export const generateSourceContent = async (type, notebookId) => {
    try {
        const response = await instance.post(`/generate`, {
            type: type,
            notebook_id: notebookId,
            context_filter: [],
            graph_context: []
        });
        return response.data;
    } catch (error) {
        console.error("Content generation failed:", error);
        throw error;
    }
};

export const expandMindMapNode = async (nodeLabel, notebookId) => {
    try {
        const response = await instance.post(`/expand_node_mind_map`, {
            node_label: nodeLabel,
            notebook_id: notebookId || "default",
            context_filter: []
        });
        return response.data;
    } catch (error) {
        console.error("Node expansion failed:", error);
        throw error;
    }

};

export const generateAudio = async (script) => {
    const response = await instance.post(`/audio-overview`, { script });
    return response.data;
};

export const generateSlideDeck = async (notebookId) => {
    const response = await instance.post(`/generate-slide-deck`, { notebook_id: notebookId });
    return response.data;
};

export const generateQuiz = async (notebookId, difficulty = 'medium') => {
    const response = await instance.post(`/generate-quiz`, { notebook_id: notebookId, difficulty });
    return response.data;
};

export const generateFlashcards = async (notebookId, numCards = 10, difficulty = 'medium') => {
    const response = await instance.post(`/generate-flashcards`, {
        notebook_id: notebookId,
        num_cards: numCards,
        difficulty
    });
    return response.data;
};

export const generateInfographic = async (notebookId) => {
    const response = await instance.post(`/generate-infographic`, { notebook_id: notebookId });
    return response.data;
};

export const generateTable = async (notebookId, prompt) => {
    const response = await instance.post(`/generate-table`, { notebook_id: notebookId, prompt });
    return response.data;
};

export const generateReport = async (notebookId, reportType, topic = "") => {
    const response = await instance.post(`/generate-report`, {
        notebook_id: notebookId,
        report_type: reportType,
        topic
    });
    return response.data;
};