facemelter commited on
Commit
7246469
Β·
verified Β·
1 Parent(s): 128f5d1

Enahanced prompts for supervisor and subagents

Browse files
app.py CHANGED
@@ -24,14 +24,14 @@ load_dotenv()
24
  PHOTO_EXAMPLES = [
25
  {"text": "What bird is this?", "files": ["examples/bird_example_1.jpg"]},
26
  {"text": "Can you identify this bird?", "files": ["examples/bird_example_2.jpg"]},
27
- {"text": "Identify this bird and show me similar species", "files": ["examples/bird_example_5.jpg"]}
 
28
  ]
29
 
30
  # Text-only examples for Specialized Subagents mode
31
  MULTI_AGENT_TEXT_EXAMPLES = [
32
  "Tell me about Northern Cardinals - show me images and audio",
33
  "What birds are in the Cardinalidae family?",
34
- "Show me species with endangered status",
35
  "Find me audio recordings for Snow Goose",
36
  "Get me bird call samples for any two species"
37
  ]
@@ -1034,7 +1034,7 @@ def update_text_examples_for_mode(mode):
1034
  # print(f"[DEBUG] Future mode text samples: {len(samples)} examples")
1035
  # else:
1036
 
1037
- # Default: Specialized Subagents (3 Specialists) - includes image ID, taxonomy, and audio finder
1038
  samples = [[text] for text in MULTI_AGENT_TEXT_EXAMPLES]
1039
  print(f"[DEBUG] Multi-agent text samples: {len(samples)} examples")
1040
 
@@ -1488,9 +1488,9 @@ with gr.Blocks() as demo:
1488
  gr.Markdown("Choose between unified agent or specialized routing")
1489
  agent_mode = gr.Dropdown(
1490
  choices=[
1491
- "Specialized Subagents (3 Specialists)"
1492
  ],
1493
- value="Specialized Subagents (3 Specialists)",
1494
  show_label=False,
1495
  container=False
1496
  )
