TOOL USE ( FUNCTION CALLING) 🔥🔥 With Anthropic CLAUDE 3 API – A Step by Step Tutorial

Опубликовано: 12 Ноябрь 2024
на канале: Rithesh Sreenivasan
812
15

#ANTHROPIC #LLM #claude3
If you like to support me financially, It is totally optional and voluntary. Buy me a coffee here: https://www.buymeacoffee.com/rithesh
Anthropic Claude is capable of interacting with external client-side tools and functions, allowing you to equip Claude with your own custom tools to perform a wider variety of tasks.
Using tools with Claude involves the following steps:

Provide Claude with tools and a user prompt: (API request)

Define the set of tools you want Claude to have access to, including their names, descriptions, and input schemas.
Provide a user prompt that may require the use of one or more of these tools to answer, such as "What is the weather in San Francisco?".
Claude uses a tool: (API response)

Claude assesses the user prompt and decides whether any of the available tools would help with the user's query or task. If so, it also decides which tool(s) to use and with what inputs.
Claude constructs a properly formatted tool use request.
The API response will have a stop_reason of tool_use, indicating that Claude wants to use an external tool.
Extract tool input, run code, and return results: (API request)

On the client side, you should extract the tool name and input from Claude's tool use request.
Run the actual tool code on the client side.
Return the results to Claude by continuing the conversation with a new user message containing a tool_result content block.
Claude uses tool result to formulate a response: (API response)

After receiving the tool results, Claude will use that information to formulate its final response to the original user prompt.
Steps (3) and (4) are optional — for some workflows, Claude using the tool is all the information you need, and you might not need to return tool results back to Claude.
https://docs.anthropic.com/claude/doc...
https://github.com/anthropics/anthrop...
https://betterprogramming.pub/the-nex...

If you like such content please subscribe to the channel here:
https://www.youtube.com/c/RitheshSree...