Skip to content

A MVP implementation of an LLM agent that can call tools

License

Notifications You must be signed in to change notification settings

gvisona/python-ai-agent

Repository files navigation

Python AI Agent

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.

Prerequesites

Create a .env file that contains a variable for ANTHROPIC_API_KEY, which you need to obtain from the Anthropic website.

Simple chat

Run

uv run simple_chat.py

to start an interactive session with a Claude model.

Chat with manual tool implementation

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?

Chat with tool calling

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.

About

A MVP implementation of an LLM agent that can call tools

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages