{"id":18689728,"url":"https://github.com/mrseanryan/gpt-function-calling-bare-bones","last_synced_at":"2025-06-17T07:39:27.482Z","repository":{"id":233273650,"uuid":"786391757","full_name":"mrseanryan/gpt-function-calling-bare-bones","owner":"mrseanryan","description":"Function Calling an LLM taking a bare-bones (no libraries) approach","archived":false,"fork":false,"pushed_at":"2024-04-14T12:17:08.000Z","size":87,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-28T01:49:43.005Z","etag":null,"topics":["function-calling","llm","llm-inference"],"latest_commit_sha":null,"homepage":"https://medium.com/p/41fdd035d781","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/mrseanryan.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}},"created_at":"2024-04-14T10:17:50.000Z","updated_at":"2024-04-14T11:51:04.000Z","dependencies_parsed_at":"2024-04-15T11:00:32.904Z","dependency_job_id":null,"html_url":"https://github.com/mrseanryan/gpt-function-calling-bare-bones","commit_stats":null,"previous_names":["mrseanryan/gpt-function-calling-bare-bones"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrseanryan%2Fgpt-function-calling-bare-bones","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrseanryan%2Fgpt-function-calling-bare-bones/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrseanryan%2Fgpt-function-calling-bare-bones/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrseanryan%2Fgpt-function-calling-bare-bones/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrseanryan","download_url":"https://codeload.github.com/mrseanryan/gpt-function-calling-bare-bones/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239550286,"owners_count":19657541,"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":["function-calling","llm","llm-inference"],"created_at":"2024-11-07T10:44:58.625Z","updated_at":"2025-02-18T21:11:41.624Z","avatar_url":"https://github.com/mrseanryan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gpt-function-calling-bare-bones README\n\nFunction Calling an LLM taking a bare-bones (no libraries) approach.\n\nLarger LLMs can be used via Function Calling via a bare bones approach without any extra Python libraries.\n\nThis repo shows a simple example of an LLM driving a home automation system, by generating a list of function calls selected from the available functions.\n\nThe LLM is Anthropic Claude hosted on AWS Bedrock - but any large LLM should work.\n\nThe functions are listed in a JSON file. Here is a diagram to show how this approach can be used to control a Home Automation system via natural language:\n\n![function calling example](./diagrams/function-calling.png)\n\n## Set up\n\n```shell\npython -m pip install pipenv\npython -m pipenv install\n```\n\n## Usage\n\n```shell\npython -m pipenv run python main.py \u003cpath to functions JSON file\u003e \u003cuser prompt\u003e [--chat]\n```\n\n### Example - LLM controlling a Home Automation system, asked to adjust for going on vacation:\n\n```shell\npython -m pipenv run python ./main.py ./data/home-automation-functions.json \"I am going on vacation - please adjust my home\"\n```\n\nOutput:\n\n```\n[\n    {\n        \"functionCalls\": [\n            {\n                \"name\": \"AdjustAC\",\n                \"parameters\": [\n                    {\"name\": \"level\", \"value\": 0}\n                ]\n            },\n            {\n                \"name\": \"AdjustHeating\",\n                \"parameters\": [\n                    {\"name\": \"level\", \"value\": 5}\n                ]\n            },\n            {\n                \"name\": \"AdjustLighting\",\n                \"parameters\": [\n                    {\"name\": \"level\", \"value\": 1}\n                ]\n            },\n            {\n                \"name\": \"EnableAlarm\",\n                \"parameters\": [\n                    {\"name\": \"enabled\", \"value\": true}\n                ]\n            },\n            {\n                \"name\": \"ReadInternalThermostatFahrenheit\",\n                \"parameters\": []\n            },\n            {\n                \"name\": \"ReadExternalThermostatFahrenheit\",\n                \"parameters\": []\n            },\n            {\n                \"name\": \"WaterLawn\",\n                \"parameters\": []\n            }\n        ],\n        \"explanation\": \"While on vacation, the AC and lighting should be minimized to save energy, the heating set to a moderate level to avoid freezing, and the alarm enabled for security. The lawn should be watered and internal/external temperatures monitored.\"\n    }\n]\n```\n\n### Example - chat mode\n\n```shell\npython -m pipenv run python ./main.py ./data/home-automation-functions.json \"I am going on vacation - please adjust my home\" --chat\n```\n\n```\nHow can I help? \u003e\u003eturn off the heat\n\u003e\u003e USER: turn off the heat\n=== === ===     [3] PROMPT      === === ===\n=== === ===     [4] RESPONSE    === === ===\n'''json\n[\n  {\n    \"name\": \"AdjustHeating\",\n    \"parameters\": [\n      {\"name\": \"level\", \"value\": 0}\n    ]\n  }\n]\n'''\n\nTo turn off the heating, I called the AdjustHeating function and set the level parameter to 0. This will adjust the heating to the minimum level to turn it off.\n\nHow can I help? \u003e\u003echeck if lawn is ok\n\n\u003e \u003e USER: check if lawn is ok\n\u003e \u003e === === === [5] PROMPT === === ===\n\u003e \u003e === === === [6] RESPONSE === === ===\n\n'''json\n[\n  {\n    \"name\": \"CheckIfRainIsDue\",\n    \"parameters\": []\n  },\n  {\n    \"name\": \"WaterLawn\",\n    \"parameters\": []\n  }\n]\n'''\n\nTo check if the lawn is okay, I included:\n\n1. CheckIfRainIsDue - to see if rain is expected which would water the lawn naturally\n2. WaterLawn - to water the lawn if needed\n\nI omitted any parameters as those functions do not take any based on the provided function definitions.\n\nUSER \u003e\u003echeck if lawn is ok\n\nPOST PROC \u003e\u003e\n[\n{\n\"name\": \"CheckIfRainIsDue\",\n\"parameters\": []\n},\n{\n\"name\": \"WaterLawn\",\n\"parameters\": []\n}\n]\n\n```\n\n## Testing\n\n```shell\n./test.sh\n````\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrseanryan%2Fgpt-function-calling-bare-bones","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrseanryan%2Fgpt-function-calling-bare-bones","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrseanryan%2Fgpt-function-calling-bare-bones/lists"}