Spaces:
Running
Running
File size: 5,737 Bytes
92bcda3 c6c68c5 92bcda3 39389f8 92bcda3 5402d17 92bcda3 44b9746 92bcda3 5402d17 92bcda3 39389f8 5402d17 cebf7a8 92bcda3 44b9746 92bcda3 5402d17 92bcda3 44b9746 92bcda3 a523e89 92bcda3 cebf7a8 92bcda3 cebf7a8 92bcda3 5402d17 92bcda3 cebf7a8 a523e89 92bcda3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | # Simple Loop Node Example with Cognitive Extraction
# This example demonstrates the LoopNode functionality with cognitive insight extraction
orchestrator:
id: simple-loop-example
strategy: sequential
agents:
- simple_loop
- final_processor
agents:
- id: simple_loop
type: loop
max_loops: 5
score_threshold: 0.75
score_extraction_pattern: "SCORE:\\s*([0-9.]+)"
persist_across_runs: true # Enable persistence of past loops across different workflow runs
# Cognitive extraction configuration
cognitive_extraction:
enabled: true
max_length_per_category: 500
extract_patterns:
insights:
- "(?:provides?|identifies?|shows?|solid|good|comprehensive|thorough)\\s+(.+?)(?:\\n|$)"
- "(?:accurately|correctly)\\s+(.+?)(?:\\n|$)"
- "(?:strong|effective|successful)\\s+(.+?)(?:\\n|$)"
improvements:
- "(?:lacks?|lacking|needs?|requires?|missing|should|could)\\s+(.+?)(?:\\n|$)"
- "(?:would improve|would enhance|could benefit from)\\s+(.+?)(?:\\n|$)"
- "\\d+\\.\\s*\\*\\*([^*]+)\\*\\*:\\s*(.+?)(?:\\n|$)"
- "(?:more detailed|more thorough|clearer|specific|in-depth)\\s+(.+?)(?:\\n|$)"
- "(?:depth of|implementation plan|stakeholder analysis|risk assessment)\\s+(.+?)(?:\\n|$)"
- "(?:addressing|exploring|developing|conducting|establishing)\\s+(.+?)(?:\\n|$)"
mistakes:
- "(?:overlooked|missed|not adequately|does not)\\s+(.+?)(?:\\n|$)"
- "(?:lacks depth|lacks specificity|insufficient|inadequate)\\s+(.+?)(?:\\n|$)"
- "(?:weakness|limitation|gap|problem|issue)\\s*[:\\s]*(.+?)(?:\\n|$)"
- "(?:vague|unclear|generic|surface-level)\\s+(.+?)(?:\\n|$)"
agent_priorities:
analyzer: ["insights", "improvements", "mistakes"]
scorer: ["mistakes", "improvements"]
# Define past_loops object structure with cognitive insights
past_loops_metadata:
loop_number: "{{ get_loop_number() }}"
score: "{{ score }}"
timestamp: "{{ timestamp }}"
key_insights: "{{ insights }}"
improvements_needed: "{{ improvements }}"
mistakes_found: "{{ mistakes }}"
# Internal workflow that gets repeated
internal_workflow:
orchestrator:
id: internal-loop
strategy: sequential
agents: [analyzer, scorer]
agents:
- id: analyzer
type: local_llm
model: gpt-oss:20b
model_url: http://localhost:11434/api/generate
provider: ollama
temperature: 0.7
prompt: |
Analyze this question: {{ get_input() }}
{% if has_past_loops() %}
Previous attempts ({{ get_past_loops() | length }}):
{% for past_loop in get_past_loops() %}
- Loop {{ past_loop.loop_number }} (Score: {{ past_loop.score }}):
* Key insights: {{ past_loop.key_insights }}
* Needed improvements: {{ past_loop.improvements_needed }}
* Mistakes found: {{ past_loop.mistakes_found }}
{% endfor %}
Build upon these previous insights and address the identified gaps.
{% endif %}
Provide a comprehensive analysis. Focus on:
1. Key insights and findings
2. Areas that need improvement
3. What might be missing or overlooked
Structure your response to clearly indicate insights, improvements needed, and potential mistakes.
- id: scorer
type: local_llm
model: gpt-oss:20b
model_url: http://localhost:11434/api/generate
provider: ollama
temperature: 0.2
prompt: |
Rate the quality of this analysis (0.0 to 1.0):
{{ get_agent_response('analyzer') }}
Consider:
- Completeness and depth
- Accuracy of insights
- Identification of improvements
- Recognition of limitations
If the score is below 0.8, clearly identify what was missed, overlooked, or needs improvement.
Format your response as: SCORE: X.XX
Then explain what was missed or needs improvement.
- id: final_processor
type: local_llm
model: gpt-oss:20b
model_url: http://localhost:11434/api/generate
provider: ollama
temperature: 0.5
prompt: |
Process the final result from the cognitive loop:
{% if previous_outputs.simple_loop %}
Loops completed: {{ previous_outputs.simple_loop.loops_completed | default('Unknown') }}
Final score: {{ previous_outputs.simple_loop.final_score | default('Unknown') }}
Threshold met: {{ previous_outputs.simple_loop.threshold_met | default('Unknown') }}
Cognitive Evolution Summary:
{% if previous_outputs.simple_loop.response.past_loops %}
{% for past_loop in previous_outputs.simple_loop.response.past_loops %}
**Loop {{ past_loop.loop_number }}** (Score: {{ past_loop.score }}):
- Key Insights: {{ past_loop.key_insights }}
- Improvements: {{ past_loop.improvements_needed }}
- Mistakes: {{ past_loop.mistakes_found }}
{% endfor %}
{% endif %}
Final Analysis: {{ previous_outputs.simple_loop.response.result | default('No result available') }}
{% else %}
The loop execution is complete. Providing a general meta-analysis of cognitive loop processing.
{% endif %}
Provide a meta-analysis of how the thinking evolved through the loops and what the final insights reveal. |