{"id":2040181,"url":"https://github.com/janekb04/py2gpt","last_synced_at":"2025-04-04T10:31:10.636Z","repository":{"id":218300021,"uuid":"655405261","full_name":"janekb04/py2gpt","owner":"janekb04","description":"Convert Python code into JSON consumable by OpenAI's function API.","archived":false,"fork":false,"pushed_at":"2023-06-26T06:55:58.000Z","size":734,"stargazers_count":25,"open_issues_count":1,"forks_count":6,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-11-05T06:34:18.252Z","etag":null,"topics":["ai","api","chatgpt","converter","function","gpt","gpt-4","json","nlp","openai","openai-api","python","schema","transcoding"],"latest_commit_sha":null,"homepage":"https://janekb04.github.io/py2gpt/","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/janekb04.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":"2023-06-18T19:43:16.000Z","updated_at":"2024-08-17T00:03:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"e1d7b478-08a3-4933-9eab-a63c8bc498fe","html_url":"https://github.com/janekb04/py2gpt","commit_stats":null,"previous_names":["janekb04/py2gpt"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janekb04%2Fpy2gpt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janekb04%2Fpy2gpt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janekb04%2Fpy2gpt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janekb04%2Fpy2gpt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/janekb04","download_url":"https://codeload.github.com/janekb04/py2gpt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247160395,"owners_count":20893823,"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":["ai","api","chatgpt","converter","function","gpt","gpt-4","json","nlp","openai","openai-api","python","schema","transcoding"],"created_at":"2024-01-21T03:52:04.212Z","updated_at":"2025-04-04T10:31:10.612Z","avatar_url":"https://github.com/janekb04.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# py2gpt\n\nRecently, OpenAI has released the GPT function API that allows models like GPT-4 to \"invoke\" functions on the user's behalf.\nThe problem is that the format, in which these functions is specified, is JSON Schema, which is relatively niche and hard to work with.\nThis repository addresses this issue. It converts regular Python function declarations into JSON consumable by the OpenAI API.\n\nFor example, this Python code:\n```py\ndef get_current_weather(location: str, format: Literal[\"fahrenheit\", \"celsius\"]):\n    \"\"\"\n    Get the current weather\n    :param location: The city and state, e.g. San Francisco, CA\n    :param format: The temperature unit to use. Infer this from the users location.\n    \"\"\"\n```\nProduces the following JSON that matches one of OpenAI's own examples:\n```js\n{\n    'name': 'get_current_weather',\n    'description': 'Get the current weather',\n    'parameters': {\n        'type': 'object',\n        'properties': {\n            'location': {\n                'description': 'The city and state, e.g. San Francisco, CA',\n                'type': 'string'\n            },\n            'format': {\n                'description': 'The temperature unit to use. Infer this from the\nusers location.',\n                'type': 'string',\n                'enum': ('fahrenheit', 'celsius')\n            }\n        }\n    },\n    'required': ['location', 'format']\n}\n```\n\n## Roadmap\n\n- [ ] Support classes (treat them as `object`s with certain `\"properties\"\n- [ ] Support methods (treat them as functions with an additional `self` parameter`)\n- [x] Support multiple functions\n- [ ] Support `Enum`s\n- [ ] Support named tuples\n- [ ] Make the code safe for local execution\n- [ ] Refactor code and make locally executable\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanekb04%2Fpy2gpt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjanekb04%2Fpy2gpt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanekb04%2Fpy2gpt/lists"}