{"id":13631419,"url":"https://github.com/npi-ai/npi","last_synced_at":"2025-04-04T11:11:34.189Z","repository":{"id":234660309,"uuid":"780584116","full_name":"npi-ai/npi","owner":"npi-ai","description":"Action library for AI Agent","archived":false,"fork":false,"pushed_at":"2025-03-18T08:45:19.000Z","size":4427,"stargazers_count":211,"open_issues_count":6,"forks_count":11,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-28T10:05:52.240Z","etag":null,"topics":["agent","artificial-intelligence","autogpt","autonomous-agent","browser-automation","chatgpt","function-calling","gpt-4","intergration","large-language-models","llm","openai","prompt-engineering","workflow"],"latest_commit_sha":null,"homepage":"https://docs.npi.ai/docs","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/npi-ai.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-01T19:23:55.000Z","updated_at":"2025-03-18T08:45:23.000Z","dependencies_parsed_at":"2024-05-07T05:44:08.194Z","dependency_job_id":null,"html_url":"https://github.com/npi-ai/npi","commit_stats":null,"previous_names":["npi-ai/npi"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npi-ai%2Fnpi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npi-ai%2Fnpi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npi-ai%2Fnpi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npi-ai%2Fnpi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/npi-ai","download_url":"https://codeload.github.com/npi-ai/npi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247166168,"owners_count":20894654,"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":["agent","artificial-intelligence","autogpt","autonomous-agent","browser-automation","chatgpt","function-calling","gpt-4","intergration","large-language-models","llm","openai","prompt-engineering","workflow"],"created_at":"2024-08-01T22:02:24.712Z","updated_at":"2025-04-04T11:11:34.163Z","avatar_url":"https://github.com/npi-ai.png","language":"Python","funding_links":[],"categories":["Python","Prompts","Learning","Agent Categories","AI Tools"],"sub_categories":["Repositories","\u003ca name=\"Unclassified\"\u003e\u003c/a\u003eUnclassified"],"readme":"# NPI\n\n\u003e [!WARNING]\n\u003e NPi is currently under active development and the APIs are subject to change in the future release. It is recommended\n\u003e to use the command line tool to try it out.\n\nNPi is an open-source platform providing **_Tool-use_** APIs to empower AI agents with the ability to take action in virtual world!\n\n[🛠️Try NPi Online](https://www.npi.ai/playground): Try NPi on online Playground (🚧Under Construction).\n\n[👀 NPi Example](https://docs.npi.ai/examples): **Highly recommended to check this first** - See what you can build with NPi.\n\n[🔥 Introducing NPi](https://docs.npi.ai/blog/introducing-npi): Why we build NPi?\n\n[📚 NPi Documentation](https://docs.npi.ai/docs): How to use NPi?\n\n[📢 Join our community on Discord](https://discord.gg/wdskUcKc): Let's build NPi together 👻 !\n\n\nNPi (**N**atural-language **P**rogramming **I**nterface), pronounced as **\"N π\"**, is an open-source platform providing **_Tool-use_** APIs to empower AI agents with the ability to operate and interact with a diverse array of software tools and applications.\n\n## Installation\n\n```sh\npip install npiai\n```\n\n## One-Minute Quick Start\n\nLet's create a new tool to compute the nth Fibonacci number. Start by crafting a new Python file titled `main.py` and insert the following snippet:\n\n```py filename=\"main.py\" showLineNumbers {9,12-13,19-22,33,44,51}\nimport os\nimport json\nimport asyncio\n\nfrom openai import OpenAI\nfrom npiai import FunctionTool, function\n\n\nclass MyTool(FunctionTool):\n    name = 'Fibonacci'\n    description = 'My first NPi tool'\n\n    @function\n    def fibonacci(self, n: int) -\u003e int:\n        \"\"\"\n        Get the nth Fibonacci number.\n\n        Args:\n            n: The index of the Fibonacci number in the sequence.\n        \"\"\"\n        if n == 0:\n            return 0\n        if n == 1:\n            return 1\n        return self.fibonacci(n - 1) + self.fibonacci(n - 2)\n\n\nasync def main():\n    async with MyTool() as tool:\n        print(f'The schema of the tool is\\n\\n {json.dumps(tool.tools, indent=2)}')\n        client = OpenAI(api_key=os.getenv('OPENAI_API_KEY'))\n        messages = [\n            {\n                \"role\": \"user\",\n                \"content\": \"What's the 10-th fibonacci number?\",\n            }\n        ]\n        response = client.chat.completions.create(\n            model=\"gpt-4o\",\n            messages=messages,\n            tools=tool.tools,  # use tool as functions package\n            tool_choice=\"auto\",\n            max_tokens=4096,\n        )\n        response_message = response.choices[0].message\n        if response_message.tool_calls:\n            result = await tool.call(tool_calls=response_message.tool_calls)\n            print(f'The result of function\\n\\n {json.dumps(result, indent=2)}')\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\nNow, run the tool:\n\n```sh\npython main.py\n```\n\nYou will see the function result in [OpenAI function calling format](https://platform.openai.com/docs/guides/function-calling/function-calling):\n\n```json {6}\n[\n  {\n    \"role\": \"tool\",\n    \"name\": \"fibonacci\",\n    \"tool_call_id\": \"call_4KItpriZmoGxXgDloI5WOtHm\",\n    \"content\": 55\n  }\n]\n```\n\n`content: 55` is the result of function calling, and the schema：\n\n```json {6, 9-12}\n[\n  {\n    \"type\": \"function\",\n    \"function\": {\n      \"name\": \"fibonacci\",\n      \"description\": \"Get the nth Fibonacci number.\",\n      \"parameters\": {\n        \"properties\": {\n          \"n\": {\n            \"description\": \"The index of the Fibonacci number in the sequence.\",\n            \"type\": \"integer\"\n          }\n        },\n        \"required\": [\n          \"n\"\n        ],\n        \"type\": \"object\"\n      }\n    }\n  }\n]\n```\n\nThat's it! You've successfully created and run your first NPi tool. 🎉\n\n## Next Steps\n\n- [Read the Documentation](https://docs.npi.ai/docs)\n- [Explore More Examples](examples)\n- [NPi Cloud(coming soon)](#)\n\n## License\n\nApache License 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpi-ai%2Fnpi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnpi-ai%2Fnpi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpi-ai%2Fnpi/lists"}