From 57061ba9268d5b123a70f7b32df4807805565144 Mon Sep 17 00:00:00 2001 From: Aymeric Date: Mon, 6 Jan 2025 14:18:56 +0100 Subject: [PATCH] Add system prompt modification in building_good_agents --- .../en/tutorials/building_good_agents.md | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/source/en/tutorials/building_good_agents.md b/docs/source/en/tutorials/building_good_agents.md index cd97b3c..b3a4e6c 100644 --- a/docs/source/en/tutorials/building_good_agents.md +++ b/docs/source/en/tutorials/building_good_agents.md @@ -168,7 +168,7 @@ Final answer: /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. -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. 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. - 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 @@ -203,7 +219,7 @@ from dotenv import load_dotenv load_dotenv() # 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()