ArticleAgent is a specialized agent for writing articles and long-form content. It extends the Assistant agent with capabilities for both creating new articles from scratch and continuing existing content based on reference materials.
from qwen_agent.agents.article_agent import ArticleAgentagent = ArticleAgent( llm={'model': 'qwen-max-latest', 'model_type': 'qwen_dashscope'})existing_content = """# Introduction to Neural NetworksNeural networks are computational models inspired by the human brain..."""messages = [{ 'role': 'user', 'content': f'Continue this article:\n\n{existing_content}\n\nAdd a section about training neural networks.'}]for response in agent.run(messages=messages, lang='en', full_article=False): print(response[-1]['content'])
from qwen_agent.agents.article_agent import ArticleAgent# Load reference documentsagent = ArticleAgent( llm={'model': 'qwen-max-latest', 'model_type': 'qwen_dashscope'}, files=[ './research_paper1.pdf', './research_paper2.pdf', './dataset_documentation.pdf' ], rag_cfg={ 'lang': 'en', 'max_ref_token': 8000, # More context for research 'search_method': 'hybrid' }, system_message='You are a research writer. Cite sources when using information.')messages = [{ 'role': 'user', 'content': 'Write an article summarizing the key findings from the research papers'}]for response in agent.run(messages=messages, lang='en', full_article=True): content = response[-1]['content'] if 'Search for relevant information' in content: print('Researching references...') else: print(content)
agent = ArticleAgent( llm={'model': 'qwen-max-latest', 'model_type': 'qwen_dashscope'}, system_message=""" You are a technical writer specializing in developer documentation. Guidelines: - Use clear, concise language - Include code examples where appropriate - Structure content with headers and sections - Use bullet points for lists - Explain technical concepts simply """)
agent = ArticleAgent( llm={'model': 'qwen-max-latest', 'model_type': 'qwen_dashscope'}, function_list=['code_interpreter'], # For code examples system_message='You are a developer advocate writing technical blog posts.')messages = [{ 'role': 'user', 'content': 'Write a blog post about async/await in Python with code examples'}]for response in agent.run(messages=messages, full_article=True): print(response[-1]['content'])