jaims-py


Namejaims-py JSON
Version 1.0.6 PyPI version JSON
download
home_pagehttps://github.com/dev-mush/jaims-py
SummaryA Python package for creating simple AI Agents using the OpenAI API.
upload_time2024-01-19 11:41:17
maintainer
docs_urlNone
authorMarco Musella
requires_python
licenseMIT
keywords openai gpt-3 and gpt-4 function enabled agent
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
    <img width="300" src="https://github.com/dev-mush/jaims-py/assets/669003/5c53381f-25b5-4141-bcd2-7457863eafb9" >
</p>


# jAIms 

_My name is Bot, jAIMs Bot._ 🕶️

jAIms is a lightweight Python framework built on top of the OpenAI library that lets you create powerful LLM agents.
It is designed with simplicity and ease of use in mind and only depends on `openai`, `tiktoken` and `Pillow`.

## Installation

```bash
pip install jaims-py
```

## 👨‍💻 Usage

Building an agent is as simple as this:

```python
from jaims import JAImsAgent

agent = JAImsAgent()

response = agent.run([
    {
        "role": "user",
        "content": "Hi!"
    }
])

print(response)
```

### ⚙️ Functions

Of course, an agent is just a chatbot if it doesn't support functions. jAIms uses the built-in OpenAI tools feature to call the functions you pass to it. Here's an example where we create a simple sum function and make a simple agent that lets you sum two numbers:

```python
import jaims


def sum(a: int, b: int):
    return a + b

# this is a class that wraps your function, it will 
# receive the actual function plus all the info required 
# by the llm to invoke it.
func_wrapper = JAImsFuncWrapper(
    function=sum, 
    name="sum", 
    description="use this function when the user wants to sum two numbers",
    params_descriptors=[
        JAImsParamDescriptor(
            name="a",
            description="first operand",
            json_type=JAImsJsonSchemaType.NUMBER,
        ),
        JAImsParamDescriptor(
            name="b",
            description="second operand",
            json_type=JAImsJsonSchemaType.NUMBER,
        ),
    ],
)

# instantiate the agent passing the functions
agent = JAImsAgent(
        openai_kwargs=JAImsOpenaiKWArgs(
            model=JAImsGPTModel.GPT_4,
            tools=[
                func_wrapper,
            ],
        ),
    )
# a simple loop that simulates a chatbot
while True:
    user_input = input("> ")
    if user_input == "exit":
        break
    response = agent.run(
        [{"role": "user", "content": user_input}],
    )

    for chunk in response:
        print(chunk, end="", flush=True)
        
        print("\n")
```

### ✨ Other features

- Complete control over openai call parameters.
- Automatic chat history management
- Configuration of the OpenAI model to use
- Injectable prompt to shape agent behavior
- Safety checks to prevent the agent from endlessly looping over function calls

I will routinely update the examples to demonstrate more advanced features.
Also, I've made sure to document the code as best as I can; everything should be self-explanatory; I plan to add a proper documentation in the future if this project gets enough traction.

## 🤖 Supported models

Currently, jAIms supports the new OpenAI models with functions enabled, specifically:

- `gpt-3.5-turbo-0613`
- `gpt-3.5-turbo-16k-0613`
- `gpt-4-0613`
- `gpt-4-32k-0613`
- `gpt-4-1106-preview`
- `gpt-4-vision-preview`

I'm not planning to add support for non-OpenAI models at the moment, but contributions are always appreciated.

## ⚠️ Project status

This is a work in progress. I still need to write some tests and add many features, but the core functionality is there.
I'm creating this framework because I need a lightweight and easy-to-use framework to create LLM agents. This project may not be as advanced as tools like [langchain](https://github.com/hwchase17/langchain) and others, but if you need a simple tool to create agents based on the OpenAI API, you might find jAIms useful.


TODOS:

- [ ] Add tests
- [ ] Add more examples
- [ ] Add more chat history optimization strategies
- [ ] Add function calling callbacks 
- [ ] Add history persistance

## 📝 License

