| import axios from 'axios';
|
|
|
| const instance = axios.create({
|
| baseURL: import.meta.env.VITE_BACKEND_URL || 'http://localhost:8000',
|
| timeout: 300000,
|
| });
|
|
|
| const API_URL = import.meta.env.VITE_BACKEND_URL || 'http://localhost:8000';
|
|
|
|
|
| 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;
|
| };
|
|
|
|
|
| export const searchPapers = async (query, mode = 'academic') => {
|
| const response = await instance.post(`/search`, { query, mode });
|
| return response.data;
|
| };
|
|
|
| export const importPaper = async (notebookId, paperData) => {
|
|
|
| const response = await instance.post(`/import_paper`, { notebookId, ...paperData });
|
| return response.data;
|
| };
|
|
|
|
|
| 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;
|
| };
|
|
|