ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
# coding: utf-8
|
||||
# Copyright (c) 2025 inclusionAI.
|
||||
|
||||
"""
|
||||
Callback function registration module, used for centralized management and registration of all callback functions.
|
||||
"""
|
||||
|
||||
from aworld.runners.callback.decorator import reg_callback, CallbackRegistry
|
||||
|
||||
|
||||
# Register a simple callback function
|
||||
@reg_callback("print_content")
|
||||
def simple_callback(content):
|
||||
"""Simple callback function that prints content and returns it
|
||||
|
||||
Args:
|
||||
content: Content to print
|
||||
|
||||
Returns:
|
||||
The input content
|
||||
"""
|
||||
print(f"Callback function received content: {content}")
|
||||
return content
|
||||
|
||||
|
||||
# You can register more callback functions here
|
||||
@reg_callback("uppercase_content")
|
||||
def uppercase_callback(content):
|
||||
"""Callback function that converts content to uppercase
|
||||
|
||||
Args:
|
||||
content: Content to process
|
||||
|
||||
Returns:
|
||||
Content converted to uppercase
|
||||
"""
|
||||
if isinstance(content, str):
|
||||
result = content.upper()
|
||||
print(f"Callback function converted content to uppercase: {result}")
|
||||
return result
|
||||
return content
|
||||
|
||||
|
||||
# Provide a function to check all registered callback functions
|
||||
def list_all_callbacks():
|
||||
"""List all registered callback functions"""
|
||||
callbacks = CallbackRegistry.list()
|
||||
print("Registered callback functions:")
|
||||
for key, func_name in callbacks.items():
|
||||
print(f" - {key}: {func_name}")
|
||||
return callbacks
|
||||
Reference in New Issue
Block a user