The license will be MIT, but I need to add this properly.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dev-mush/jaims-py",
    "name": "jaims-py",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "OpenAI GPT-3 and GPT-4 function enabled agent",
    "author": "Marco Musella",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/67/c2/4554cb4baca37bd913a127c2e687592e3db925b3c3f95a1ff507996a1c15/jaims-py-1.0.6.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n    <img width=\"300\" src=\"https://github.com/dev-mush/jaims-py/assets/669003/5c53381f-25b5-4141-bcd2-7457863eafb9\" >\n</p>\n\n\n# jAIms \n\n_My name is Bot, jAIMs Bot._ \ud83d\udd76\ufe0f\n\njAIms is a lightweight Python framework built on top of the OpenAI library that lets you create powerful LLM agents.\nIt is designed with simplicity and ease of use in mind and only depends on `openai`, `tiktoken` and `Pillow`.\n\n## Installation\n\n```bash\npip install jaims-py\n```\n\n## \ud83d\udc68\u200d\ud83d\udcbb Usage\n\nBuilding an agent is as simple as this:\n\n```python\nfrom jaims import JAImsAgent\n\nagent = JAImsAgent()\n\nresponse = agent.run([\n    {\n        \"role\": \"user\",\n        \"content\": \"Hi!\"\n    }\n])\n\nprint(response)\n```\n\n### \u2699\ufe0f Functions\n\nOf course, an agent is just a chatbot if it doesn't support functions. jAIms uses the built-in OpenAI tools feature to call the functions you pass to it. Here's an example where we create a simple sum function and make a simple agent that lets you sum two numbers:\n\n```python\nimport jaims\n\n\ndef sum(a: int, b: int):\n    return a + b\n\n# this is a class that wraps your function, it will \n# receive the actual function plus all the info required \n# by the llm to invoke it.\nfunc_wrapper = JAImsFuncWrapper(\n    function=sum, \n    name=\"sum\", \n    description=\"use this function when the user wants to sum two numbers\",\n    params_descriptors=[\n        JAImsParamDescriptor(\n            name=\"a\",\n            description=\"first operand\",\n            json_type=JAImsJsonSchemaType.NUMBER,\n        ),\n        JAImsParamDescriptor(\n            name=\"b\",\n            description=\"second operand\",\n            json_type=JAImsJsonSchemaType.NUMBER,\n        ),\n    ],\n)\n\n# instantiate the agent passing the functions\nagent = JAImsAgent(\n        openai_kwargs=JAImsOpenaiKWArgs(\n            model=JAImsGPTModel.GPT_4,\n            tools=[\n                func_wrapper,\n            ],\n        ),\n    )\n# a simple loop that simulates a chatbot\nwhile True:\n    user_input = input(\"> \")\n    if user_input == \"exit\":\n        break\n    response = agent.run(\n        [{\"role\": \"user\", \"content\": user_input}],\n    )\n\n    for chunk in response:\n        print(chunk, end=\"\", flush=True)\n        \n        print(\"\\n\")\n```\n\n### \u2728 Other features\n\n- Complete control over openai call parameters.\n- Automatic chat history management\n- Configuration of the OpenAI model to use\n- Injectable prompt to shape agent behavior\n- Safety checks to prevent the agent from endlessly looping over function calls\n\nI will routinely update the examples to demonstrate more advanced features.\nAlso, I've made sure to document the code as best as I can; everything should be self-explanatory; I plan to add a proper documentation in the future if this project gets enough traction.\n\n## \ud83e\udd16 Supported models\n\nCurrently, jAIms supports the new OpenAI models with functions enabled, specifically:\n\n- `gpt-3.5-turbo-0613`\n- `gpt-3.5-turbo-16k-0613`\n- `gpt-4-0613`\n- `gpt-4-32k-0613`\n- `gpt-4-1106-preview`\n- `gpt-4-vision-preview`\n\nI'm not planning to add support for non-OpenAI models at the moment, but contributions are always appreciated.\n\n## \u26a0\ufe0f Project status\n\nThis is a work in progress. I still need to write some tests and add many features, but the core functionality is there.\nI'm creating this framework because I need a lightweight and easy-to-use framework to create LLM agents. This project may not be as advanced as tools like [langchain](https://github.com/hwchase17/langchain) and others, but if you need a simple tool to create agents based on the OpenAI API, you might find jAIms useful.\n\n\nTODOS:\n\n- [ ] Add tests\n- [ ] Add more examples\n- [ ] Add more chat history optimization strategies\n- [ ] Add function calling callbacks \n- [ ] Add history persistance\n\n## \ud83d\udcdd License\n\nThe license will be MIT, but I need to add this properly.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python package for creating simple AI Agents using the OpenAI API.",
    "version": "1.0.6",
    "project_urls": {
        "Homepage": "https://github.com/dev-mush/jaims-py"
    },
    "split_keywords": [
        "openai",
        "gpt-3",
        "and",
        "gpt-4",
        "function",
        "enabled",
        "agent"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5b375d3990e4060ef03f24d67d24631dc8c447ef715692144d3fe491f21d58c5",
                "md5": "bbd55986dd172914ad29383885821296",
                "sha256": "11ff6ccb4a4d4816a54673aa8d71dfc4ac3fc1f878f5e53044bee7a6dc5ecc0f"
            },
            "downloads": -1,
            "filename": "jaims_py-1.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bbd55986dd172914ad29383885821296",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 16856,
            "upload_time": "2024-01-19T11:41:15",
            "upload_time_iso_8601": "2024-01-19T11:41:15.761702Z",
            "url": "https://files.pythonhosted.org/packages/5b/37/5d3990e4060ef03f24d67d24631dc8c447ef715692144d3fe491f21d58c5/jaims_py-1.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "67c24554cb4baca37bd913a127c2e687592e3db925b3c3f95a1ff507996a1c15",
                "md5": "8ec7ef42c7f8da407f3f1dfe8180231a",
                "sha256": "8451f2daa448f9ca146a9794a989d7427a1ca4fab66a739bca9181f88f8a0504"
            },
            "downloads": -1,
            "filename": "jaims-py-1.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "8ec7ef42c7f8da407f3f1dfe8180231a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 16353,
            "upload_time": "2024-01-19T11:41:17",
            "upload_time_iso_8601": "2024-01-19T11:41:17.086957Z",
            "url": "https://files.pythonhosted.org/packages/67/c2/4554cb4baca37bd913a127c2e687592e3db925b3c3f95a1ff507996a1c15/jaims-py-1.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-19 11:41:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dev-mush",
    "github_project": "jaims-py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "jaims-py"
}
        
Elapsed time: 0.16838s