diff --git a/README.md b/README.md index 61778d2..740590c 100644 --- a/README.md +++ b/README.md @@ -25,10 +25,10 @@ limitations under the License.
🤗 Smolagents - a smol library to build great agents!
+🤗 `smolagents` - a smol library to build great agents!
-Smolagents is a library that enables you to run powerful agents in a few lines of code. It offers: +`smolagents` is a library that enables you to run powerful agents in a few lines of code. It offers: ✨ **Simplicity**: the logic for agents fits in ~thousand lines of code. We kept abstractions to their minimal shape above raw code! @@ -58,7 +58,7 @@ https://github.com/user-attachments/assets/cd0226e2-7479-4102-aea0-57c22ca47884 ## Code agents? We built agents where the LLM engine writes its actions in code. This approach is demonstrated to work better than the current industry practice of letting the LLM output a dictionary of the tools it wants to calls: [uses 30% fewer steps](https://huggingface.co/papers/2402.01030) (thus 30% fewer LLM calls) -and [reaches higher performance on difficult benchmarks](https://huggingface.co/papers/2411.01747). Head to [./conceptual_guides/intro_agents.md] to learn more on that. +and [reaches higher performance on difficult benchmarks](https://huggingface.co/papers/2411.01747). Head to [https://huggingface.co/docs/smolagents/conceptual_guides/intro_agents] to learn more on that. Especially, since code execution can be a security concern (arbitrary code execution!), we provide options at runtime: - a secure python interpreter to run code more safely in your environment @@ -76,7 +76,7 @@ If you use `smolagents` in your publication, please cite it by using the followi ```bibtex @Misc{accelerate, - title = {Smolagents: The easiest way to build efficient agentic systems.}, + title = {`smolagents`: The easiest way to build efficient agentic systems.}, author = {Aymeric Roucher and Thomas Wolf and Leandro von Werra and Erik Kaunismäki}, howpublished = {\url{https://github.com/huggingface/smolagents}}, year = {2024} diff --git a/docs/source/conceptual_guides/intro_agents.md b/docs/source/conceptual_guides/intro_agents.md index 0a1434f..45f3437 100644 --- a/docs/source/conceptual_guides/intro_agents.md +++ b/docs/source/conceptual_guides/intro_agents.md @@ -78,7 +78,7 @@ Actually, most real-life tasks do not fit in a pre-determined workflow. This is Agentic systems are a great way to introduce the vast world of real-world tasks to programs! -### Why Smolagents? +### Why `smolagents`? For some low-level agentic use cases, like chains or routers, you can write all the code yourself. You'll be much better that way, since it will let you control and understand your system better. diff --git a/docs/source/examples/rag.md b/docs/source/examples/rag.md index 01af785..80c03af 100644 --- a/docs/source/examples/rag.md +++ b/docs/source/examples/rag.md @@ -37,12 +37,11 @@ Run the line below to install required dependencies: ```bash !pip install smolagents pandas langchain langchain-community sentence-transformers faiss-cpu --upgrade -q ``` -Let's login in order to call the HF Inference API: - +To call the HF Inference API, you will need a valid token as your environment variable `HF_TOKEN`. +We use python-dotenv to load it. ```py -from huggingface_hub import login - -login() +from python_dotenv import load_dotenv +load_dotenv() ``` We first load a knowledge base on which we want to perform RAG: this dataset is a compilation of the documentation pages for many Hugging Face libraries, stored as markdown. We will keep only the documentation for the `transformers` library. diff --git a/docs/source/index.md b/docs/source/index.md index f9e7948..7392cfc 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -13,7 +13,7 @@ specific language governing permissions and limitations under the License. rendered properly in your Markdown viewer. --> -# Smolagents +# `smolagents` This library is the simplest framework out there to build powerful agents! By the way, wtf are "agents"? We provide our definition [in this page](conceptual_guides/intro_agents), whe're you'll also find tips for when to use them or not (spoilers: you'll often be better off without agents). diff --git a/pyproject.toml b/pyproject.toml index d5cc407..6c2d7f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "smolagents" version = "0.0.1" -description = "🤗 Smolagents: a barebones library for agents. Agents just write python code to call/orchestrate tools." +description = "🤗 `smolagents`: a barebones library for agents. Agents just write python code to call/orchestrate tools." authors = [ { name="Aymeric Roucher", email="aymeric@hf.co" }, { name="Thomas Wolf"}, ] diff --git a/tests/test_agents.py b/tests/test_agents.py index cdb7fc1..9bb2ab5 100644 --- a/tests/test_agents.py +++ b/tests/test_agents.py @@ -184,7 +184,7 @@ class AgentTests(unittest.TestCase): ) output = agent.run("What is 2 multiplied by 3.6452?", single_step=True) assert isinstance(output, str) - assert output == "7.2904" + assert "7.2904" in output def test_fake_toolcalling_agent(self): agent = ToolCallingAgent( @@ -192,9 +192,9 @@ class AgentTests(unittest.TestCase): ) output = agent.run("What is 2 multiplied by 3.6452?") assert isinstance(output, str) - assert output == "7.2904" + assert "7.2904" in output assert agent.logs[1].task == "What is 2 multiplied by 3.6452?" - assert agent.logs[2].observations == "7.2904" + assert "7.2904" in agent.logs[2].observations assert agent.logs[3].llm_output is None def test_toolcalling_agent_handles_image_tool_outputs(self): @@ -229,7 +229,8 @@ class AgentTests(unittest.TestCase): def test_additional_args_added_to_task(self): agent = CodeAgent(tools=[], model=fake_code_model) agent.run( - "What is 2 multiplied by 3.6452?", additional_instruction="Remember this." + "What is 2 multiplied by 3.6452?", + additional_args={"instruction": "Remember this."}, ) assert "Remember this" in agent.task assert "Remember this" in str(agent.input_messages)