Spaces:
Running on Zero
Running on Zero
Manoj Kumar Thapa
feat: CogniGraph – turn documents into a 3D knowledge graph you can chat with
fafd7a2 Download frontend/src/lib/api.js from manojthapaa/Cognigraph: direct link, hf CLI and curl.
- Browser
- Download file 712 Bytes
-
https://huggingface.co/spaces/manojthapaa/Cognigraph/resolve/main/frontend/src/lib/api.js
- Command line
-
hf download hf://spaces/manojthapaa/Cognigraph/frontend/src/lib/api.js
-
curl -L -o api.js https://huggingface.co/spaces/manojthapaa/Cognigraph/resolve/main/frontend/src/lib/api.js
712 Bytes
| import axios from 'axios'; | |
| export const API_URL = import.meta.env.VITE_API_URL || ''; | |
| // Generate or retrieve a Session ID so each browser gets its own graph + vector store | |
| const getSessionId = () => { | |
| const fresh = () => (crypto.randomUUID ? crypto.randomUUID() : Math.random().toString(36).substring(2) + Date.now().toString(36)); | |
| try { | |
| let sid = localStorage.getItem('cognigraph-session-id'); | |
| if (!sid) { | |
| sid = fresh(); | |
| localStorage.setItem('cognigraph-session-id', sid); | |
| } | |
| return sid; | |
| } catch { | |
| return fresh(); | |
| } | |
| }; | |
| export const api = axios.create({ | |
| baseURL: API_URL, | |
| headers: { 'X-Session-ID': getSessionId() }, | |
| }); | |