import asyncio import sys import io # 设置 stdout 编码为 UTF-8 sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') sys.path.insert(0, '.') async def test(): from agent.tools.builtin.search import search_posts print("Testing search_posts with gzh channel...") result = await search_posts(keyword='Midjourney v8', channel='gzh', max_count=20) print(f'Title: {result.title}') print(f'Has error: {result.error is not None}') if result.error: print(f'Error message: {result.error}') else: print(f'Output length: {len(result.output)} chars') print(f'Has images: {len(result.images) > 0}') if __name__ == '__main__': asyncio.run(test())