Last active
January 15, 2026 09:58
-
-
Save brojd/3f8faff370abe01b3dd3ed2ffea373db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { readFileSync } from 'fs'; | |
| const LIGHTRAG_URL = process.env.LIGHTRAG_URL || 'http://localhost:9621'; | |
| async function ingestTvShows() { | |
| const data = JSON.parse(readFileSync('tmdb_tv_shows.json', 'utf-8')); | |
| const tvShows = data.tv_shows; | |
| console.log(`Ingesting ${tvShows.length} TV shows into LightRAG`); | |
| console.log(`LightRAG URL: ${LIGHTRAG_URL}\n`); | |
| let success = 0; | |
| let failed = 0; | |
| for (const show of tvShows) { | |
| const document = ` | |
| Title: ${show.name} | |
| Original Title: ${show.original_name} | |
| First Air Date: ${show.first_air_date} | |
| Rating: ${show.vote_average}/10 (${show.vote_count} votes) | |
| Popularity: ${show.popularity} | |
| Language: ${show.original_language} | |
| Genre IDs: ${show.genre_ids.join(', ')} | |
| Origin Country: ${show.origin_country.join(', ')} | |
| Overview: | |
| ${show.overview} | |
| `.trim(); | |
| const fileSource = show.name.toLowerCase().replace(/[^a-z0-9]+/g, '_') + `_${show.id}.md`; | |
| try { | |
| const response = await fetch(`${LIGHTRAG_URL}/documents/text`, { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ text: document, file_source: fileSource }), | |
| }); | |
| if (response.ok) { | |
| console.log(`✓ Ingested: ${show.name} (${show.vote_average}/10)`); | |
| success++; | |
| } else { | |
| const error = await response.text(); | |
| console.error(`✗ Failed: ${show.name} - ${response.status}: ${error}`); | |
| failed++; | |
| } | |
| } catch (error) { | |
| console.error(`✗ Failed: ${show.name} - ${error.message}`); | |
| failed++; | |
| } | |
| await new Promise((resolve) => setTimeout(resolve, 500)); | |
| } | |
| console.log(`\nDone! Success: ${success}, Failed: ${failed}`); | |
| } | |
| ingestTvShows(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment