Spaces:
Runtime error
Runtime error
Introdduce a default callback mechanism
Browse files
app.py
CHANGED
|
@@ -57,6 +57,7 @@ from pydantic import BaseModel
|
|
| 57 |
from strands import Agent
|
| 58 |
from strands.agent.conversation_manager import SlidingWindowConversationManager
|
| 59 |
from strands.models.openai import OpenAIModel
|
|
|
|
| 60 |
|
| 61 |
# Import confluence-ingestor
|
| 62 |
from confluence_ingestor import ConfluenceRAG
|
|
@@ -397,7 +398,14 @@ def create_enhanced_agent():
|
|
| 397 |
should_truncate_results=True, # Enable truncating the tool result when a message is too large for the model's context window
|
| 398 |
)
|
| 399 |
|
| 400 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 401 |
else:
|
| 402 |
# Create a conversation manager with custom window size
|
| 403 |
conversation_manager = SlidingWindowConversationManager(
|
|
@@ -405,7 +413,13 @@ def create_enhanced_agent():
|
|
| 405 |
should_truncate_results=True, # Enable truncating the tool result when a message is too large for the model's context window
|
| 406 |
)
|
| 407 |
|
| 408 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 409 |
|
| 410 |
return _cached_agent
|
| 411 |
|
|
|
|
| 57 |
from strands import Agent
|
| 58 |
from strands.agent.conversation_manager import SlidingWindowConversationManager
|
| 59 |
from strands.models.openai import OpenAIModel
|
| 60 |
+
from strands.handlers.callback_handler import PrintingCallbackHandler
|
| 61 |
|
| 62 |
# Import confluence-ingestor
|
| 63 |
from confluence_ingestor import ConfluenceRAG
|
|
|
|
| 398 |
should_truncate_results=True, # Enable truncating the tool result when a message is too large for the model's context window
|
| 399 |
)
|
| 400 |
|
| 401 |
+
# The default callback handler prints text and shows tool usage
|
| 402 |
+
_cached_agent = Agent(
|
| 403 |
+
model=model,
|
| 404 |
+
system_prompt=system_prompt,
|
| 405 |
+
tools=tools,
|
| 406 |
+
conversation_manager=conversation_manager,
|
| 407 |
+
callback_handler=PrintingCallbackHandler()
|
| 408 |
+
)
|
| 409 |
else:
|
| 410 |
# Create a conversation manager with custom window size
|
| 411 |
conversation_manager = SlidingWindowConversationManager(
|
|
|
|
| 413 |
should_truncate_results=True, # Enable truncating the tool result when a message is too large for the model's context window
|
| 414 |
)
|
| 415 |
|
| 416 |
+
# The default callback handler prints text and shows tool usage
|
| 417 |
+
_cached_agent = Agent(
|
| 418 |
+
system_prompt=system_prompt,
|
| 419 |
+
tools=tools,
|
| 420 |
+
conversation_manager=conversation_manager,
|
| 421 |
+
callback_handler=PrintingCallbackHandler()
|
| 422 |
+
)
|
| 423 |
|
| 424 |
return _cached_agent
|
| 425 |
|