This repository implements a proof of concept for implementing a chat script with Anthropic Claude Sonnet 3.7, to demonstrate the implementation of tool usage in LLMs.
A more detailed description is available in the blogpost LINK.
Create a .env file that contains a variable for ANTHROPIC_API_KEY, which you need to obtain from the Anthropic website.
Run
uv run simple_chat.py
to start an interactive session with a Claude model.
The script that can be started with
uv run chat_with_manual_tool_implementation.py
demonstrates the basic logic of tool calling in LLMs. In this case, we have to explicitly prime the model to "call" the tool in the right situation, with a prompt like:
When, in future messages, I ask you to check if Google DNS is available, you will respond only with the text `ping_address("8.8.8.8")`. All other queries should be answered normally. Can you do that?
The script for chatting with tools passed to Claude is run with
uv run chat_with_tools.py
In this case, a more flexible prompt (e.g. Is the Google DNS at the IP address 8.8.8.8 available?) will lead the model to automatically determine that it should call the given tool.