From 561295af76d56de2837f33efa4b436b8892de61c Mon Sep 17 00:00:00 2001 From: Kevin Cogan <44865890+kevincogan@users.noreply.github.com> Date: Thu, 20 Feb 2025 21:52:14 +0000 Subject: [PATCH] docs: Fix Links, Add Podman Instructions, Vector DB Unregister, and Example Script (#1129) # What does this PR do? This PR improves the documentation in several ways: - **Fixed incorrect link in `tools.md`** to ensure all references point to the correct resources. - **Added instructions for running the `code-interpreter` agent in a Podman container**, helping users configure and execute the tool in containerized environments. - **Introduced an unregister command for single and multiple vector databases**, making it easier to manage vector DBs. - **Provided a simple example script for using the `code-interpreter` agent**, giving users a practical reference for implementation. These updates enhance the clarity, usability, and completeness of the documentation. [//]: # (If resolving an issue, uncomment and update the line below) [//]: # (Closes #[issue-number]) ## Test Plan The following steps were performed to verify the accuracy of the changes: 1. **Validated all fixed link** by checking their destinations to ensure correctness. 2. **Ran the `code-interpreter` agent in a Podman container** following the new instructions to confirm functionality. 3. **Executed the vector database unregister commands** and verified that both single and multiple databases were correctly removed. 4. **Tested the new example script for `code-interpreter`**, ensuring it runs without errors. All changes were reviewed and tested successfully, improving the documentation's accuracy and ease of use. [//]: # (## Documentation) --- docs/source/building_applications/rag.md | 17 +++++++++ docs/source/building_applications/tools.md | 40 +++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/docs/source/building_applications/rag.md b/docs/source/building_applications/rag.md index 5287a2367..e6d628193 100644 --- a/docs/source/building_applications/rag.md +++ b/docs/source/building_applications/rag.md @@ -122,3 +122,20 @@ response = agent.create_turn( session_id=session_id, ) ``` + +### Unregistering Vector DBs + +If you need to clean up and unregister vector databases, you can do so as follows: + +```python +# Unregister a specified vector database +vector_db_id = "my_vector_db_id" +print(f"Unregistering vector database: {vector_db_id}") +client.vector_dbs.unregister(vector_db_id=vector_db_id) + + +# Unregister all vector databases +for vector_db_id in client.vector_dbs.list(): + print(f"Unregistering vector database: {vector_db_id.identifier}") + client.vector_dbs.unregister(vector_db_id=vector_db_id.identifier) +``` diff --git a/docs/source/building_applications/tools.md b/docs/source/building_applications/tools.md index c0f6230db..323374673 100644 --- a/docs/source/building_applications/tools.md +++ b/docs/source/building_applications/tools.md @@ -60,6 +60,11 @@ Features: - Disabled dangerous system operations - Configurable execution timeouts +> ⚠️ Important: The code interpreter tool can operate in a controlled enviroment locally or on Podman containers. To ensure proper functionality in containerised environments: +> - The container requires privileged access (e.g., --privileged). +> - Users without sufficient permissions may encounter permission errors. (`bwrap: Can't mount devpts on /newroot/dev/pts: Permission denied`) +> - 🔒 Security Warning: Privileged mode grants elevated access and bypasses security restrictions. Use only in local, isolated, or controlled environments. + #### WolframAlpha The WolframAlpha tool provides access to computational knowledge through the WolframAlpha API. @@ -103,7 +108,7 @@ Features: MCP tools are special tools that can interact with llama stack over model context protocol. These tools are dynamically discovered from an MCP endpoint and can be used to extend the agent's capabilities. -Refer to https://github.com/modelcontextprotocol/server for available MCP servers. +Refer to [https://github.com/modelcontextprotocol/servers](https://github.com/modelcontextprotocol/servers) for available MCP servers. ```python # Register MCP tools @@ -191,3 +196,36 @@ all_tools = client.tools.list_tools() # List tools in a specific group group_tools = client.tools.list_tools(toolgroup_id="search_tools") ``` + +## Simple Example: Using an Agent with the Code-Interpreter Tool + +```python +from llama_stack_client.lib.agents.agent import Agent +from llama_stack_client.types.agent_create_params import AgentConfig + +# Configure the AI agent with necessary parameters +agent_config = AgentConfig( + name="code-interpreter", + description="A code interpreter agent for executing Python code snippets", + instructions=""" + You are a highly reliable, concise, and precise assistant. + Always show the generated code, never generate your own code, and never anticipate results. + """, + model="meta-llama/Llama-3.2-3B-Instruct", + toolgroups=["builtin::code_interpreter"], + max_infer_iters=5, + enable_session_persistence=False, +) + +# Instantiate the AI agent with the given configuration +agent = Agent(client, agent_config) + +# Start a session +session_id = agent.create_session("tool_session") + +# Send a query to the AI agent for code execution +response = agent.create_turn( + messages=[{"role": "user", "content": "Run this code: print(3 ** 4 - 5 * 2)"}], + session_id=session_id, +) +```