Add system prompt modification in building_good_agents
This commit is contained in:
		
							parent
							
								
									4cfe4a6573
								
							
						
					
					
						commit
						57061ba926
					
				|  | @ -168,7 +168,7 @@ Final answer: | ||||||
| /var/folders/6m/9b1tts6d5w960j80wbw9tx3m0000gn/T/tmpx09qfsdd/652f0007-3ee9-44e2-94ac-90dae6bb89a4.png | /var/folders/6m/9b1tts6d5w960j80wbw9tx3m0000gn/T/tmpx09qfsdd/652f0007-3ee9-44e2-94ac-90dae6bb89a4.png | ||||||
| ``` | ``` | ||||||
| The user sees, instead of an image being returned, a path being returned to them. | The user sees, instead of an image being returned, a path being returned to them. | ||||||
| It could look like a bug from the system, but actually the agentic system didn't cause the error: it's just that the LLM engine did the mistake of not saving the image output into a variable. | It could look like a bug from the system, but actually the agentic system didn't cause the error: it's just that the LLM brain did the mistake of not saving the image output into a variable. | ||||||
| Thus it cannot access the image again except by leveraging the path that was logged while saving the image, so it returns the path instead of an image. | Thus it cannot access the image again except by leveraging the path that was logged while saving the image, so it returns the path instead of an image. | ||||||
| 
 | 
 | ||||||
| The first step to debugging your agent is thus "Use a more powerful LLM". Alternatives like `Qwen2/5-72B-Instruct` wouldn't have made that mistake. | The first step to debugging your agent is thus "Use a more powerful LLM". Alternatives like `Qwen2/5-72B-Instruct` wouldn't have made that mistake. | ||||||
|  | @ -191,6 +191,22 @@ If after trying the above, you still want to change the system prompt, your new | ||||||
| - `"{{managed_agents_description}}"` to insert the description for managed agents if there are any. | - `"{{managed_agents_description}}"` to insert the description for managed agents if there are any. | ||||||
| - For `CodeAgent` only: `"{{authorized_imports}}"` to insert the list of authorized imports. | - For `CodeAgent` only: `"{{authorized_imports}}"` to insert the list of authorized imports. | ||||||
| 
 | 
 | ||||||
|  | Then you can change the system prompt as follows: | ||||||
|  | 
 | ||||||
|  | ```py | ||||||
|  | from smolagents.prompts import CODE_SYSTEM_PROMPT, HfApiModel | ||||||
|  | 
 | ||||||
|  | modified_system_prompt = CODE_SYSTEM_PROMPT + "\nHere you go!" # Change the system prompt here | ||||||
|  | 
 | ||||||
|  | agent = CodeAgent( | ||||||
|  |     tools=[],  | ||||||
|  |     model=HfApiModel(),  | ||||||
|  |     system_prompt=modified_system_prompt | ||||||
|  | ) | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | This also works with the ToolCallingAgent. | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| ### 3. Extra planning | ### 3. Extra planning | ||||||
| 
 | 
 | ||||||
|  | @ -203,7 +219,7 @@ from dotenv import load_dotenv | ||||||
| load_dotenv() | load_dotenv() | ||||||
| 
 | 
 | ||||||
| # Import tool from Hub | # Import tool from Hub | ||||||
| image_generation_tool = load_tool("m-ric/text-to-image", cache=False) | image_generation_tool = load_tool("m-ric/text-to-image", trust_remote_code=True) | ||||||
| 
 | 
 | ||||||
| search_tool = DuckDuckGoSearchTool() | search_tool = DuckDuckGoSearchTool() | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue