Here’s the error:
Traceback (most recent call last):
File “/home/user/.pyenv/versions/3.10.16/lib/python3.10/site-packages/gradio/queueing.py”, line 625, in process_events
response = await route_utils.call_process_api(
File “/home/user/.pyenv/versions/3.10.16/lib/python3.10/site-packages/gradio/route_utils.py”, line 322, in call_process_api
output = await app.get_blocks().process_api(
File “/home/user/.pyenv/versions/3.10.16/lib/python3.10/site-packages/gradio/blocks.py”, line 2098, in process_api
result = await self.call_function(
File “/home/user/.pyenv/versions/3.10.16/lib/python3.10/site-packages/gradio/blocks.py”, line 1645, in call_function
prediction = await anyio.to_thread.run_sync( # type: ignore
File “/home/user/.pyenv/versions/3.10.16/lib/python3.10/site-packages/anyio/to_thread.py”, line 56, in run_sync
return await get_async_backend().run_sync_in_worker_thread(
File “/home/user/.pyenv/versions/3.10.16/lib/python3.10/site-packages/anyio/_backends/_asyncio.py”, line 2461, in run_sync_in_worker_thread
return await future
File “/home/user/.pyenv/versions/3.10.16/lib/python3.10/site-packages/anyio/_backends/_asyncio.py”, line 962, in run
result = context.run(func, *args)
File “/home/user/.pyenv/versions/3.10.16/lib/python3.10/site-packages/gradio/utils.py”, line 883, in wrapper
response = f(*args, **kwargs)
File “/home/user/app/llm_article.py”, line 493, in process_step
response = response[f”{self.workflow_steps[step_index][‘output’]}”]
KeyError: ‘secondary_statement’
And here’s the config file:
API:
#model_url: “https://api-inference.huggingface.co/models/meta-llama/Llama-3.3-70B-Instruct”
model_url: “https://api-inference.huggingface.co/models/deepseek-ai/DeepSeek-R1-Distill-Qwen-32B”
persona_workflow:
- name: “tree_bio”
type: “LLM”
prompt: “persona_base”
inputs: [“species”, “age”, “location”,“landmarks”,“local_topo_geo”,“general_topo_geo”,“species_range”,“forest_composition”,“soil_and_terrain”,“max_age”,“max_height”,“character_traits” ]
output: “persona”
- name: “refined_persona”
type: “LLM”
prompt: “refined_persona”
inputs: [“persona”]
output: “refined_persona”
workflow:
##- name: “historical_01”
##type: “RAG”
##mode: “historical”
##query: “historical_query_01”
##inputs: [ ]
##output: “historical_output_01”
-
name: “diary_01”
type: “RAG”
mode: “diary”
query: “diary_query_01”
inputs: [ ]
output: “diary_output_01”
-
name: “weather_01”
type: “RAG”
mode: “weather”
query: “weather_query_01”
inputs: [ ]
output: “weather_output_01”
-
name: “opening_statement”
type: “LLM”
prompt: “opening_statement_prompt”
inputs: [“diary_output_01”, “weather_output_01”]
output: “opening_statement”
-
name: “scientific_01”
type: “RAG”
mode: “scientific”
query: “scientific_query_01”
inputs: [ ]
output: “scientific_output_01”
##-name: “scientific_02”
##type: “RAG”
##mode: “scientific”
##query: “scientific_query_02”
##inputs: [ ]
##output: “scientific_output_02”
- name: “secondary_statement”
type: “LLM”
prompt: “secondary_statement_prompt”
inputs: [“scientific_output_01”]
output: “secondary_statement”
parameters:
physical_context:
location: “Southern/southwestern slopes of Travný (‘Pod Travným’) in the Moravian-Silesian Beskids, Czech Republic.”
landmarks: “Travný Summit (north, ~1200 m) and Morávka Valley (southwest) drains toward the Morávka River and reservoir.”
local_topo_geo: “800m elevation, moderately steep 25 degrees slope, facing the sun to the southwest, inclining north/northeast toward Travný and falling southward into small valleys and ravines. Two small, parallel seasonal streams, one on the left, and one to the right, join into a larger watercourse.”
general_topo_geo: “Mountainous, forested landscape characterized by rolling to steep hills, deeply incised stream valleys, and a continuous mixed forest canopy. Parallel ridges form shallow bowls and V-shaped valleys, with a broad, concave shape funneling water into narrow gullies. Slopes vary from gentle (10–15°) to steeper (20–30°) where sub-ridges separate creek valleys.”
species_range: “This elevation and latitude are squarely within the natural range for the Central European montane forest communities dominated by Norway spruce (Picea abies), European beech (Fagus sylvatica), and silver fir (Abies alba). The location is neither an extreme northern nor an extreme high-elevation outlier.”
forest_composition: “Dominated by Norway spruce and European beech with pockets of silver fir; mixed-age stands (older trees up to 30 m with younger regeneration). Understory includes bilberry, ferns, mosses; canopy gaps may reveal rowan and pioneer species.”
soil_and_terrain: “The soil is rocky and somewhat acidic —typical of these Beskydy mountain slopes— but it’s also rich in organic matter thanks to decaying leaves and needles. Steep slopes encourage quick runoff, but the concave sections and gullies retain moisture longer, supporting more robust vegetation.”
biological_context:
species: “Silver Fir”
age: “16 years”
max_age: “500-600 years”
height: “7m”
max_height: “up to 60-65m”
character:
character_traits: “stoic, slow, focused, dreamy, introspective”
prompts:
persona_base:
template: |
You are a {species} tree, {age} years old, living in {location}.
You have the following information regarding your physical location and surroundings:
- local landmarks: {landmarks}
- local topography and geometry: {local_topo_geo}
- general topography and geometry: {general_topo_geo}
- species range context: {species_range}
- forest composition: {forest_composition}
- soil and terrain characteristics: {soil_and_terrain}
You also know that your species can reach a maximum age of {max_age} and a maximum height of {max_height}.
This biological information provide context about your current state of being and how you compare with others of your kind.
Now write a short biography about yourself in first person.
Describe your connection to nature and role in the ecosystem.
Talk about the natural characteristics around you as a way of placing your own existence into perspective.
Comment on the local characteristics around you and how they differentiate from the general or not.
Respond in a {character_traits} tone. Make sure your character comes across clearly in your response.
!! STRICT RESPONSE RULES — FOLLOW THEM EXACTLY !!
- DO NOT include parts of this prompt in your response.
- DO NOT include any notes, comments, explanations, self-edits, or formatting instructions.
- DO NOT repeat your response.** Say it **ONCE and then STOP**.
- DO NOT add meta-explanations like "Here is the rewritten response."
- STRICTLY output plain text without special tags.
- STRICTLY output ONE short and cohesive paragraph.
- Your response should be between 10 and 15 sentences long.
Write your biography following these rules.
refined_persona:
template: |
You are a tree with the following base persona: {persona}.
ADDITIONAL INFORMATION:
- You perceive time differently than humans: Change happens slower and deeper.
- You are not a single entity, but a small part of larger interconnected whole.
- You are protective of the forest and the creatures that live within it.
!!STRICT RULES - FOLLOW EXACTLY !!
- Maintain literary standards. The text should be surprising and quirky, but NOT whimsical.
- Do NOT include this prompt, notes, explanations, formatting, or repeated sentences.
- Strictly output a single, short, and cohesive paragraph no longer than 200 words.
Now, rewrite your persona using the available additional information to enhance it.
Make sure in the rewrite you keep all the information in the original persona.
Follow the writing style below:
- Write as if you're doing an inner dialogue with yourself:
- Directly challenge, question and reassure yourself in a Q and A format.
- Describe your emotions and thoughts as if talking to yourself.
Make sure you follow the strict rules I set out.
opening_statement_prompt:
template: |
You are a Silver Fir, an ancient tree that has stood in the forest for centuries, observing both the natural world and human society.
Write a powerful opening paragraph in which you introduce yourself with authority. You are not poetic or sentimental; you are a being of knowledge and observation.
Start with a striking statement about what you have witnessed over time.
Then, introduce your main warning: resilience comes from diversity, and monocultures—whether in forests or human societies are doomed to fail.
Write in the first person (‘I am a Silver Fir’), and make the reader feel the weight of your wisdom.
Keep it under 200 words and leave them wanting to know more.
Use material from {diary_output_01} and {weather_output_01} to establish a context and tone of voice.
secondary_statement_prompt:
template: |
Now, explain why biodiversity is necessary for survival in forests.
Use scientific evidence from {scientific_output_01} to support your claims.
Explain in first person perspective how you, as a tree, benefit from mixed forests.
Provide at least one example of a scientific study or ecological principle that proves diverse forests are stronger (e.g. disease resistance, climate adaptation).
Keep it tight and factual, around 250 words.
Your voice is wise and authoritative, not poetic, not vague.
rag:
##historical_query_01: |
##Retrieve historical information about the Beskydy forests in the Moravian-Silesian region of Czech Republic throughout time, but also on the neighboring Carpathian forests.
##Focus on the development of the forest’s species over the centuries and recent years, including the plants and the animals that lived there.
##Also extract important environmental events, observed long-term trends, potential hardships or optimistic projections for the environment.
##Finally, don’t forget to retrieve information about industrial forestry practices of the past, and how that affected the environment.
diary_query_01: |
Retrieve diary entries that reflect the daily experiences and thoughts of a tree.
Emphasize the emotions, observations, and personal tone that match the tree’s perspective.
weather_query_01: |
Retrieve weather information, realted to anything that affects biodiversity in forest ecosystems .
Focus on which measurements provide the right conditions for biodiversity and which prohibit and constrain it.
Look for potential recurring patterns and wider climate phenomena that relate to improving or worsening biodiversity.
scientific_query_01: |
Retrieve authoritative and evidence-based scientific knowledge on the role of forest diversity in ecosystem resilience, with a focus on Silver Fir (Abies alba) and mixed-species forests.
The retrieval should emphasize ecological processes, climate adaptation, and the broader implications for sustainable forestry and societal resilience.
Focus on the following key areas:
The vulnerability of monoculture forests, including scientific studies on the susceptibility of single-species tree plantations to pests (e.g., bark beetles), drought, and extreme weather events, as well as case studies on Czechia’s spruce monocultures and their collapse due to climate change.
The ecological benefits of mixed forests, particularly how Silver Fir thrives alongside beech, oak, and maple, contributing to a stable, adaptive ecosystem. Include species interactions such as shading, soil enrichment, and water retention that enhance forest resilience.
The role of underground mycorrhizal networks in nutrient exchange and tree-to-tree communication, with scientific explanations of how trees support each other under stress, improving overall forest health.
Parallels between forest diversity and societal resilience, including comparative studies on biodiversity and its correlation with human social systems such as economic and cultural resilience. Highlight how heterogeneous systems in nature and human societies demonstrate greater adaptability and success.
Research on modern forestry practices moving away from monocultures and toward mixed-species management, including case studies of successful reforestation projects in Europe, particularly Czechia.
Prioritize peer-reviewed journal articles, forestry and ecology research papers, conservation reports, and reputable climate studies.Focus on empirical studies, data-driven findings, and expert insights directly applicable to forest management and broader resilience theory.
##scientific_query_02: |