Skip to content

In rag tutorial part 2, how can graph_builder decide whether to call tool or not ? #30243

Answered by PragyanTiwari
astrung asked this question in Q&A
Discussion options

You must be logged in to vote

Let me help you🐣...

Starting with the query_or_respond node that includes the function query_or_respond. This function generates an AIMessage, which is created by your llm and contains a tool call dict having the tool_name, id, and args. The tool name and ID indicate the specific tool the model intends to use.

You provide a list of such tools to the llm by binding them to the llm. Here is an example:

llm_with_tools = llm.bind_tools([retrieve])  # here, the retrieve tool is added to the llm

And how does the llm decide whether to use a particular tool or not❓
Well 🎈, If you've observed the code while defining the retrieve tool, that is:

@tool(response_format="content_and_artifact")
def ret…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@astrung
Comment options

Answer selected by astrung
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants