Bots¶
AbstractBot ¶
AbstractBot(name: str = 'Nav', system_prompt: str = None, llm: Union[str, Type[AbstractClient], AbstractClient, Callable, str] = None, instructions: str = None, tools: List[Union[str, AbstractTool, ToolDefinition]] = None, tool_threshold: float = 0.7, use_kb: bool = False, local_kb: bool = False, debug: bool = False, strict_mode: bool = True, block_on_threat: bool = False, injection_detection: bool = True, injection_probability_threshold: float = 0.98, output_mode: OutputMode = OutputMode.DEFAULT, include_search_tool: bool = False, warmup_on_configure: bool = False, prompt_builder: PromptBuilder = None, prompt_preset: str = None, event_bus: Optional[Any] = None, **kwargs)
Bases: MCPEnabledMixin, DBInterface, LocalKBMixin, EventEmitterMixin, ToolInterface, VectorInterface, ABC
AbstractBot.
This class is an abstract representation a base abstraction for all Chatbots. Inherits from ToolInterface for tool management and VectorInterface for vector store operations.
Initialize the Chatbot with the given configuration.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Name of the bot.
TYPE:
|
system_prompt
|
Custom system prompt for the bot.
TYPE:
|
llm
|
LLM configuration.
TYPE:
|
instructions
|
Additional instructions to append to the system prompt.
TYPE:
|
tools
|
List of tools to initialize.
TYPE:
|
tool_threshold
|
Confidence threshold for tool usage.
TYPE:
|
use_kb
|
Whether to use knowledge bases.
TYPE:
|
debug
|
Enable debug mode.
TYPE:
|
strict_mode
|
Enable strict security mode.
TYPE:
|
block_on_threat
|
Block responses on detected threats.
TYPE:
|
injection_detection
|
Run the prompt-injection detector on user input. Default True. Set False on bots whose inputs are short imperative commands the detector tends to misclassify.
TYPE:
|
injection_probability_threshold
|
Minimum pytector probability (0.0-1.0) required to treat input as an injection. Default 0.98. Raise to reduce false positives.
TYPE:
|
output_mode
|
Default output mode for the bot.
TYPE:
|
include_search_tool
|
Whether to include the 'search_tools' meta-tool. Set to False for agents that rely on RAG context. Default is True.
TYPE:
|
prompt_builder
|
Explicit composable prompt builder. Takes precedence over prompt_preset when provided.
TYPE:
|
prompt_preset
|
Name of a prompt preset to use for composable prompt layers. When set, uses PromptBuilder instead of legacy system_prompt_template. Default is None (legacy behavior).
TYPE:
|
event_bus
|
Optional
TYPE:
|
**kwargs
|
Additional keyword arguments for configuration.
DEFAULT:
|
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 | |
prompt_builder
property
writable
¶
Get the composable prompt builder, if set.
is_configured
property
¶
Return whether the bot has completed its configuration.
add_event_listener ¶
Add a listener for an event.
.. deprecated::
add_event_listener is deprecated. Use
self.events.subscribe(EventClass, callback) from
parrot.core.events.lifecycle instead.
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
set_program ¶
define_store_config ¶
Override this method to declaratively configure the vector store.
Similar to agent_tools(), this is called during configure() lifecycle.
| RETURNS | DESCRIPTION |
|---|---|
Optional[StoreConfig]
|
StoreConfig or None if no store needed. |
Example
def define_store_config(self) -> StoreConfig: return StoreConfig( vector_store='postgres', table='employee_docs', schema='hr', embedding_model={"model": "thenlper/gte-base", "model_type": "huggingface"}, dimension=768, dsn="postgresql+asyncpg://user:pass@host/db", auto_create=True )
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
register_kb ¶
Register a new knowledge base.
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
get_policy_rules ¶
Return policy rules for this bot.
Override in subclasses to provide dynamic rules computed at
instantiation time. The default implementation returns the class
attribute policy_rules.
| RETURNS | DESCRIPTION |
|---|---|
list
|
A list of dicts matching the
TYPE:
|
Example::
class FinanceBot(AbstractBot):
def get_policy_rules(self) -> list:
return [
{"action": "agent:chat", "effect": "allow",
"groups": [self.allowed_group]},
]
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
configure_conversation_memory ¶
Configure the unified conversation memory system.
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
configure_kb
async
¶
Configure Knowledge Base.
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
configure
async
¶
Basic Configuration of Bot.
Wrapped in try/except/finally so self._configured is always
flipped to True at the end, even when an inner step raises.
Without this guarantee an uncaught error during configure() leaves
_configured = False; callers that gate on is_configured
(e.g. BotManager.get_bot()) then re-enter configure() on the
next request, which re-registers already-registered toolkits and
raises ToolNameCollisionError on top of the original failure —
masking the real cause.
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 | |
post_configure
async
¶
Hook called at the end of :meth:configure.
Runs after the base configuration is complete and self.app has
been set, giving subclasses a safe place to wire up resources that
depend on the aiohttp application (e.g. fetching
app['jira_oauth_manager'] and constructing an OAuth-aware
toolkit, opening a DB pool, registering a scheduler).
The default implementation is a no-op. Subclasses that override
this should await super().post_configure() first to stay
forward-compatible with future base-class setup added here.
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
warmup_embeddings
async
¶
Warm up embedding/KB/vector-store models to avoid first-ask latency.
Embedding model loading is delegated to EmbeddingRegistry.preload()
so multiple bots sharing the same model incur only one load. Non-
embedding warmup (vector-store connection pool, KB document loading)
is preserved unchanged.
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
get_conversation_memory ¶
Factory function to create conversation memory instances.
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
get_conversation_history
async
¶
get_conversation_history(user_id: str, session_id: str, chatbot_id: Optional[str] = None) -> Optional[ConversationHistory]
Get conversation history using unified memory system.
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
create_conversation_history
async
¶
create_conversation_history(user_id: str, session_id: str, metadata: Optional[Dict[str, Any]] = None, chatbot_id: Optional[str] = None) -> ConversationHistory
Create new conversation history using unified memory system.
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
save_conversation_turn
async
¶
save_conversation_turn(user_id: str, session_id: str, turn: ConversationTurn, chatbot_id: Optional[str] = None) -> None
Save a conversation turn using unified memory system.
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
clear_conversation_history
async
¶
Clear conversation history using unified memory system.
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
delete_conversation_history
async
¶
delete_conversation_history(user_id: str, session_id: str, chatbot_id: Optional[str] = None) -> bool
Delete conversation history entirely using unified memory system.
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
list_user_conversations
async
¶
List all conversation sessions for a user.
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
configure_store_router ¶
configure_store_router(config: Any, ontology_resolver: Optional[Any] = None, multi_store_tool: Optional[Any] = None) -> None
Configure the store-level router for this bot.
Once configured, :meth:_build_vector_context will route each
query through StoreRouter instead of dispatching directly to
self.store.
Calling this method twice replaces the prior router and cache.
| PARAMETER | DESCRIPTION |
|---|---|
config
|
A :class:
TYPE:
|
ontology_resolver
|
Optional ontology resolver forwarded to
:class:
TYPE:
|
multi_store_tool
|
Optional
:class:
TYPE:
|
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
get_vector_context
async
¶
get_vector_context(question: str, search_type: str = 'similarity', search_kwargs: dict = None, metric_type: str = 'COSINE', limit: int = 10, score_threshold: float = None, ensemble_config: dict = None, return_sources: bool = False, expand_to_parent: Optional[bool] = None) -> str
Get relevant context from vector store.
Args:
question (str): The user's question to search context for.
search_type (str): Type of search to perform ('similarity', 'mmr', 'ensemble').
search_kwargs (dict): Additional parameters for the search.
expand_to_parent (Optional[bool]): Per-call override for parent expansion
(FEAT-128). None → use bot-level default (self.expand_to_parent).
True → always expand. False → always return children.
metric_type (str): Metric type for vector search (e.g., 'COSINE', 'EUCLIDEAN').
limit (int): Maximum number of context items to retrieve.
score_threshold (float): Minimum score for context relevance.
ensemble_config (dict): Configuration for ensemble search.
return_sources (bool): Whether to extract enhanced source information
Returns:
tuple: (context_string, metadata_dict)
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 | |
build_conversation_context ¶
build_conversation_context(history: ConversationHistory, max_chars_per_message: int = 200, max_total_chars: int = 1500, include_turn_timestamps: bool = False, smart_truncation: bool = True) -> str
Build conversation context from history using Template to avoid f-string conflicts.
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 | |
is_agent_mode ¶
Check if the bot is configured to operate in agent mode.
is_conversational_mode ¶
Check if the bot is configured for pure conversational mode.
get_operation_mode ¶
Get the current operation mode of the bot.
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
get_tool ¶
list_tool_categories ¶
get_tools_by_category ¶
create_system_prompt
async
¶
create_system_prompt(user_context: str = '', vector_context: str = '', conversation_context: str = '', kb_context: str = '', pageindex_context: str = '', metadata: Optional[Dict[str, Any]] = None, memory_context: Optional[str] = None, **kwargs) -> 'Union[str, List]'
Create the complete system prompt for the LLM with user context support.
| PARAMETER | DESCRIPTION |
|---|---|
user_context
|
User-specific context for the database interaction
TYPE:
|
vector_context
|
Vector store context
TYPE:
|
conversation_context
|
Previous conversation context
TYPE:
|
kb_context
|
Knowledge base context (KB Facts)
TYPE:
|
pageindex_context
|
PageIndex tree structure context for tree-based RAG
TYPE:
|
metadata
|
Additional metadata
TYPE:
|
memory_context
|
Optional long-term memory context from LongTermMemoryMixin
TYPE:
|
**kwargs
|
Additional template variables
DEFAULT:
|
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 | |
get_user_context
async
¶
Retrieve user-specific context for the database interaction.
| PARAMETER | DESCRIPTION |
|---|---|
user_id
|
User identifier
TYPE:
|
session_id
|
Session identifier
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
User-specific context
TYPE:
|
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
conversation
abstractmethod
async
¶
conversation(question: str, session_id: Optional[str] = None, user_id: Optional[str] = None, search_type: str = 'similarity', search_kwargs: dict = None, metric_type: str = 'COSINE', use_vector_context: bool = True, use_conversation_history: bool = True, return_sources: bool = True, return_context: bool = False, memory: Optional[Callable] = None, ensemble_config: dict = None, mode: str = 'adaptive', ctx: Optional[RequestContext] = None, output_mode: OutputMode = OutputMode.DEFAULT, format_kwargs: dict = None, trace_context: Optional[TraceContext] = None, **kwargs) -> AIMessage
Conversation method with vector store and history integration.
| PARAMETER | DESCRIPTION |
|---|---|
question
|
The user's question
TYPE:
|
session_id
|
Session identifier for conversation history
TYPE:
|
user_id
|
User identifier
TYPE:
|
search_type
|
Type of search to perform ('similarity', 'mmr', 'ensemble')
TYPE:
|
search_kwargs
|
Additional search parameters
TYPE:
|
metric_type
|
Metric type for vector search (e.g., 'COSINE', 'EUCLIDEAN')
TYPE:
|
limit
|
Maximum number of context items to retrieve
|
score_threshold
|
Minimum score for context relevance
|
use_vector_context
|
Whether to retrieve context from vector store
TYPE:
|
use_conversation_history
|
Whether to use conversation history
TYPE:
|
**kwargs
|
Additional arguments for LLM
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
AIMessage
|
The response from the LLM
TYPE:
|
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
as_markdown ¶
as_markdown(response: AIMessage, return_sources: bool = False, return_context: bool = False, return_tools: bool = False) -> str
Enhanced markdown formatting with context information.
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 | |
get_response ¶
get_response(response: AIMessage, return_sources: bool = True, return_context: bool = False, return_tools: bool = False) -> AIMessage
Response processing with error handling.
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
session
async
¶
session(ctx: Optional[RequestContext] = None, *, request: 'web.Request' = None, app: Optional[Any] = None, llm: Optional[Any] = None, user_id: Union[str, int, None] = None, session_id: Optional[str] = None, **ctx_kwargs) -> AsyncIterator['AbstractBot']
Bind a RequestContext to the current asyncio task for the block's lifetime.
Replaces the removed retrieval() method. Absorbs PBAC enforcement
and concurrency limiting. Anything awaited beneath this block can call
current_context() and get the same RequestContext object without
explicit parameter threading.
Delegates access control entirely to the PDP evaluator (PBAC). When no PDP is configured (e.g. during development or when policies/ dir is absent), this method is fail-open and allows all requests.
Superuser bypass is handled by policies/defaults.yaml:allow_superuser_all
at priority=100 — no hardcoded superuser check here.
| PARAMETER | DESCRIPTION |
|---|---|
ctx
|
Pre-built RequestContext. If provided, all other keyword args are ignored (ctx takes precedence).
TYPE:
|
request
|
The aiohttp Request object. Required for session extraction.
TYPE:
|
app
|
Optional aiohttp Application. Falls back to
TYPE:
|
llm
|
Optional LLM override for this request.
TYPE:
|
user_id
|
User identifier stored on the RequestContext.
TYPE:
|
session_id
|
Session identifier stored on the RequestContext.
TYPE:
|
**ctx_kwargs
|
Additional context passed to RequestContext.
DEFAULT:
|
| YIELDS | DESCRIPTION |
|---|---|
AbstractBot
|
The bot instance itself (
TYPE::
|
| RAISES | DESCRIPTION |
|---|---|
HTTPUnauthorized
|
When the PDP evaluator explicitly denies access
for this agent and action |
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 | |
shutdown
async
¶
Shutdown.
Optional shutdown method to clean up resources. This method can be overridden in subclasses to perform any necessary cleanup tasks, such as closing database connections, releasing resources, etc. Args: **kwargs: Additional keyword arguments.
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
invoke
abstractmethod
async
¶
invoke(question: str, session_id: Optional[str] = None, user_id: Optional[str] = None, use_conversation_history: bool = True, memory: Optional[Callable] = None, ctx: Optional[RequestContext] = None, response_model: Optional[Type[BaseModel]] = None, **kwargs) -> AIMessage
Simplified conversation method with adaptive mode and conversation history.
| PARAMETER | DESCRIPTION |
|---|---|
question
|
The user's question
TYPE:
|
session_id
|
Session identifier for conversation history
TYPE:
|
user_id
|
User identifier
TYPE:
|
use_conversation_history
|
Whether to use conversation history
TYPE:
|
memory
|
Optional memory callable override
TYPE:
|
**kwargs
|
Additional arguments for LLM
DEFAULT:
|
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
resume
async
¶
Resume a suspended conversation turn using the underlying client.
| PARAMETER | DESCRIPTION |
|---|---|
session_id
|
Session identifier
TYPE:
|
user_input
|
The user input text
TYPE:
|
state
|
The suspended state dictionary
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
AIMessage
|
The response from the LLM
TYPE:
|
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
get_conversation_summary
async
¶
Get a summary of the conversation history.
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
get_tools_count ¶
Get the total number of available tools from LLM client.
has_tools ¶
get_available_tools ¶
register_tools ¶
Register multiple tools via LLM client's tool_manager.
post_login
async
¶
Per-user initialization hook run after authentication.
Called by integration wrappers (Telegram, MS Teams, Slack, HTTP)
once per user — typically right after primary authentication
succeeds, or on the first authenticated message. At the time of
invocation the agent's tool_manager has already been swapped
to the per-user clone (in singleton_agent mode) or the whole
agent is already the per-user instance (in full-clone mode), so
any toolkit wiring, credential resolver binding, or cache
priming done here is safely scoped to this user.
Default implementation is a no-op. Subclasses override to seed state that depends on who the caller is (e.g., bind a Jira client to the user's tokens, register user-specific toolkits).
| PARAMETER | DESCRIPTION |
|---|---|
user_context
|
Channel-agnostic identity snapshot produced by
the integration wrapper. See
TYPE:
|
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
clone_for_user
async
¶
Return an independent agent instance scoped to a single user.
Used by integration wrappers when singleton_agent is disabled
so each user gets a fully isolated agent (no shared mutable
state, no swap-and-restore dance around the shared ToolManager).
This is heavier than cloning only the ToolManager but removes
the need for a cross-user lock and supports tools that keep
state on self.
The default implementation raises NotImplementedError because
reconstructing an agent faithfully requires knowledge its base
class does not have (LLM config, vector store, memory backend,
system prompt, toolkits). Subclasses that want per-user agent
isolation must implement this method — typically by calling
self.__class__(**self._init_kwargs) if they captured their
construction kwargs, or by delegating to a factory registered
with the BotManager.
| PARAMETER | DESCRIPTION |
|---|---|
user_context
|
Channel-agnostic identity snapshot.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
'AbstractBot'
|
A brand-new agent instance. The caller is responsible for |
'AbstractBot'
|
invoking |
'AbstractBot'
|
the instance is ready. |
| RAISES | DESCRIPTION |
|---|---|
NotImplementedError
|
Default behavior. Opt into
|
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
ask
abstractmethod
async
¶
ask(question: str, session_id: Optional[str] = None, user_id: Optional[str] = None, search_type: str = 'similarity', search_kwargs: dict = None, metric_type: str = 'COSINE', use_vector_context: bool = True, use_conversation_history: bool = True, return_sources: bool = True, memory: Optional[Callable] = None, ensemble_config: dict = None, ctx: Optional[RequestContext] = None, structured_output: Optional[Union[Type[BaseModel], StructuredOutputConfig]] = None, output_mode: OutputMode = OutputMode.DEFAULT, format_kwargs: dict = None, use_tools: bool = True, trace_context: Optional[TraceContext] = None, **kwargs) -> AIMessage
Ask method with tools always enabled and output formatting support.
Note
BeforeInvokeEvent, AfterInvokeEvent, and
InvokeFailedEvent are emitted by the concrete implementation in
parrot/bots/base.py. This abstract declaration carries the
trace_context kwarg signature that callers must respect; the
event emission lives in BaseBot.ask().
| PARAMETER | DESCRIPTION |
|---|---|
question
|
The user's question
TYPE:
|
session_id
|
Session identifier for conversation history
TYPE:
|
user_id
|
User identifier
TYPE:
|
search_type
|
Type of search to perform ('similarity', 'mmr', 'ensemble')
TYPE:
|
search_kwargs
|
Additional search parameters
TYPE:
|
metric_type
|
Metric type for vector search
TYPE:
|
use_vector_context
|
Whether to retrieve context from vector store
TYPE:
|
use_conversation_history
|
Whether to use conversation history
TYPE:
|
return_sources
|
Whether to return sources in response
TYPE:
|
memory
|
Optional memory handler
TYPE:
|
ensemble_config
|
Configuration for ensemble search
TYPE:
|
ctx
|
Request context
TYPE:
|
output_mode
|
Output formatting mode ('default', 'terminal', 'html', 'json')
TYPE:
|
structured_output
|
Structured output configuration or model
TYPE:
|
format_kwargs
|
Additional kwargs for formatter (show_metadata, show_sources, etc.)
TYPE:
|
**kwargs
|
Additional arguments for LLM
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
AIMessage
|
AIMessage or formatted output based on output_mode |
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
ask_stream
abstractmethod
async
¶
ask_stream(question: str, session_id: Optional[str] = None, user_id: Optional[str] = None, search_type: str = 'similarity', search_kwargs: dict = None, metric_type: str = 'COSINE', use_vector_context: bool = True, use_conversation_history: bool = True, return_sources: bool = True, memory: Optional[Callable] = None, ensemble_config: dict = None, ctx: Optional[RequestContext] = None, structured_output: Optional[Union[Type[BaseModel], StructuredOutputConfig]] = None, output_mode: OutputMode = OutputMode.DEFAULT, trace_context: Optional[TraceContext] = None, **kwargs) -> AsyncIterator[Union[str, AIMessage]]
Stream responses using the same preparation logic as :meth:ask.
Yields successive string chunks of the response. The final yielded
element is an :class:~parrot.models.responses.AIMessage containing
the full response text together with response metadata (token usage,
model information, etc.).
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
get_infographic
async
¶
get_infographic(question: str, template: Optional[str] = None, session_id: Optional[str] = None, user_id: Optional[str] = None, use_vector_context: bool = True, use_conversation_history: bool = False, theme: Optional[str] = None, accept: str = 'text/html', ctx: Optional[RequestContext] = None, **kwargs) -> AIMessage
Generate a structured infographic response.
Uses a template to instruct the LLM to return an InfographicResponse with typed blocks (title, hero_card, chart, summary, etc.).
Content negotiation is controlled by the accept parameter:
- "text/html" (default): renders a self-contained HTML document
with inline CSS and ECharts JS — backward compatible.
- "application/json": returns the raw InfographicResponse JSON.
| PARAMETER | DESCRIPTION |
|---|---|
question
|
The topic, query, or data description for the infographic.
TYPE:
|
template
|
Template name from the registry (e.g., 'basic', 'executive', 'dashboard', 'comparison', 'timeline', 'minimal'). Pass None to let the LLM decide the block structure freely.
TYPE:
|
session_id
|
Session identifier for conversation history.
TYPE:
|
user_id
|
User identifier.
TYPE:
|
use_vector_context
|
Whether to retrieve context from vector store.
TYPE:
|
use_conversation_history
|
Whether to use conversation history.
TYPE:
|
theme
|
Color theme hint ('light', 'dark', 'corporate', 'vibrant').
TYPE:
|
accept
|
Content type for the response. Defaults to
TYPE:
|
ctx
|
Request context.
TYPE:
|
**kwargs
|
Additional arguments passed to ask().
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
AIMessage
|
AIMessage with structured_output containing InfographicResponse. |
AIMessage
|
When |
AIMessage
|
the rendered HTML and |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If the template name is not found in the registry. |
Example
response = await bot.get_infographic( "Analyze Q4 2025 sales performance", template="executive", theme="corporate", ) infographic = response.structured_output # InfographicResponse for block in infographic.blocks: print(block.type, block)
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 | |
enhance_infographic
async
¶
enhance_infographic(*, skeleton: str, brief: str, data_context: 'Dict[str, Any]', js_bundles_available: 'List[Any]') -> str
Enhance a deterministic infographic skeleton with LLM-generated JS.
The LLM is instructed to add interactivity using only the bundles in
js_bundles_available. The returned HTML is validated by the
toolkit's validate_enhanced_html helper before being persisted.
| PARAMETER | DESCRIPTION |
|---|---|
skeleton
|
Complete HTML document from the deterministic render pass.
TYPE:
|
brief
|
Short description of the desired interactive enhancement.
TYPE:
|
data_context
|
JSON-serialisable dict of DataFrames (as records).
TYPE:
|
js_bundles_available
|
List of
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Enhanced HTML string. The caller is responsible for validation. |
| RAISES | DESCRIPTION |
|---|---|
Exception
|
Any LLM completion error is propagated to the caller. |
Note
This method is intentionally simple — it is the caller's
responsibility to validate the returned HTML and fall back to the
skeleton on InfographicValidationError(code='ENHANCE_OUTPUT_INVALID').
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 | |
enhance_interactive
async
¶
enhance_interactive(*, skeleton: str, brief: str, data_context: 'Dict[str, Any]', js_bundles_available: 'List[Any]', library_guide: str = '') -> str
Author a self-contained interactive HTML page from a scaffold skeleton.
The free-form counterpart to :meth:enhance_infographic: the LLM fills
the skeleton's <!-- SLOT:* --> markers and adds interactive JS using
only the whitelisted js_bundles_available. The returned HTML is
validated by the caller (InteractiveToolkit) before persistence.
| PARAMETER | DESCRIPTION |
|---|---|
skeleton
|
Complete HTML skeleton with
TYPE:
|
brief
|
Description of the page to build (slot contents, interactivity).
TYPE:
|
data_context
|
JSON-serialisable source-of-truth data for figures.
TYPE:
|
js_bundles_available
|
TYPE:
|
library_guide
|
Usage snippets + reference types for the chosen libraries (built by the toolkit).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Enhanced HTML string. The caller is responsible for validation and |
str
|
for falling back to the deterministic skeleton on rejection. |
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 | |
get_interactive
async
¶
get_interactive(question: str, template: str = 'report', libraries: Optional[List[str]] = None, theme: Optional[str] = None, mode: str = 'enhance', data_context: Optional['Dict[str, Any]'] = None, title: Optional[str] = None) -> AIMessage
Generate a self-contained interactive HTML page (direct, no persistence).
Convenience wrapper that drives the same catalog + enhance pipeline as
:class:~parrot.tools.interactive_toolkit.InteractiveToolkit but returns
the rendered HTML inline in an :class:AIMessage instead of persisting an
artifact (persistence is the toolkit/handler's responsibility).
| PARAMETER | DESCRIPTION |
|---|---|
question
|
Description of the page to build (becomes the enhance brief).
TYPE:
|
template
|
Scaffold template name (
TYPE:
|
libraries
|
Library names to use; defaults to the template's allow-list.
TYPE:
|
theme
|
Theme name (
TYPE:
|
mode
|
TYPE:
|
data_context
|
Optional JSON-serialisable data source for figures.
TYPE:
|
title
|
Optional document title.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
AIMessage
|
|
AIMessage
|
and whose |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If the template name is not in the catalog. |
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 | |
cleanup
async
¶
Clean up agent resources including KB connections.
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
BaseBot ¶
BaseBot(name: str = 'Nav', system_prompt: str = None, llm: Union[str, Type[AbstractClient], AbstractClient, Callable, str] = None, instructions: str = None, tools: List[Union[str, AbstractTool, ToolDefinition]] = None, tool_threshold: float = 0.7, use_kb: bool = False, local_kb: bool = False, debug: bool = False, strict_mode: bool = True, block_on_threat: bool = False, injection_detection: bool = True, injection_probability_threshold: float = 0.98, output_mode: OutputMode = OutputMode.DEFAULT, include_search_tool: bool = False, warmup_on_configure: bool = False, prompt_builder: PromptBuilder = None, prompt_preset: str = None, event_bus: Optional[Any] = None, **kwargs)
Bases: AbstractBot
Base Bot implementation providing concrete implementations of abstract methods defined in AbstractBot.
This is the recommended base class for creating custom bots. It provides full implementations of ask, ask_stream, invoke, and conversation methods with support for: - Vector store context retrieval - Knowledge base integration - Conversation history management - Tool usage (agentic mode) - Multiple output formats - Security and prompt injection detection
Subclasses can override these methods to customize behavior or use them as-is for standard bot functionality.
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 | |
conversation
async
¶
conversation(question: str, session_id: Optional[str] = None, user_id: Optional[str] = None, search_type: str = 'similarity', search_kwargs: dict = None, metric_type: Optional[str] = None, use_vector_context: bool = True, use_conversation_history: bool = True, return_sources: bool = True, return_context: bool = False, memory: Optional[Callable] = None, ensemble_config: dict = None, mode: str = 'adaptive', ctx: Optional[RequestContext] = None, output_mode: OutputMode = OutputMode.DEFAULT, format_kwargs: dict = None, system_prompt: Optional[str] = None, trace_context=None, **kwargs) -> AIMessage
Conversation method with vector store and history integration.
.. deprecated::
conversation() is deprecated and will be removed in a future
release. Use :meth:ask instead — it provides the same retrieval
pipeline plus tool support, prompt-injection sanitization, and
long-term memory hooks.
| PARAMETER | DESCRIPTION |
|---|---|
question
|
The user's question
TYPE:
|
session_id
|
Session identifier for conversation history
TYPE:
|
user_id
|
User identifier
TYPE:
|
search_type
|
Type of search to perform ('similarity', 'mmr', 'ensemble')
TYPE:
|
search_kwargs
|
Additional search parameters
TYPE:
|
metric_type
|
Metric type for vector search (e.g., 'EUCLIDEAN_DISTANCE', 'EUCLIDEAN')
TYPE:
|
limit
|
Maximum number of context items to retrieve
|
score_threshold
|
Minimum score for context relevance
|
use_vector_context
|
Whether to retrieve context from vector store
TYPE:
|
use_conversation_history
|
Whether to use conversation history
TYPE:
|
**kwargs
|
Additional arguments for LLM
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
AIMessage
|
The response from the LLM
TYPE:
|
Source code in packages/ai-parrot/src/parrot/bots/base.py
chat
async
¶
invoke
async
¶
invoke(question: str, session_id: Optional[str] = None, user_id: Optional[str] = None, use_conversation_history: bool = True, memory: Optional[Callable] = None, ctx: Optional[RequestContext] = None, response_model: Optional[Type[BaseModel]] = None, **kwargs) -> AIMessage
Simplified conversation method with adaptive mode and conversation history.
| PARAMETER | DESCRIPTION |
|---|---|
question
|
The user's question
TYPE:
|
session_id
|
Session identifier for conversation history
TYPE:
|
user_id
|
User identifier
TYPE:
|
use_conversation_history
|
Whether to use conversation history
TYPE:
|
memory
|
Optional memory callable override
TYPE:
|
**kwargs
|
Additional arguments for LLM
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
AIMessage
|
The response from the LLM
TYPE:
|
Source code in packages/ai-parrot/src/parrot/bots/base.py
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
ask
async
¶
ask(question: str, session_id: Optional[str] = None, user_id: Optional[str] = None, search_type: str = 'similarity', search_kwargs: dict = None, metric_type: Optional[str] = None, use_vector_context: bool = True, use_conversation_history: bool = True, return_sources: bool = True, memory: Optional[Callable] = None, ensemble_config: dict = None, ctx: Optional[RequestContext] = None, permission_context: Optional[Any] = None, structured_output: Optional[Union[Type[BaseModel], StructuredOutputConfig]] = None, system_prompt: Optional[str] = None, output_mode: OutputMode = OutputMode.DEFAULT, format_kwargs: dict = None, use_tools: bool = True, trace_context=None, **kwargs) -> AIMessage
Ask method with tools always enabled and output formatting support.
| PARAMETER | DESCRIPTION |
|---|---|
question
|
The user's question
TYPE:
|
session_id
|
Session identifier for conversation history
TYPE:
|
user_id
|
User identifier
TYPE:
|
search_type
|
Type of search to perform ('similarity', 'mmr', 'ensemble')
TYPE:
|
search_kwargs
|
Additional search parameters
TYPE:
|
system_prompt
|
System prompt to append to the generated system prompt
TYPE:
|
metric_type
|
Metric type for vector search
TYPE:
|
use_vector_context
|
Whether to retrieve context from vector store
TYPE:
|
use_conversation_history
|
Whether to use conversation history
TYPE:
|
return_sources
|
Whether to return sources in response
TYPE:
|
memory
|
Optional memory handler
TYPE:
|
ensemble_config
|
Configuration for ensemble search
TYPE:
|
ctx
|
Request context
TYPE:
|
output_mode
|
Output formatting mode ('default', 'terminal', 'html', 'json')
TYPE:
|
structured_output
|
Structured output configuration or model
TYPE:
|
format_kwargs
|
Additional kwargs for formatter (show_metadata, show_sources, etc.)
TYPE:
|
**kwargs
|
Additional arguments for LLM
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
AIMessage
|
AIMessage or formatted output based on output_mode |
Source code in packages/ai-parrot/src/parrot/bots/base.py
911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 | |
ask_stream
async
¶
ask_stream(question: str, session_id: Optional[str] = None, user_id: Optional[str] = None, search_type: str = 'similarity', search_kwargs: dict = None, metric_type: Optional[str] = None, use_vector_context: bool = True, use_conversation_history: bool = True, return_sources: bool = True, memory: Optional[Callable] = None, ensemble_config: dict = None, ctx: Optional[RequestContext] = None, permission_context: Optional[Any] = None, structured_output: Optional[Union[Type[BaseModel], StructuredOutputConfig]] = None, output_mode: OutputMode = OutputMode.DEFAULT, system_prompt: Optional[str] = None, trace_context=None, **kwargs) -> AsyncIterator[Union[str, AIMessage]]
Stream responses using the same preparation logic as :meth:ask.
Source code in packages/ai-parrot/src/parrot/bots/base.py
1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 | |
BasicBot ¶
BasicBot(name: str = 'Nav', system_prompt: str = None, llm: Union[str, Type[AbstractClient], AbstractClient, Callable, str] = None, instructions: str = None, tools: List[Union[str, AbstractTool, ToolDefinition]] = None, tool_threshold: float = 0.7, use_kb: bool = False, local_kb: bool = False, debug: bool = False, strict_mode: bool = True, block_on_threat: bool = False, injection_detection: bool = True, injection_probability_threshold: float = 0.98, output_mode: OutputMode = OutputMode.DEFAULT, include_search_tool: bool = False, warmup_on_configure: bool = False, prompt_builder: PromptBuilder = None, prompt_preset: str = None, event_bus: Optional[Any] = None, **kwargs)
Bases: BaseBot
Represents an BasicBot in Navigator.
Each BasicBot has a name, a role, a goal, a backstory, and an optional language model (llm).
Source code in packages/ai-parrot/src/parrot/bots/abstract.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 | |
Chatbot ¶
Chatbot(name: str = 'Nav', system_prompt: str = None, human_prompt: str = None, from_database: bool = True, tools: List[Union[str, AbstractTool]] = None, **kwargs)
Bases: BaseBot
Represents an Bot (Chatbot, Agent) in Navigator.
This class is the base for all chatbots and agents in the ai-parrot framework.
This class can be used in two ways
- Manual creation: bot = Chatbot(name="MyBot", tools=[...])
- Database loading: bot = Chatbot(name="MyBot", from_database=True)
Initialize the Chatbot with manual creation or database loading support.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Bot name
TYPE:
|
system_prompt
|
Custom system prompt
TYPE:
|
human_prompt
|
Custom human prompt
TYPE:
|
from_database
|
Whether to load configuration from database
TYPE:
|
tools
|
List of tools for manual creation
TYPE:
|
**kwargs
|
Additional configuration
DEFAULT:
|
Source code in packages/ai-parrot/src/parrot/bots/chatbot.py
configure
async
¶
Load configuration for this Chatbot.
Source code in packages/ai-parrot/src/parrot/bots/chatbot.py
from_manual_config
async
¶
Configure the bot manually without database dependency.
Source code in packages/ai-parrot/src/parrot/bots/chatbot.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
bot_exists
async
¶
Check if the Chatbot exists in the Database.
Source code in packages/ai-parrot/src/parrot/bots/chatbot.py
from_database
async
¶
Load the Chatbot/Agent Configuration from the Database. If the bot is not found, it will raise a ConfigError.
Source code in packages/ai-parrot/src/parrot/bots/chatbot.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 | |
update_database_config
async
¶
Update bot configuration in database.
| PARAMETER | DESCRIPTION |
|---|---|
**updates
|
Configuration updates to apply
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if update was successful, False otherwise
TYPE:
|
Source code in packages/ai-parrot/src/parrot/bots/chatbot.py
save_to_database
async
¶
Save current bot configuration to database.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if save was successful, False otherwise
TYPE:
|
Source code in packages/ai-parrot/src/parrot/bots/chatbot.py
get_configuration_summary ¶
Get a summary of the current bot configuration.
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
Dict containing configuration summary |
Source code in packages/ai-parrot/src/parrot/bots/chatbot.py
test_configuration
async
¶
Test the current bot configuration and return status.
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
Dict containing test results |
Source code in packages/ai-parrot/src/parrot/bots/chatbot.py
reload_from_database
async
¶
Reload bot configuration from database.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if reload was successful, False otherwise
TYPE:
|
Source code in packages/ai-parrot/src/parrot/bots/chatbot.py
Agent ¶
Agent(name: str = 'Agent', agent_id: str = 'agent', use_llm: str = 'google', llm: str = None, tools: List[AbstractTool] = None, system_prompt: str = None, human_prompt: str = None, use_tools: bool = True, instructions: Optional[str] = None, dataframes: Optional[Dict[str, DataFrame]] = None, **kwargs)
Bases: BasicAgent
A general-purpose agent with no additional tools.
Source code in packages/ai-parrot/src/parrot/bots/agent.py
BasicAgent ¶
BasicAgent(name: str = 'Agent', agent_id: str = 'agent', use_llm: str = 'google', llm: str = None, tools: List[AbstractTool] = None, system_prompt: str = None, human_prompt: str = None, use_tools: bool = True, instructions: Optional[str] = None, dataframes: Optional[Dict[str, DataFrame]] = None, **kwargs)
Bases: Chatbot, NotificationMixin
Represents an Agent in Navigator.
Agents are chatbots that can access to Tools and execute commands. Each Agent has a name, a role, a goal, a backstory, and an optional language model (llm).
These agents are designed to interact with structured and unstructured data sources.
Features: - Built-in MCP server support (no separate mixin needed) - Can connect to HTTP, OAuth, API-key authenticated, and local MCP servers - Automatic tool registration from MCP servers - Compatible with all existing agent functionality - Notification capabilities through various channels (e.g., email, Slack, Teams)
Source code in packages/ai-parrot/src/parrot/bots/agent.py
handle_files
async
¶
Handle uploaded files and register them as DataFrames.
| PARAMETER | DESCRIPTION |
|---|---|
attachments
|
Dictionary of uploaded files (filename: file_obj/content)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
List[str]
|
List of names of the added DataFrames |
Source code in packages/ai-parrot/src/parrot/bots/agent.py
agent_tools ¶
set_response ¶
save_document
async
¶
save_document(content: str, prefix: str = 'report', extension: str = 'txt', directory: Optional[Path] = None, subdir: str = 'documents') -> None
Save the document to a file.
Source code in packages/ai-parrot/src/parrot/bots/agent.py
open_prompt
async
¶
Opens a prompt file and returns its content.
Source code in packages/ai-parrot/src/parrot/bots/agent.py
open_query
async
¶
Opens a query string and formats it with provided keyword arguments.
Source code in packages/ai-parrot/src/parrot/bots/agent.py
generate_report
async
¶
generate_report(prompt_file: str, save: bool = False, directory: Optional[Path] = None, **kwargs) -> Tuple[AIMessage, AgentResponse]
Generate a report based on the provided prompt.
Source code in packages/ai-parrot/src/parrot/bots/agent.py
save_transcript
async
¶
save_transcript(transcript: str, filename: str = None, prefix: str = 'transcript', directory: Optional[str] = None, subdir='transcripts') -> str
Save the transcript to a file.
Source code in packages/ai-parrot/src/parrot/bots/agent.py
pdf_report
async
¶
pdf_report(content: str, filename_prefix: str = 'report', directory: Optional[Path] = None, title: str = None, **kwargs) -> str
Generate a report based on the provided prompt.
Source code in packages/ai-parrot/src/parrot/bots/agent.py
markdown_report
async
¶
markdown_report(content: str, filename: Optional[str] = None, filename_prefix: str = 'report', directory: Optional[Path] = None, subdir: str = 'documents', **kwargs) -> str
Saving Markdown report based on provided file.
Source code in packages/ai-parrot/src/parrot/bots/agent.py
speech_report
async
¶
speech_report(report: str, max_lines: int = 15, num_speakers: int = 2, podcast_instructions: Optional[str] = 'for_podcast.txt', directory: Optional[Path] = None, output_directory: Optional[Path] = None, **kwargs) -> Dict[str, Any]
Generate a Transcript Report and a Podcast based on findings.
Source code in packages/ai-parrot/src/parrot/bots/agent.py
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 | |
report
async
¶
Generate a report based on the provided prompt.
Source code in packages/ai-parrot/src/parrot/bots/agent.py
generate_presentation
async
¶
generate_presentation(content: str, filename_prefix: str = 'report', template_name: Optional[str] = None, pptx_template: str = 'corporate_template.pptx', output_dir: Optional[Path] = None, title: str = None, **kwargs)
Generate a PowerPoint presentation using the provided tool.
Source code in packages/ai-parrot/src/parrot/bots/agent.py
create_speech
async
¶
create_speech(content: str, language: str = 'en-US', only_script: bool = False, **kwargs) -> Dict[str, Any]
Generate a Transcript Report and a Podcast based on findings.
Source code in packages/ai-parrot/src/parrot/bots/agent.py
add_mcp_server
async
¶
Add an MCP server and register its tools.
| PARAMETER | DESCRIPTION |
|---|---|
config
|
MCPServerConfig with connection details
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
List[str]
|
List of registered tool names |
Example
config = MCPServerConfig( ... name="weather_api", ... url="https://api.example.com/mcp", ... auth_type="api_key", ... auth_config={"api_key": "xxx"} ... ) tools = await agent.add_mcp_server(config)
Source code in packages/ai-parrot/src/parrot/bots/agent.py
add_mcp_server_url
async
¶
add_mcp_server_url(name: str, url: str, auth_type: Optional[str] = None, auth_config: Optional[Dict[str, Any]] = None, headers: Optional[Dict[str, str]] = None, allowed_tools: Optional[List[str]] = None, blocked_tools: Optional[List[str]] = None, **kwargs) -> List[str]
Convenience method to add a public URL-based MCP server.
This is a simplified interface for adding HTTP MCP servers without manually creating MCPServerConfig objects.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Unique name for the MCP server
TYPE:
|
url
|
Base URL of the MCP server
TYPE:
|
auth_type
|
Optional authentication type ('api_key', 'bearer', 'oauth', 'basic')
TYPE:
|
auth_config
|
Authentication configuration dict
TYPE:
|
headers
|
Additional HTTP headers
TYPE:
|
allowed_tools
|
Whitelist of tool names to register
TYPE:
|
blocked_tools
|
Blacklist of tool names to skip
TYPE:
|
**kwargs
|
Additional MCPServerConfig parameters
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
List[str]
|
List of registered tool names |
Examples:
>>> # Public server with no auth
>>> tools = await agent.add_mcp_server_url(
... "public_api",
... "https://api.example.com/mcp"
... )
>>> # API key authenticated server
>>> tools = await agent.add_mcp_server_url(
... "weather",
... "https://weather.example.com/mcp",
... auth_type="api_key",
... auth_config={"api_key": "your-key-here"}
... )
>>> # Server with custom headers and tool filtering
>>> tools = await agent.add_mcp_server_url(
... "finance",
... "https://finance.example.com/mcp",
... headers={"User-Agent": "AI-Parrot/1.0"},
... allowed_tools=["get_stock_price", "get_market_data"]
... )
Source code in packages/ai-parrot/src/parrot/bots/agent.py
add_local_mcp_server
async
¶
add_local_mcp_server(name: str, script_path: Union[str, Path], interpreter: str = 'python', **kwargs) -> List[str]
Add a local stdio MCP server.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Unique name for the MCP server
TYPE:
|
script_path
|
Path to the MCP server script
TYPE:
|
interpreter
|
Interpreter to use (default: "python")
TYPE:
|
**kwargs
|
Additional MCPServerConfig parameters
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
List[str]
|
List of registered tool names |
Example
tools = await agent.add_local_mcp_server( ... "local_tools", ... "/path/to/mcp_server.py" ... )
Source code in packages/ai-parrot/src/parrot/bots/agent.py
add_http_mcp_server
async
¶
add_http_mcp_server(name: str, url: str, auth_type: Optional[str] = None, auth_config: Optional[Dict[str, Any]] = None, headers: Optional[Dict[str, str]] = None, **kwargs) -> List[str]
Add an HTTP MCP server with optional authentication.
This is an alias for add_mcp_server_url for backward compatibility.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Unique name for the MCP server
TYPE:
|
url
|
Base URL of the MCP server
TYPE:
|
auth_type
|
Optional authentication type
TYPE:
|
auth_config
|
Authentication configuration
TYPE:
|
headers
|
Additional HTTP headers
TYPE:
|
**kwargs
|
Additional MCPServerConfig parameters
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
List[str]
|
List of registered tool names |
Source code in packages/ai-parrot/src/parrot/bots/agent.py
add_api_key_mcp_server
async
¶
add_api_key_mcp_server(name: str, url: str, api_key: str, header_name: str = 'X-API-Key', use_bearer_prefix: bool = False, **kwargs) -> List[str]
Add an API-key authenticated MCP server.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Unique name for the MCP server
TYPE:
|
url
|
Base URL of the MCP server
TYPE:
|
api_key
|
API key for authentication
TYPE:
|
header_name
|
Header name for the API key (default: "X-API-Key")
TYPE:
|
use_bearer_prefix
|
If True, prepend "Bearer " to the API key value (default: False)
TYPE:
|
**kwargs
|
Additional MCPServerConfig parameters
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
List[str]
|
List of registered tool names |
Example
tools = await agent.add_api_key_mcp_server( ... "weather_api", ... "https://api.weather.com/mcp", ... api_key="your-api-key", ... header_name="Authorization" ... )
For Bearer token format (e.g., Fireflies API)¶
tools = await agent.add_api_key_mcp_server( ... "fireflies", ... "https://api.fireflies.ai/mcp", ... api_key="your-api-key", ... header_name="Authorization", ... use_bearer_prefix=True ... )
Source code in packages/ai-parrot/src/parrot/bots/agent.py
remove_mcp_server
async
¶
Remove an MCP server and unregister its tools.
| PARAMETER | DESCRIPTION |
|---|---|
server_name
|
Name of the MCP server to remove
TYPE:
|
Source code in packages/ai-parrot/src/parrot/bots/agent.py
list_mcp_servers ¶
List all connected MCP servers.
| RETURNS | DESCRIPTION |
|---|---|
List[str]
|
List of MCP server names |
get_mcp_client ¶
Get the MCP client for a specific server.
| PARAMETER | DESCRIPTION |
|---|---|
server_name
|
Name of the MCP server
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
|
MCPClient instance or None |
Source code in packages/ai-parrot/src/parrot/bots/agent.py
shutdown
async
¶
Shutdown the agent and disconnect all MCP servers.
Source code in packages/ai-parrot/src/parrot/bots/agent.py
as_tool ¶
as_tool(tool_name: str = None, tool_description: str = None, use_conversation_method: bool = True, context_filter: Optional[Callable[[AgentContext], AgentContext]] = None) -> AgentTool
Convert this agent into an AgentTool that can be used by other agents.
This allows agents to be composed and used as tools in orchestration scenarios.
| PARAMETER | DESCRIPTION |
|---|---|
tool_name
|
Custom name for the tool (defaults to agent name)
TYPE:
|
tool_description
|
Description of what this agent does
TYPE:
|
use_conversation_method
|
Whether to use conversation() or invoke()
TYPE:
|
context_filter
|
Optional function to filter context before execution
TYPE:
|
question_description
|
Custom description for the query parameter
|
context_description
|
Custom description for the context parameter
|
| RETURNS | DESCRIPTION |
|---|---|
AgentTool
|
Tool wrapper for this agent
TYPE:
|
Example
hr_agent = BasicAgent(name="HRAgent", ...) hr_tool = hr_agent.as_tool( ... tool_description="Handles HR policy questions" ... ) orchestrator.tool_manager.add_tool(hr_tool)
Source code in packages/ai-parrot/src/parrot/bots/agent.py
register_as_tool ¶
register_as_tool(target_agent: BasicAgent, tool_name: str = None, tool_description: str = None, **kwargs) -> None
Register this agent as a tool in another agent's tool manager.
This is a convenience method that combines as_tool() and registration.
| PARAMETER | DESCRIPTION |
|---|---|
target_agent
|
The agent to register this tool with
TYPE:
|
tool_name
|
Custom name for the tool
TYPE:
|
tool_description
|
Description of what this agent does
TYPE:
|
**kwargs
|
Additional arguments for as_tool()
DEFAULT:
|
Example
hr_agent = BasicAgent(name="HRAgent", ...) employee_agent = BasicAgent(name="EmployeeAgent", ...) orchestrator = OrchestratorAgent(name="Orchestrator")
hr_agent.register_as_tool( ... orchestrator, ... tool_description="Handles HR policies and procedures" ... ) employee_agent.register_as_tool( ... orchestrator, ... tool_description="Manages employee data" ... )
Source code in packages/ai-parrot/src/parrot/bots/agent.py
add_dataframe ¶
Add a dataframe to the agent and configure PythonPandasTool.
| PARAMETER | DESCRIPTION |
|---|---|
df
|
pandas DataFrame to add
|
name
|
Optional name for the dataframe. If None, uses df{index}
TYPE:
|
Source code in packages/ai-parrot/src/parrot/bots/agent.py
remove_dataframe ¶
Remove a dataframe by name.
Source code in packages/ai-parrot/src/parrot/bots/agent.py
followup
async
¶
followup(question: str, turn_id: str, data: Any, session_id: Optional[str] = None, user_id: Optional[str] = None, use_conversation_history: bool = True, memory: Optional[Any] = None, ctx: Optional[Any] = None, structured_output: Optional[Any] = None, output_mode: Any = None, format_kwargs: dict = None, return_structured: bool = True, **kwargs) -> AIMessage
Generate a follow-up question using a previous turn as context.
Source code in packages/ai-parrot/src/parrot/bots/agent.py
1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 | |
WebSearchAgent ¶
WebSearchAgent(name: str = 'WebSearchAgent', agent_id: str = 'web_search_agent', use_llm: str = 'google', llm: str = 'google:gemini-3-flash', tools: Optional[List[Any]] = None, use_builtin_search: bool = False, contrastive_search: bool = False, contrastive_prompt: Optional[str] = None, synthesize: bool = False, synthesize_prompt: Optional[str] = None, competitor_search: bool = False, competitor_prompt: Optional[str] = None, **kwargs)
Bases: BasicAgent
An agent specialized in performing web searches.
By default, it is equipped with several search tools: - GoogleSearchTool - GoogleSiteSearchTool - DdgSearchTool - BingSearchTool - SerpApiSearchTool
If use_builtin_search is True, it will fallback to using
Gemini's built-in Google Search functionality via tool_type='builtin_tools'.
If contrastive_search is True, performs a two-step search:
first the original query, then a contrastive analysis of
competitors/alternatives based on the initial results.
If synthesize is True, an additional LLM call (with use_tools=False)
analyzes and synthesizes the search results using a synthesis prompt.
Initialize the WebSearchAgent.
Source code in packages/ai-parrot/src/parrot/bots/search.py
ask
async
¶
Override ask to support contrastive search and synthesis.
Flow: 1. If contrastive_search is False: normal search via _do_search. If True: two-step search (initial + contrastive analysis). 2. If synthesize is True: additional LLM call (no tools) to synthesize the results.