{"id":18429084,"url":"https://github.com/lancedb/aifunctools","last_synced_at":"2025-04-07T17:32:33.537Z","repository":{"id":176141500,"uuid":"655059802","full_name":"lancedb/aifunctools","owner":"lancedb","description":"Utility for OpenAI GPT Functions","archived":false,"fork":false,"pushed_at":"2023-06-25T19:00:14.000Z","size":13,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-04-27T01:42:37.320Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lancedb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2023-06-17T18:54:23.000Z","updated_at":"2024-01-25T16:14:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"e8408e37-fd02-47e8-8784-1d65a840e07e","html_url":"https://github.com/lancedb/aifunctools","commit_stats":null,"previous_names":["lancedb/aifunctools"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lancedb%2Faifunctools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lancedb%2Faifunctools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lancedb%2Faifunctools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lancedb%2Faifunctools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lancedb","download_url":"https://codeload.github.com/lancedb/aifunctools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247697921,"owners_count":20981272,"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":[],"created_at":"2024-11-06T05:15:45.707Z","updated_at":"2025-04-07T17:32:33.531Z","avatar_url":"https://github.com/lancedb.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Functools for OpenAI GPT Functions\n\nOpenAI just released GPT Functions: https://openai.com/blog/function-calling-and-other-api-updates\n\nBut it's really cumbersome to make the actual function signature.\nAnd manually parse results and chain the calls:\n\n```shell\ncurl https://api.openai.com/v1/chat/completions -u :$OPENAI_API_KEY -H 'Content-Type: application/json' -d '{\n  \"model\": \"gpt-3.5-turbo-0613\",\n  \"messages\": [\n    {\"role\": \"user\", \"content\": \"What is the weather like in Boston?\"}\n  ],\n  \"functions\": [\n    {\n      \"name\": \"get_current_weather\",\n      \"description\": \"Get the current weather in a given location\",\n      \"parameters\": {\n        \"type\": \"object\",\n        \"properties\": {\n          \"location\": {\n            \"type\": \"string\",\n            \"description\": \"The city and state, e.g. San Francisco, CA\"\n          },\n          \"unit\": {\n            \"type\": \"string\",\n            \"enum\": [\"celsius\", \"fahrenheit\"]\n          }\n        },\n        \"required\": [\"location\"]\n      }\n    }\n  ]\n}'\n```\n\n## Use aifunctools instead\n\nInstead, aifunctools automatically parses available python type annotations \nand docstrings so you don't have to do all of the manual work:\n\n```python\nfrom aifunctools.openai_funcs import complete_with_functions\n\ndef get_current_weather(location: str, unit: str) -\u003e dict:\n    \"\"\"\n    Get the current weather in a given location\n\n    :param location: The city and state, e.g. San Francisco, CA\n    :param unit: Either \"celsius\" or \"fahrenheit\"\n    :return: the current temperature, unit, and a description\n    \"\"\"\n    return {\"temperature\": 22, \"unit\": \"celsius\", \"description\": \"Sunny\"}\n\n\nresp = complete_with_functions(\"What is the weather like in Boston?\",\n                               get_current_weather)\n# The response should contain: \"The weather in Boston is currently sunny with a temperature of 22 degrees Celsius.\"\n```\n\n## What's next\n\n### OpenAPI Specs\n\nPython functions are great, but what would really be great is to parse openapi specs from remote services.\nImagine where every service provider makes their api spec available and agents can just\ncrawl these APIs and use aifunctools to chain them together.\n\n### Richer types\n\nFor this hack we only support the basic string / number / boolean types.\nBy making this more flexible we can get much richer behavior.\n\n### Error handling\n\nI'm sure there are lots of cases where incomplete docstrings and type signatures\nwill cause errors. We can make these more robust (or use some reasonable defaults).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flancedb%2Faifunctools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flancedb%2Faifunctools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flancedb%2Faifunctools/lists"}