{"id":20466046,"url":"https://github.com/rizerphe/anthropic-tools","last_synced_at":"2025-07-04T18:07:07.773Z","repository":{"id":235269587,"uuid":"790441890","full_name":"rizerphe/anthropic-tools","owner":"rizerphe","description":"Generate Anthropic Claude tool use schemas based on type annotations and function docstrings.","archived":false,"fork":false,"pushed_at":"2024-04-25T14:16:55.000Z","size":97,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T09:18:54.785Z","etag":null,"topics":["anthropic","claude-3-haiku","claude-3-opus","claude-3-sonnet","claude-ai","claude-api","claude3","llm-tools","nlp","python","python-library"],"latest_commit_sha":null,"homepage":"https://anthropic-tools.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rizerphe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-22T22:11:53.000Z","updated_at":"2025-01-19T20:46:12.000Z","dependencies_parsed_at":"2024-11-15T13:32:29.972Z","dependency_job_id":null,"html_url":"https://github.com/rizerphe/anthropic-tools","commit_stats":null,"previous_names":["rizerphe/anthropic-tools"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizerphe%2Fanthropic-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizerphe%2Fanthropic-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizerphe%2Fanthropic-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizerphe%2Fanthropic-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rizerphe","download_url":"https://codeload.github.com/rizerphe/anthropic-tools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248688544,"owners_count":21145763,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anthropic","claude-3-haiku","claude-3-opus","claude-3-sonnet","claude-ai","claude-api","claude3","llm-tools","nlp","python","python-library"],"created_at":"2024-11-15T13:21:17.219Z","updated_at":"2025-04-13T08:55:32.578Z","avatar_url":"https://github.com/rizerphe.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Anthropic tools\n\nThe `anthropic-tools` library simplifies the usage of Anthropics’s [tool use](https://docs.anthropic.com/claude/docs/tool-use) feature. It abstracts away the complexity of parsing function signatures and docstrings by providing developers with a clean and intuitive interface. It's a near-clone of my [openai-functions](https://openai-functions.readthedocs.io) library that does the same with OpenAI.\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![PyPI version](https://badge.fury.io/py/anthropic-tools.svg)](https://badge.fury.io/py/anthropic-tools) [![Documentation Status](https://readthedocs.org/projects/anthropic-tools/badge/?version=latest)](https://anthropic-tools.readthedocs.io/en/latest/?badge=latest)\n\n## Installation\n\nYou can install `anthropic-tools` from PyPI using pip:\n\n```\npip install anthropic-tools\n```\n\n## Usage\n\n1. Import the necessary modules and provide your API key:\n\n```python\nimport enum\nimport anthropic\nfrom anthropic_tools import Conversation\n\nclient = anthropic.Anthropic(\n    api_key=\"\u003cYOUR_API_KEY\u003e\",\n)\n```\n\n2. Create a `Conversation` instance:\n\n```python\nconversation = Conversation(client)\n```\n\n3. Define your tools using the `@conversation.add_tool` decorator:\n\n```python\nclass Unit(enum.Enum):\n    FAHRENHEIT = \"fahrenheit\"\n    CELSIUS = \"celsius\"\n\n@conversation.add_tool()\ndef get_current_weather(location: str, unit: Unit = Unit.FAHRENHEIT) -\u003e dict:\n    \"\"\"Get the current weather in a given location.\n\n    Args:\n        location (str): The city and state, e.g., San Francisco, CA\n        unit (Unit): The unit to use, e.g., fahrenheit or celsius\n    \"\"\"\n    return {\n        \"location\": location,\n        \"temperature\": \"72\",\n        \"unit\": unit.value,\n        \"forecast\": [\"sunny\", \"windy\"],\n    }\n```\n\n4. Ask the AI a question:\n\n```python\nresponse = conversation.ask(\"What's the weather in San Francisco?\")\n# Should return three messages, the last one's content being something like:\n# The current weather in San Francisco is 72 degrees Fahrenheit and it is sunny and windy.\n```\n\nYou can read more about how to use `Conversation` [here](https://anthropic-tools.readthedocs.io/en/latest/conversation.html).\n\n## More barebones use - just schema generation and result parsing:\n\n```python\nfrom anthropic_tools import ToolWrapper\n\nwrapper = ToolWrapper(get_current_weather)\nschema = wrapper.schema\nresult = wrapper({\"location\": \"San Francisco, CA\"})\n```\n\nOr you could use [skills](https://anthropic-tools.readthedocs.io/en/latest/skills.html).\n\n## How it Works\n\n`anthropic-tools` takes care of the following tasks:\n\n- Parsing the function signatures (with type annotations) and docstrings.\n- Sending the conversation and tool descriptions to Anthropic Claude.\n- Deciding whether to call a tool based on the model's response.\n- Calling the appropriate function with the provided arguments.\n- Updating the conversation with the tool response.\n- Repeating the process until the model generates a user-facing message.\n\nThis abstraction allows developers to focus on defining their functions and adding user messages without worrying about the details of tool use.\n\n## Note\n\nPlease note that `anthropic-tools` is an unofficial project not maintained by Anthropic. Use it at your discretion.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frizerphe%2Fanthropic-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frizerphe%2Fanthropic-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frizerphe%2Fanthropic-tools/lists"}