Pretty print output
This commit is contained in:
		
							parent
							
								
									f43293819f
								
							
						
					
					
						commit
						86bd32a9e6
					
				| @ -1,3 +1,4 @@ | ||||
| import json # Import the json module | ||||
| from qwen_agent.agents import Assistant | ||||
| 
 | ||||
| # Define LLM | ||||
| @ -40,7 +41,15 @@ tools = [ | ||||
| bot = Assistant(llm=llm_cfg, function_list=tools) | ||||
| 
 | ||||
| # Streaming generation | ||||
| messages = [{'role': 'user', 'content': 'https://qwenlm.github.io/blog/ Introduce the latest developments of Qwen'}] | ||||
| messages = [{'role': 'user', 'content': 'https://qwenlm.github.io/blog/ Sumarize the latest developments of Qwen'}] | ||||
| # Initialize responses variable before the loop in case the loop doesn't run | ||||
| final_responses = None  | ||||
| for responses in bot.run(messages=messages): | ||||
|     pass | ||||
| print(responses) | ||||
|     # The loop assigns the latest response to final_responses | ||||
|     final_responses = responses  | ||||
| 
 | ||||
| # Pretty-print the final response object | ||||
| if final_responses: | ||||
|     print(json.dumps(final_responses, indent=2)) # Use indent=2 (or 4) for pretty printing | ||||
| else: | ||||
|     print("No response received from the agent.") | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user