Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/npi-ai/npi
Action library for AI Agent
https://github.com/npi-ai/npi
agent artificial-intelligence autogpt autonomous-agent browser-automation chatgpt function-calling gpt-4 intergration large-language-models llm openai prompt-engineering workflow
Last synced: 6 days ago
JSON representation
Action library for AI Agent
- Host: GitHub
- URL: https://github.com/npi-ai/npi
- Owner: npi-ai
- License: apache-2.0
- Created: 2024-04-01T19:23:55.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-01-24T01:50:16.000Z (14 days ago)
- Last Synced: 2025-01-25T06:05:23.125Z (13 days ago)
- Topics: agent, artificial-intelligence, autogpt, autonomous-agent, browser-automation, chatgpt, function-calling, gpt-4, intergration, large-language-models, llm, openai, prompt-engineering, workflow
- Language: Python
- Homepage: https://docs.npi.ai/docs
- Size: 5.04 MB
- Stars: 206
- Watchers: 7
- Forks: 8
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ChatGPT-repositories - npi - Tool use APIs platform for AI Agent (Prompts)
- awesome_ai_agents - NPI - NPi is an open-source platform providing tool-use APIs for AI agents, with installation and setup instructions available [github](https://github.com/npi-ai/npi) | [website](https://www.npi.ai/) | [docs](https://www.npi.ai/docs) | [blog](https://www.npi.ai/blog) (Learning / Repositories)
- awesome_ai_agents - NPI - NPi is an open-source platform providing tool-use APIs for AI agents, with installation and setup instructions available [github](https://github.com/npi-ai/npi) | [website](https://www.npi.ai/) | [docs](https://www.npi.ai/docs) | [blog](https://www.npi.ai/blog) (Learning / Repositories)
README
# NPI
> [!WARNING]
> NPi is currently under active development and the APIs are subject to change in the future release. It is recommended
> to use the command line tool to try it out.NPi is an open-source platform providing **_Tool-use_** APIs to empower AI agents with the ability to take action in virtual world!
[π οΈTry NPi Online](https://www.npi.ai/playground): Try NPi on online Playground (π§Under Construction).
[π NPi Example](https://docs.npi.ai/examples): **Highly recommended to check this first** - See what you can build with NPi.
[π₯ Introducing NPi](https://docs.npi.ai/blog/introducing-npi): Why we build NPi?
[π NPi Documentation](https://docs.npi.ai/docs): How to use NPi?
[π’ Join our community on Discord](https://discord.gg/wdskUcKc): Let's build NPi together π» !
NPi (**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.
## Installation
```sh
pip install npiai
```## One-Minute Quick Start
Let'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:
```py filename="main.py" showLineNumbers {9,12-13,19-22,33,44,51}
import os
import json
import asynciofrom openai import OpenAI
from npiai import FunctionTool, functionclass MyTool(FunctionTool):
name = 'Fibonacci'
description = 'My first NPi tool'@function
def fibonacci(self, n: int) -> int:
"""
Get the nth Fibonacci number.Args:
n: The index of the Fibonacci number in the sequence.
"""
if n == 0:
return 0
if n == 1:
return 1
return self.fibonacci(n - 1) + self.fibonacci(n - 2)async def main():
async with MyTool() as tool:
print(f'The schema of the tool is\n\n {json.dumps(tool.tools, indent=2)}')
client = OpenAI(api_key=os.getenv('OPENAI_API_KEY'))
messages = [
{
"role": "user",
"content": "What's the 10-th fibonacci number?",
}
]
response = client.chat.completions.create(
model="gpt-4o",
messages=messages,
tools=tool.tools, # use tool as functions package
tool_choice="auto",
max_tokens=4096,
)
response_message = response.choices[0].message
if response_message.tool_calls:
result = await tool.call(tool_calls=response_message.tool_calls)
print(f'The result of function\n\n {json.dumps(result, indent=2)}')if __name__ == "__main__":
asyncio.run(main())
```Now, run the tool:
```sh
python main.py
```You will see the function result in [OpenAI function calling format](https://platform.openai.com/docs/guides/function-calling/function-calling):
```json {6}
[
{
"role": "tool",
"name": "fibonacci",
"tool_call_id": "call_4KItpriZmoGxXgDloI5WOtHm",
"content": 55
}
]
````content: 55` is the result of function calling, and the schemaοΌ
```json {6, 9-12}
[
{
"type": "function",
"function": {
"name": "fibonacci",
"description": "Get the nth Fibonacci number.",
"parameters": {
"properties": {
"n": {
"description": "The index of the Fibonacci number in the sequence.",
"type": "integer"
}
},
"required": [
"n"
],
"type": "object"
}
}
}
]
```That's it! You've successfully created and run your first NPi tool. π
## Next Steps
- [Read the Documentation](https://docs.npi.ai/docs)
- [Explore More Examples](examples)
- [NPi Cloud(coming soon)](#)## License
Apache License 2.0