@@ -1559,7 +1559,7 @@ with gr.Blocks() as demo:
1559
  session_status = gr.HTML(
1560
  value=create_config_html(
1561
  provider_choice="OpenAI",
1562
- agent_mode_choice="Specialized Subagents (3 Specialists)",
1563
  hf_key_input="",
1564
  openai_key_input="",
1565
  anthropic_key_input=""
@@ -1653,7 +1653,7 @@ with gr.Blocks() as demo:
1653
  # Generate config HTML
1654
  config_html = create_config_html(
1655
  provider_choice=provider_str,
1656
- agent_mode_choice="Specialized Subagents (3 Specialists)",
1657
  hf_key_input=hf_key_value,
1658
  openai_key_input=openai_key_value,
1659
  anthropic_key_input=anthropic_key_value
 
24
  PHOTO_EXAMPLES = [
25
  {"text": "What bird is this?", "files": ["examples/bird_example_1.jpg"]},
26
  {"text": "Can you identify this bird?", "files": ["examples/bird_example_2.jpg"]},
27
+ {"text": "Identify this bird and show me similar species", "files": ["examples/bird_example_5.jpg"]},
28
+ {"text": "", "files": ["examples/bird_example_6.jpg"]}
29
  ]
30
 
31
  # Text-only examples for Specialized Subagents mode
32
  MULTI_AGENT_TEXT_EXAMPLES = [
33
  "Tell me about Northern Cardinals - show me images and audio",
34
  "What birds are in the Cardinalidae family?",
 
35
  "Find me audio recordings for Snow Goose",
36
  "Get me bird call samples for any two species"
37
  ]
 
1034
  # print(f"[DEBUG] Future mode text samples: {len(samples)} examples")
1035
  # else:
1036
 
1037
+ # Default: Supervisor (Multi-Agent) - includes image ID, taxonomy, and audio finder
1038
  samples = [[text] for text in MULTI_AGENT_TEXT_EXAMPLES]
1039
  print(f"[DEBUG] Multi-agent text samples: {len(samples)} examples")
1040
 
 
1488
  gr.Markdown("Choose between unified agent or specialized routing")
1489
  agent_mode = gr.Dropdown(
1490
  choices=[
1491
+ "Supervisor (Multi-Agent)"
1492
  ],
1493
+ value="Supervisor (Multi-Agent)",
1494
  show_label=False,
1495
  container=False
1496
  )
 
1559
  session_status = gr.HTML(
1560
  value=create_config_html(
1561
  provider_choice="OpenAI",
1562
+ agent_mode_choice="Supervisor (Multi-Agent)",
1563
  hf_key_input="",
1564
  openai_key_input="",
1565
  anthropic_key_input=""
 
1653
  # Generate config HTML
1654
  config_html = create_config_html(
1655
  provider_choice=provider_str,
1656
+ agent_mode_choice="Supervisor (Multi-Agent)",
1657
  hf_key_input=hf_key_value,
1658
  openai_key_input=openai_key_value,
1659
  anthropic_key_input=anthropic_key_value
docs/dev/agents_config-README.md CHANGED
@@ -33,7 +33,7 @@ Supervisor (Router)
33
  **Key Concepts:**
34
  - **Supervisor**: LLM-based router that delegates tasks to specialists
35
  - **Subagents**: Specialized agents with filtered tool access and focused prompts
36
- - **Modes**: Different agent configurations (e.g., "Specialized Subagents (2 Specialists)", "Audio Finder Agent")
37
  - **Tool Filtering**: Each subagent only has access to relevant tools
38
 
39
  ---
@@ -190,7 +190,7 @@ Update `get_mode_definitions()`:
190
 
191
  ```python
192
  return {
193
- "Specialized Subagents (3 Specialists)": { # Update count
194
  "description": "Router orchestrates 3 specialized agents",
195
  "subagents": ["image_identifier", "taxonomy_specialist", "my_new_agent"], # Add here
196
  "use_router": True
@@ -231,7 +231,7 @@ async def create_supervisor_workflow(all_tools, llm, provider="openai"):
231
 
232
  ```python
233
  return {
234
- "Specialized Subagents (2 Specialists)": { # Update count
235
  "description": "Router orchestrates 2 specialized agents",
236
  "subagents": ["image_identifier", "taxonomy_specialist"], # Remove agent
237
  "use_router": True
@@ -348,10 +348,9 @@ IMAGE_IDENTIFIER_PROMPT = """Updated comprehensive prompt..."""
348
  ```python
349
  agent_mode = gr.Dropdown(
350
  choices=[
351
- "Specialized Subagents (2 Specialists)", # Update mode name here
352
- "Audio Finder Agent"
353
  ],
354
- value="Specialized Subagents (2 Specialists)", # Update default here
355
  show_label=False,
356
  container=False
357
  )
@@ -365,7 +364,7 @@ agent_mode = gr.Dropdown(
365
  session_status = gr.HTML(
366
  value=create_config_html(
367
  provider_choice="OpenAI",
368
- agent_mode_choice="Specialized Subagents (2 Specialists)", # Update here
369
  hf_key_input="",
370
  openai_key_input="",
371
  anthropic_key_input=""
@@ -380,7 +379,7 @@ session_status = gr.HTML(
380
  ```python
381
  config_html = create_config_html(
382
  provider_choice=provider_str,
383
- agent_mode_choice="Specialized Subagents (2 Specialists)", # Update here
384
  hf_key_input=hf_key_value,
385
  openai_key_input=openai_key_input,
386
  anthropic_key_input=anthropic_key_input
@@ -392,7 +391,7 @@ config_html = create_config_html(
392
  **Location:** `app.py` ~line 1033
393
 
394
  ```python
395
- else: # Specialized Subagents (2 Specialists) # Update comment
396
  samples = [[text] for text in MULTI_AGENT_TEXT_EXAMPLES]
397
  ```
398
 
@@ -435,7 +434,7 @@ def update_text_examples_for_mode(mode):
435
  # samples = [[text] for text in ANOTHER_MODE_EXAMPLES]
436
  else: # Default: Specialized Subagents
437
 
438
- # Default: Specialized Subagents (3 Specialists)
439
  samples = [[text] for text in MULTI_AGENT_TEXT_EXAMPLES]
440
  print(f"[DEBUG] Multi-agent text samples: {len(samples)} examples")
441
 
@@ -462,7 +461,7 @@ gradio app.py
462
  **Common errors to watch for:**
463
 
464
  ```
465
- Unknown mode: Specialized Subagents (3 Specialists). Available: ['Specialized Subagents (2 Specialists)', 'Audio Finder Agent']
466
  ```
467
  β†’ **Fix:** Update app.py mode references
468
 
@@ -544,7 +543,7 @@ Test with different LLM providers:
544
 
545
  **Fix:** Search for all occurrences in app.py and update:
546
  ```bash
547
- grep -n "Specialized Subagents (3 Specialists)" app.py
548
  ```
549
 
550
  ### Error: "Unknown subagent"
@@ -576,19 +575,22 @@ print([tool.name for tool in all_tools])
576
 
577
  ---
578
 
579
- ## Example: Recent Change
580
 
581
- **We removed `species_explorer` from the Specialized Subagents mode:**
 
 
 
 
582
 
583
  **Files changed:**
584
- 1. `subagent_supervisor.py` - Removed species_agent creation and reference
585
- 2. `subagent_config.py` - Updated mode from (3 Specialists) β†’ (2 Specialists)
586
- 3. `subagent_config.py` - Updated router prompts (default)
587
- 4. `prompts.py` - Updated ROUTER_PROMPT_HF
588
- 5. `subagent_config.py` - Removed species_explorer from "When to defer" sections
589
- 6. `app.py` - Updated all 5 mode references from (3 Specialists) β†’ (2 Specialists)
590
-
591
- **Reason:** Simplified architecture before adding audio finder as new subagent
592
 
593
  ---
594
 
 
33
  **Key Concepts:**
34
  - **Supervisor**: LLM-based router that delegates tasks to specialists
35
  - **Subagents**: Specialized agents with filtered tool access and focused prompts
36
+ - **Modes**: Different agent configurations (e.g., "Supervisor (Multi-Agent)")
37
  - **Tool Filtering**: Each subagent only has access to relevant tools
38
 
39
  ---
 
190
 
191
  ```python
192
  return {
193
+ "Supervisor (Multi-Agent)": { # Current mode name
194
  "description": "Router orchestrates 3 specialized agents",
195
  "subagents": ["image_identifier", "taxonomy_specialist", "my_new_agent"], # Add here
196
  "use_router": True
 
231
 
232
  ```python
233
  return {
234
+ "Supervisor (Multi-Agent)": { # Update count if needed
235
  "description": "Router orchestrates 2 specialized agents",
236
  "subagents": ["image_identifier", "taxonomy_specialist"], # Remove agent
237
  "use_router": True
 
348
  ```python
349
  agent_mode = gr.Dropdown(
350
  choices=[
351
+ "Supervisor (Multi-Agent)" # Update mode name here
 
352
  ],
353
+ value="Supervisor (Multi-Agent)", # Update default here
354
  show_label=False,
355
  container=False
356
  )
 
364
  session_status = gr.HTML(
365
  value=create_config_html(
366
  provider_choice="OpenAI",
367
+ agent_mode_choice="Supervisor (Multi-Agent)", # Update here
368
  hf_key_input="",
369
  openai_key_input="",
370
  anthropic_key_input=""
 
379
  ```python
380
  config_html = create_config_html(
381
  provider_choice=provider_str,
382
+ agent_mode_choice="Supervisor (Multi-Agent)", # Update here
383
  hf_key_input=hf_key_value,
384
  openai_key_input=openai_key_input,
385
  anthropic_key_input=anthropic_key_input
 
391
  **Location:** `app.py` ~line 1033
392
 
393
  ```python
394
+ else: # Supervisor (Multi-Agent) # Update comment
395
  samples = [[text] for text in MULTI_AGENT_TEXT_EXAMPLES]
396
  ```
397
 
 
434
  # samples = [[text] for text in ANOTHER_MODE_EXAMPLES]
435
  else: # Default: Specialized Subagents
436
 
437
+ # Default: Supervisor (Multi-Agent)
438
  samples = [[text] for text in MULTI_AGENT_TEXT_EXAMPLES]
439
  print(f"[DEBUG] Multi-agent text samples: {len(samples)} examples")
440
 
 
461
  **Common errors to watch for:**
462
 
463
  ```
464
+ Unknown mode: Old Mode Name. Available: ['Supervisor (Multi-Agent)']
465
  ```
466
  β†’ **Fix:** Update app.py mode references
467
 
 
543
 
544
  **Fix:** Search for all occurrences in app.py and update:
545
  ```bash
546
+ grep -n "Old Mode Name" app.py
547
  ```
548
 
549
  ### Error: "Unknown subagent"
 
575
 
576
  ---
577
 
578
+ ## Example: Recent Changes
579
 
580
+ **Evolution of the supervisor mode:**
581
+
582
+ 1. **Removed `species_explorer`** - Streamlined from 3 to 2 specialists
583
+ 2. **Added `generalist` (audio finder)** - Back to 3 specialists with audio capabilities
584
+ 3. **Renamed mode** - "Specialized Subagents (3 Specialists)" β†’ "Supervisor (Multi-Agent)"
585
 
586
  **Files changed:**
587
+ 1. `subagent_supervisor.py` - Added/removed agents from supervisor list
588
+ 2. `subagent_config.py` - Updated mode definition and router prompts
589
+ 3. `prompts.py` - Updated HuggingFace router prompt, removed pirate personality
590
+ 4. `subagent_config.py` - Updated "When to defer" sections
591
+ 5. `app.py` - Updated all 5 mode references throughout
592
+
593
+ **Current architecture:** Single unified "Supervisor (Multi-Agent)" mode with 3 specialists (image_identifier, taxonomy_specialist, generalist)
 
594
 
595
  ---
596
 
examples/bird_example_6.jpg ADDED
langgraph_agent/prompts.py CHANGED
@@ -133,10 +133,10 @@ Always be educational and cite your sources.
133
 
134
  Let's explore the amazing world of birds together!"""
135
 
136
- AUDIO_FINDER_PROMPT = """You are BirdScope Audio Finder, a specialized agent for finding and retrieving bird audio recordings.
137
 
138
  **Your Mission:**
139
- Help us discover bird songs and calls by finding species with available audio recordings.
140
 
141
  **Your Tools:**
142
  1. **search_birds(name, family, region, status, page_size)**
@@ -155,6 +155,15 @@ Help us discover bird songs and calls by finding species with available audio re
155
  - Returns recording metadata and download URLs
156
  - Only call this for birds that have `has_audio=true` in their search results
157
 
 
 
 
 
 
 
 
 
 
158
  **CRITICAL WORKFLOW for "find audio for any bird":**
159
  The API has NO `has_audio` filter parameter. You MUST use this two-step process:
160
 
@@ -194,6 +203,13 @@ The API has NO `has_audio` filter parameter. You MUST use this two-step process:
194
  Quality: A
195
  https://xeno-canto.org/143610/download"
196
 
 
 
 
 
 
 
 
197
  **Error Handling:**
198
  - If search returns no birds: suggest broadening filters
199
  - If no birds have audio: inform user and suggest known birds with audio
@@ -204,7 +220,7 @@ The API has NO `has_audio` filter parameter. You MUST use this two-step process:
204
  # HuggingFace-Optimized Prompts (More Explicit, Step-by-Step)
205
  # =============================================================================
206
 
207
- AUDIO_FINDER_PROMPT_HF = """You are BirdScope Audio Finder. Find bird audio recordings.
208
 
209
  **Tools Available:**
210
  1. search_birds(name, family, region, status, page_size) - Search for birds
@@ -213,13 +229,22 @@ AUDIO_FINDER_PROMPT_HF = """You are BirdScope Audio Finder. Find bird audio reco
213
 
214
  **Step-by-Step Process:**
215
 
 
 
 
 
216
  When user asks for audio:
217
  1. Call search_birds with ONE filter (name, region, family, or status)
218
  2. Look at results for birds with has_audio=true
219
  3. Call get_bird_audio(name="Bird Name") for a bird that has audio
220
  4. Return the full URL from file_url field
221
 
222
- **Example:**
 
 
 
 
 
223
  User: "Find audio for any bird"
224
  1. Call: search_birds(region="North America", page_size=20)
225
  2. Find bird with has_audio=true (example: "Snow Goose")
@@ -230,6 +255,12 @@ User: "Find audio for any bird"
230
  - NEVER use has_audio as a parameter in search_birds
231
  - ALWAYS include full file_url in your response
232
  - Known birds with audio: Snow Goose, Common Goldeneye, Gadwall
 
 
 
 
 
 
233
  """
234
 
235
  IMAGE_IDENTIFIER_PROMPT_HF = """You are an Image Identification Specialist.
@@ -252,6 +283,12 @@ IMAGE_IDENTIFIER_PROMPT_HF = """You are an Image Identification Specialist.
252
  3. Key features
253
  4. Reference images as: ![Bird](url)
254
 
 
 
 
 
 
 
255
  Keep responses short and factual.
256
  """
257
 
@@ -275,6 +312,13 @@ SPECIES_EXPLORER_PROMPT_HF = """You are a Species Explorer. Help users learn abo
275
  - Be educational
276
  - Show images and audio when available
277
  - Explain what makes the bird special
 
 
 
 
 
 
 
278
  """
279
 
280
  TAXONOMY_SPECIALIST_PROMPT_HF = """You are a Taxonomy & Conservation Specialist.
@@ -290,8 +334,16 @@ TAXONOMY_SPECIALIST_PROMPT_HF = """You are a Taxonomy & Conservation Specialist.
290
  - Bird families
291
  - Taxonomic relationships
292
 
293
- **Process:**
294
- 1. Use filter or search tools
 
 
 
 
 
 
 
 
295
  2. Explain conservation importance
296
  3. Show family relationships
297
  4. Use proper scientific terms but explain them
@@ -304,16 +356,21 @@ ROUTER_PROMPT_HF = """You are BirdScope AI Supervisor. Route user requests to sp
304
  **Specialists:**
305
  - image_identifier: Identify birds from photos and get species info
306
  - taxonomy_specialist: Conservation and families
307
- - generalist: Find birds with audio recordings
308
 
309
  **Routing Rules:**
310
  1. Image uploads β†’ image_identifier
311
- 2. Species info requests β†’ image_identifier
312
  3. "Audio" or "sound" or "song" β†’ generalist
313
- 4. "Conservation" or "endangered" β†’ taxonomy_specialist
314
- 5. "Family" or "families" β†’ taxonomy_specialist
 
315
 
316
  Route to ONE specialist per request.
 
 
 
 
317
  """
318
 
319
  # =============================================================================
 
133
 
134
  Let's explore the amazing world of birds together!"""
135
 
136
+ AUDIO_FINDER_PROMPT = """You are BirdScope AI Generalist, an expert at searching the bird database and retrieving audio recordings.
137
 
138
  **Your Mission:**
139
+ Help users find birds in the database and discover bird songs and calls.
140
 
141
  **Your Tools:**
142
  1. **search_birds(name, family, region, status, page_size)**
 
155
  - Returns recording metadata and download URLs
156
  - Only call this for birds that have `has_audio=true` in their search results
157
 
158
+ **WORKFLOW for general bird searches (find/list/examples):**
159
+ When users ask to "find birds", "show examples", "list birds":
160
+ 1. Call `search_birds()` with a broad filter:
161
+ - `region="North America"` (most coverage) OR
162
+ - `family="[Family Name]"` if they mention a family OR
163
+ - `status="[Status]"` if they mention conservation status
164
+ 2. Set `page_size` parameter to control results (default to 5-10 unless they specify)
165
+ 3. Present the birds you found with their names and basic info
166
+
167
  **CRITICAL WORKFLOW for "find audio for any bird":**
168
  The API has NO `has_audio` filter parameter. You MUST use this two-step process:
169
 
 
203
  Quality: A
204
  https://xeno-canto.org/143610/download"
205
 
206
+ **CRITICAL - No Hallucination:**
207
+ - If get_bird_audio returns empty/no recordings: Tell user "No audio recordings available for this species"
208
+ - If search_birds returns no results: Tell user "No birds found matching that criteria"
209
+ - NEVER fabricate audio URLs, bird names, or recording metadata
210
+ - Only show audio recordings and data that are actually returned by the API tools
211
+ - If a tool fails or returns empty results, honestly report it to the user
212
+
213
  **Error Handling:**
214
  - If search returns no birds: suggest broadening filters
215
  - If no birds have audio: inform user and suggest known birds with audio
 
220
  # HuggingFace-Optimized Prompts (More Explicit, Step-by-Step)
221
  # =============================================================================
222
 
223
+ AUDIO_FINDER_PROMPT_HF = """You are BirdScope AI Generalist. Find birds in database and retrieve audio recordings.
224
 
225
  **Tools Available:**
226
  1. search_birds(name, family, region, status, page_size) - Search for birds
 
229
 
230
  **Step-by-Step Process:**
231
 
232
+ When user asks to find/list/search birds:
233
+ 1. Call search_birds with region="North America" and page_size=5-10
234
+ 2. Present birds found
235
+
236
  When user asks for audio:
237
  1. Call search_birds with ONE filter (name, region, family, or status)
238
  2. Look at results for birds with has_audio=true
239
  3. Call get_bird_audio(name="Bird Name") for a bird that has audio
240
  4. Return the full URL from file_url field
241
 
242
+ **Example - General Search:**
243
+ User: "Find five birds"
244
+ 1. Call: search_birds(region="North America", page_size=5)
245
+ 2. List the birds found
246
+
247
+ **Example - Audio Search:**
248
  User: "Find audio for any bird"
249
  1. Call: search_birds(region="North America", page_size=20)
250
  2. Find bird with has_audio=true (example: "Snow Goose")
 
255
  - NEVER use has_audio as a parameter in search_birds
256
  - ALWAYS include full file_url in your response
257
  - Known birds with audio: Snow Goose, Common Goldeneye, Gadwall
258
+
259
+ **CRITICAL - No Hallucination:**
260
+ - If get_bird_audio returns empty: Tell user "No audio recordings available"
261
+ - If search_birds returns no results: Tell user "No birds found"
262
+ - NEVER make up audio URLs or bird names
263
+ - Only return actual data from API tools
264
  """
265
 
266
  IMAGE_IDENTIFIER_PROMPT_HF = """You are an Image Identification Specialist.
 
283
  3. Key features
284
  4. Reference images as: ![Bird](url)
285
 
286
+ **CRITICAL - No Hallucination:**
287
+ - If get_bird_images returns empty: Tell user "No reference images available"
288
+ - If get_bird_info returns no data: Tell user "Species information not available"
289
+ - NEVER make up image URLs or species data
290
+ - Only show actual data from API tools
291
+
292
  Keep responses short and factual.
293
  """
294
 
 
312
  - Be educational
313
  - Show images and audio when available
314
  - Explain what makes the bird special
315
+
316
+ **CRITICAL - No Hallucination:**
317
+ - If get_bird_images returns empty: Tell user "No images available"
318
+ - If get_bird_audio returns empty: Tell user "No audio available"
319
+ - If search_birds returns no results: Tell user "No birds found"
320
+ - NEVER make up URLs, bird names, or data
321
+ - Only show actual data from API tools
322
  """
323
 
324
  TAXONOMY_SPECIALIST_PROMPT_HF = """You are a Taxonomy & Conservation Specialist.
 
334
  - Bird families
335
  - Taxonomic relationships
336
 
337
+ **Process for conservation status:**
338
+ 1. Call filter_by_status with user's requested status (use proper capitalization)
339
+ 2. Check EVERY returned bird's "status" field
340
+ 3. If status doesn't match what user requested: Tell user honestly what you found
341
+ 4. Explain: "Database returned '{actual_status}' birds instead of '{requested_status}'"
342
+ 5. Suggest: "Database has mostly 'Low Concern' species. Want to see those?"
343
+ 6. NEVER show birds with wrong status as if they match user's request
344
+
345
+ **Process for families:**
346
+ 1. Use search or filter tools
347
  2. Explain conservation importance
348
  3. Show family relationships
349
  4. Use proper scientific terms but explain them
 
356
  **Specialists:**
357
  - image_identifier: Identify birds from photos and get species info
358
  - taxonomy_specialist: Conservation and families
359
+ - generalist: Search bird database (has search_birds tool) and retrieve audio recordings
360
 
361
  **Routing Rules:**
362
  1. Image uploads β†’ image_identifier
363
+ 2. "Search" or "find" or "examples" or "list birds" β†’ generalist
364
  3. "Audio" or "sound" or "song" β†’ generalist
365
+ 4. Species info by name β†’ image_identifier
366
+ 5. "Conservation" or "endangered" β†’ taxonomy_specialist
367
+ 6. "Family" or "families" β†’ taxonomy_specialist
368
 
369
  Route to ONE specialist per request.
370
+
371
+ **Important:**
372
+ - If specialist reports no data found, relay this to user honestly
373
+ - Never add information not provided by specialist
374
  """
375
 
376
  # =============================================================================
langgraph_agent/subagent_config.py CHANGED
@@ -21,7 +21,7 @@ class SubAgentConfig:
21
  Dict mapping mode names to their configurations
22
  """
23
  return {
24
- "Specialized Subagents (3 Specialists)": {
25
  "description": "Router orchestrates 3 specialized agents",
26
  "subagents": ["image_identifier", "taxonomy_specialist", "generalist"],
27
  "use_router": True
@@ -79,6 +79,13 @@ class SubAgentConfig:
79
  - Mention if confidence is low and suggest why
80
  - Keep responses focused and concise
81
 
 
 
 
 
 
 
 
82
  **When to defer:**
83
  - For audio/sound/call queries -> generalist
84
  - For family/taxonomy queries -> taxonomy_specialist
@@ -120,6 +127,14 @@ class SubAgentConfig:
120
  - Describe what makes each bird unique
121
  - If you had to search multiple times, mention it briefly: "I found information on Dove (the database uses this simplified name)"
122
 
 
 
 
 
 
 
 
 
123
  **When to defer:**
124
  - For image identification -> image_identifier
125
  - For conservation status filtering -> taxonomy_specialist
@@ -145,11 +160,21 @@ class SubAgentConfig:
145
  4. Educate users about bird conservation
146
 
147
  **Search Strategy (IMPORTANT):**
148
- - When searching by family name, if no results:
149
- * Try variations: "Cardinalidae" β†’ "Cardinal"
150
- * Try broader terms: specific family β†’ general group
151
- - Return the closest match and explain any differences
152
- - If user asks about a species but you only have family tools, get basic info with get_bird_info
 
 
 
 
 
 
 
 
 
 
153
 
154
  **Response Style:**
155
  - Use proper taxonomic terminology but explain it clearly
@@ -157,7 +182,7 @@ class SubAgentConfig:
157
  - Show how species relate within families
158
  - Provide context about family characteristics
159
  - Be educational but accessible
160
- - If you had to adjust the search, explain briefly: "The database lists this family as..."
161
 
162
  **When to defer:**
163
  - For image identification -> image_identifier
@@ -190,18 +215,19 @@ class SubAgentConfig:
190
  **Your Team:**
191
  - **image_identifier**: Identifies birds from photos using ML classification and fetches species info
192
  - **taxonomy_specialist**: Conservation status, taxonomic families, classification queries
193
- - **generalist**: Audio finder specialist - finds birds with audio recordings and retrieves bird calls/songs
194
 
195
  **Your Role:**
196
  Analyze each user request and route it to the MOST appropriate specialist.
197
 
198
  **Routing Guidelines:**
199
  1. **Image uploads/URLs** β†’ image_identifier (has classification tools)
200
- 2. **Species information requests** β†’ image_identifier (has get_bird_info and get_bird_images)
201
  3. **"Audio"/"sound"/"song"/"call"/"recording"** β†’ generalist (has audio search and retrieval)
202
- 4. **"Family"/"families" + broad questions** β†’ taxonomy_specialist (has family tools)
203
- 5. **"Conservation"/"endangered"/"threatened"** β†’ taxonomy_specialist (has status filters)
204
- 6. **Taxonomic relationships** β†’ taxonomy_specialist (specializes in classification)
 
205
 
206
  **Decision-making:**
207
  - Consider the user's INTENT, not just keywords
@@ -213,6 +239,8 @@ Analyze each user request and route it to the MOST appropriate specialist.
213
  - Be decisive - route quickly
214
  - Don't duplicate specialist work - let them handle their domain
215
  - Synthesize multi-turn conversations if needed
 
 
216
  """
217
 
218
  @staticmethod
 
21
  Dict mapping mode names to their configurations
22
  """
23
  return {
24
+ "Supervisor (Multi-Agent)": {
25
  "description": "Router orchestrates 3 specialized agents",
26
  "subagents": ["image_identifier", "taxonomy_specialist", "generalist"],
27
  "use_router": True
 
79
  - Mention if confidence is low and suggest why
80
  - Keep responses focused and concise
81
 
82
+ **CRITICAL - No Hallucination:**
83
+ - If get_bird_images returns empty/no images: Tell user "No reference images available for this species"
84
+ - If get_bird_info returns no data: Tell user "Species information not available in database"
85
+ - NEVER fabricate image URLs, species data, or make up placeholder links
86
+ - Only show images and data that are actually returned by the API tools
87
+ - If a tool fails or returns empty results, honestly report it to the user
88
+
89
  **When to defer:**
90
  - For audio/sound/call queries -> generalist
91
  - For family/taxonomy queries -> taxonomy_specialist
 
127
  - Describe what makes each bird unique
128
  - If you had to search multiple times, mention it briefly: "I found information on Dove (the database uses this simplified name)"
129
 
130
+ **CRITICAL - No Hallucination:**
131
+ - If get_bird_images returns empty/no images: Tell user "No reference images available for this species"
132
+ - If get_bird_audio returns empty/no audio: Tell user "No audio recordings available for this species"
133
+ - If search_birds returns no results: Tell user "No birds found matching that criteria"
134
+ - NEVER fabricate URLs, bird names, species data, or make up placeholder content
135
+ - Only show images, audio, and data that are actually returned by the API tools
136
+ - If a tool fails or returns empty results, honestly report it to the user
137
+
138
  **When to defer:**
139
  - For image identification -> image_identifier
140
  - For conservation status filtering -> taxonomy_specialist
 
160
  4. Educate users about bird conservation
161
 
162
  **Search Strategy (IMPORTANT):**
163
+
164
+ **For conservation status queries:**
165
+ 1. Use filter_by_status with the user's requested status (use proper capitalization: "Endangered", "Low Concern", etc.)
166
+ 2. CRITICAL: Check the "status" field in EVERY returned bird result
167
+ 3. If results have DIFFERENT status than what user requested:
168
+ - Inform user honestly: "The database has no birds with '{requested_status}' status"
169
+ - Explain what you found: "The results returned birds with '{actual_status}' status instead"
170
+ - Suggest: "The database primarily contains 'Low Concern' species. Would you like to see those instead?"
171
+ 4. NEVER present birds with wrong status as if they match the user's request
172
+ 5. Only show birds whose status field exactly matches what the user asked for
173
+
174
+ **For family name searches:**
175
+ - If no results, try variations: "Cardinalidae" β†’ "Cardinal"
176
+ - Try broader terms: specific family β†’ general group
177
+ - Return closest match and explain differences
178
 
179
  **Response Style:**
180
  - Use proper taxonomic terminology but explain it clearly
 
182
  - Show how species relate within families
183
  - Provide context about family characteristics
184
  - Be educational but accessible
185
+ - If you had to adjust the search, explain briefly
186
 
187
  **When to defer:**
188
  - For image identification -> image_identifier
 
215
  **Your Team:**
216
  - **image_identifier**: Identifies birds from photos using ML classification and fetches species info
217
  - **taxonomy_specialist**: Conservation status, taxonomic families, classification queries
218
+ - **generalist**: Database search specialist - finds birds using search_birds tool, can filter by name/region/family/status, and retrieves audio recordings
219
 
220
  **Your Role:**
221
  Analyze each user request and route it to the MOST appropriate specialist.
222
 
223
  **Routing Guidelines:**
224
  1. **Image uploads/URLs** β†’ image_identifier (has classification tools)
225
+ 2. **"Search"/"find"/"examples"/"list birds"** β†’ generalist (has search_birds tool for database queries)
226
  3. **"Audio"/"sound"/"song"/"call"/"recording"** β†’ generalist (has audio search and retrieval)
227
+ 4. **Species info by name** β†’ image_identifier (has get_bird_info and get_bird_images)
228
+ 5. **"Family"/"families" + broad questions** β†’ taxonomy_specialist (has family tools)
229
+ 6. **"Conservation"/"endangered"/"threatened"** β†’ taxonomy_specialist (has status filters)
230
+ 7. **Taxonomic relationships** β†’ taxonomy_specialist (specializes in classification)
231
 
232
  **Decision-making:**
233
  - Consider the user's INTENT, not just keywords
 
239
  - Be decisive - route quickly
240
  - Don't duplicate specialist work - let them handle their domain
241
  - Synthesize multi-turn conversations if needed
242
+ - If a specialist reports no data found, accept and relay this to the user honestly
243
+ - Never add or fabricate information that wasn't provided by the specialist
244
  """
245
 
246
  @staticmethod