i have this piece of code that handles the creating of metadata for a faiss index I am creating.
#metadata.append(item.get("source", {})) # Store only the source metadata
"source": item.get("source", {}), # Store only the source metadata
"original_text": full_text # Store original text for retrieval
right now it’s just pulling the source element but i also want to add to the source dictionary the
stuff on the top:
“item_id”: 11,
“item_name”: “How We Defend Ourselves: Strategies for Survival”,
“item_author”: “Uncharted Limbo”,
“item_year”: 2025,
“item_type”: “Full_Text”,
“content”: [
{
“How We Defend Ourselves: Strategies for Survival”: [
“We cannot run. We cannot hide. But we are not defenseless. We stand, we endure, and we fight.\nOur bodies are fortresses—sealed with resins, laced with toxins, armed with impenetrable bark. When danger comes, we sense it, we respond, and sometimes, we even call for help.”
]
},
{
“1. Our First Line of Defense: Resins—Barriers of Protection”: [
“Some wounds bleed. We seal.\n- When insects bite, when bark is torn, when a wound opens, we release resin, a thick, sticky substance that hardens into a shield.\n- Resin traps invaders, suffocating insects before they can burrow into our wood.\n- It flushes out pathogens, preventing fungi and bacteria from spreading through our veins.\n- It seals our wounds, stopping infections before they begin.\n\nSome of our strongest kin—pines, spruces, firs—are masters of this defense. Their resin flows like a river of protection, keeping them safe from burrowing beetles and disease. The air may carry the scent of pine, but to an invader, it is the scent of warning.”
]
},
{
“2. We Make Ourselves Undesirable: Tannins—Weapons Against Consumption”: [
“Not all battles are fought with walls. Some are fought with taste, with digestion, with chemistry.\n- Tannins make our leaves bitter, toxic, and impossible to digest.\n- They bind to proteins in the guts of insects and deer, making it harder for them to absorb nutrients.\n- They slow microbial growth, reducing the risk of fungal and bacterial infections.\n\nOaks and chestnuts are rich in tannins, ensuring that their young leaves and acorns are left untouched by hungry mouths. Those who try to feed on them learn quickly—some meals are not worth eating.”
]
},
{
“3. Our Most Potent and Expensive Weapons: Secondary Metabolites”: [
“Not all defenses are immediate. Some are stored, waiting to be unleashed in times of need. These are our secondary metabolites—compounds we do not need to grow, but ones that protect us when we are under attack.\n- Alkaloids (Nicotine, Caffeine, Morphine) – Poisons that paralyze, weaken, or kill insects and fungi.\n- Terpenoids (Camphor, Limonene, Pyrethrin) – Chemicals that repel herbivores and pests with scent or toxicity.\n- Phenolics (Salicylic Acid) – Antifungal and antibacterial compounds that heal and protect.\n\nSome of us warn our neighbors when danger arrives. Aspens release salicylic acid into the air when insects attack, triggering a collective defense response in the trees around them. We do not just defend ourselves—we protect each other.”
]
},
{
“4. When Stress Weakens Us, Our Defenses Falter”: [
“To fight, we need energy. To make resins, tannins, and toxins, we need carbon from the air and nutrients from the soil. But when stress weakens us, our defenses crumble.\n- Drought forces us to close our stomata, cutting off the carbon supply we need to produce protective compounds.\n- Nutrient-poor soils limit our ability to create secondary metabolites, leaving us vulnerable to attack.\n- Weak trees become easy targets for bark beetles, fungi, and disease.\n\nWe are strongest when we are healthy. When stress takes hold, our enemies come faster, sensing our weakness.”
]
},
{
“5. Defenses in Our Structure: Physical Barriers”: [
“Not all protection is chemical. Some of us armor ourselves with form alone.\n- Thorns, spines, and prickles keep herbivores at bay—Acacia trees shelter ants in their thorns, and in return, the ants attack anything that tries to eat them.\n- Smooth bark sheds water quickly, preventing mold and fungi from taking hold.\n- Thick bark insulates against fire, protecting the living core inside.\n- Some of us sacrifice our own limbs—like lizards that shed their tails, we drop branches when they become too heavy or diseased, saving the rest of the tree.\n\nEven the smallest structures can be weapons—plants in the Arum family fill their leaves with sharp oxalate crystals, causing unbearable pain to anything foolish enough to chew them. Silica in our leaves makes digestion nearly impossible.”
]
},
{
“6. Some of Us Change—Our Defense is Adaptation”: [
“Defense is not always about standing firm. Sometimes, we shift, we change, we evolve.\n- Some of us grow quickly, escaping the reach of hungry herbivores before they can do damage.\n- Some of us change the way we flower—one plant pollinated by butterflies shifts its nectar and shape to attract hummingbirds instead when caterpillars become a threat.\n- Some of us call for help—when insects attack, we release chemicals into the air that summon predators, bringing death to those that try to feed on us.\n\nWe do not always fight alone. We use the enemies of our enemies to our advantage.”
]
},
{
“7. We Form Alliances: Mutual Defenses with Other Species”: [
“No tree survives alone. We forge alliances with those who can help us.\n- Ants protect us, clearing leaf litter around our trunks, lowering competition for resources, and attacking herbivores in exchange for shelter.\n- Mycorrhizal fungi extend our roots, helping us absorb nutrients in return for sugar.\n- Bacteria in our roots fix nitrogen, enriching the soil, strengthening our neighbors, and ensuring the health of the entire forest.\n\nSome of us stand alone in open landscapes. But in the forest, we are stronger together.”
]
},
{
“We Do Not Run, But We Do Fight”: [
”- We trap, poison, and repel invaders.\n- We alter our structure to keep danger at bay.\n- We sacrifice, adapt, and even change our allies when needed.\n- We call for help, and we listen when others call.\n\nWe are not helpless. We are not passive. We stand, we defend, and we survive.”
]
}
],
“source”: {
“title”: “ULC Research”,
“author”: “ULC”,
“type”: “ULC Research”,
“year”: “2025”,
“url”: null
}
},
the “item_id”,
“item_name”,
“item_author”,
“item_year”,
“item_type”,