Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove special handling of builtin::rag tool #1015

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

ehhuang
Copy link
Contributor

@ehhuang ehhuang commented Feb 8, 2025

Summary:

Lets the model decide which tool it needs to call to respond to a query.

Test Plan:

LLAMA_STACK_CONFIG=fireworks pytest -s -v tests/client-sdk/ --safety-shield meta-llama/Llama-Guard-3-8B

Stack created with Sapling. Best reviewed with ReviewStack.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Feb 8, 2025
@ehhuang ehhuang changed the title memory feat: remove special handling of builtin::rag tool Feb 8, 2025
@ehhuang ehhuang changed the title feat: remove special handling of builtin::rag tool [RFC] feat: remove special handling of builtin::rag tool Feb 8, 2025
@ehhuang ehhuang changed the title [RFC] feat: remove special handling of builtin::rag tool memory Feb 8, 2025
@ehhuang ehhuang changed the title memory [RFC] feat: remove special handling of builtin::rag tool Feb 8, 2025
@ehhuang ehhuang force-pushed the pr1014 branch 3 times, most recently from 17c3d05 to 01cc4c0 Compare February 11, 2025 07:16
@ehhuang ehhuang changed the title [RFC] feat: remove special handling of builtin::rag tool feat: remove special handling of builtin::rag tool Feb 11, 2025
@ehhuang ehhuang marked this pull request as ready for review February 11, 2025 07:25
@@ -466,5 +503,8 @@ def test_rag_and_code_agent(llama_stack_client, agent_config):
documents=docs,
)
logs = [str(log) for log in EventLogger().log(response) if log is not None]
logs_str = "".join(logs)
logs_str = "\n".join(logs)
print(logs_str)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?

@@ -381,92 +379,6 @@ async def _run(
if documents:
await self.handle_documents(session_id, documents, input_messages, tool_defs)

if RAG_TOOL_GROUP in toolgroups and len(input_messages) > 0:
Copy link
Contributor

@yanxi0830 yanxi0830 Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering what happens if we explicitly specify the builtin::rag toolgroups now?

https://github.com/meta-llama/llama-stack-apps/blob/7119ea1d4064ab774f10bb6c0f292bc517cb49b7/examples/agents/rag_with_vector_db.py#L83-L88

I'm wondering if there's a way we can specify how to force retrieve v.s. retrieve based on model tool call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a knowledge_search tool being exposed (see list_runtime_tools). The model chooses which tools to call among all the tools. The user can include in instructions that they would like certain tools called. The tool_choice option will also support this, coming next.

tools=[
tool for tool in tool_defs.values() if tool_to_group.get(tool.tool_name, None) != RAG_TOOL_GROUP
],
tools=[tool for tool in tool_defs.values()],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For builtin tools we do not have a description in the system prompt besides

Environment: ipython
Tools: brave_search, wolfram_alpha

for all other tools , we have a prompt saying here is the tool and the description of when to use it.
Now, we are neither explicitly calling the tool (sine this was never a builtin tool that the model was trained with) nor does the model know when to invoke this since its not in the client tools for which we include descriptions.

Thus, its not clear how this will get invoked if at all. Can you test our RAG examples to see if this works ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the client_sdk tests do have rag in multiple tests and it seems like they passed ? So what am i missing here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea by removing this logic to remove RAG_TOOL_GROUP before, we actually are passing the rag tool to model now, with descriptions. So the model does call it. And you're right the client_tests do test it.

@hardikjshah
Copy link
Contributor

Also reminder - we will need to update getting_started and other places where we have RAG agent.

Copy link
Contributor

@hardikjshah hardikjshah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we update the tests to not hard code but manage other models properly please ?

Summary:

Test Plan:
Summary:

Test Plan:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants