dm-aioaiagent


Namedm-aioaiagent JSON
Version 0.5.6 PyPI version JSON
download
home_pagehttps://pypi.org/project/dm-aioaiagent
SummaryThis is my custom aioaiagent client
upload_time2025-10-21 10:29:41
maintainerNone
docs_urlNone
authordimka4621
requires_python>=3.9
licenseNone
keywords dm aioaiagent
VCS
bugtrack_url
requirements dm-logger python-dotenv pydantic langchain langchain-core langchain-community langchain-openai langchain-anthropic langgraph langsmith grandalf
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # DM-aioaiagent

## Urls

* [PyPI](https://pypi.org/project/dm-aioaiagent)
* [GitHub](https://github.com/MykhLibs/dm-aioaiagent)

### * Package contains both `asynchronous` and `synchronous` clients

## Usage

Analogue to `DMAioAIAgent` is the synchronous client `DMAIAgent`.

### Windows Setup

```python
import asyncio
import sys

if sys.platform == "win32":
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
```

### Api Key Setup

You can set your OpenAI API key in the environment variable `OPENAI_API_KEY` or pass it as an argument to the agent.

**Use load_dotenv to load the `.env` file.**

```python
from dotenv import load_dotenv
load_dotenv()
```

### Use agent *with* inner memory and run *single* message

By default, agent use inner memory to store the conversation history.

(You can set *max count messages in memory* by `max_memory_messages` init argument)

```python
import asyncio
from dm_aioaiagent import DMAioAIAgent


async def main():
    # define a system message
    system_message = "Your custom system message with role, backstory and goal"

    # (optional) define a list of tools, if you want to use them
    tools = [...]

    # define a openai model, default is "gpt-4o-mini"
    model_name = "gpt-4o"

    # create an agent
    ai_agent = DMAioAIAgent(system_message, tools, model=model_name)
    # if you don't want to see the input and output messages from agent
    # you can set `input_output_logging=False` init argument

    # call an agent
    answer = await ai_agent.run("Hello!")

    # call an agent
    answer = await ai_agent.run("I want to know the weather in Kyiv")

    # get full conversation history
    conversation_history = ai_agent.memory_messages

    # clear conversation history
    ai_agent.clear_memory_messages()


if __name__ == "__main__":
    asyncio.run(main())
```

### Use agent *without* inner memory and run *multiple* messages

If you want to control the memory of the agent, you can disable it by setting `is_memory_enabled=False`

```python
import asyncio
from dm_aioaiagent import DMAioAIAgent


async def main():
    # define a system message
    system_message = "Your custom system message with role, backstory and goal"

    # (optional) define a list of tools, if you want to use them
    tools = [...]

    # define a openai model, default is "gpt-4o-mini"
    model_name = "gpt-4o"

    # create an agent
    ai_agent = DMAioAIAgent(system_message, tools, model=model_name,
                            is_memory_enabled=False)
    # if you don't want to see the input and output messages from agent
    # you can set input_output_logging=False

    # define the conversation message(s)
    messages = [
        {"role": "user", "content": "Hello!"}
    ]

    # call an agent
    new_messages = await ai_agent.run_messages(messages)

    # add new_messages to messages
    messages.extend(new_messages)

    # define the next conversation message
    messages.append(
        {"role": "user", "content": "I want to know the weather in Kyiv"}
    )

    # call an agent
    new_messages = await ai_agent.run_messages(messages)


if __name__ == "__main__":
    asyncio.run(main())
```

### Image vision

```python
from dm_aioaiagent import DMAIAgent, OpenAIImageMessageContent


def main():
    # create an agent
    ai_agent = DMAIAgent(agent_name="image_vision", model="gpt-4o")

    # create an image message content
    # NOTE: text argument is optional
    img_content = OpenAIImageMessageContent(image_url="https://your.domain/image",
                                            text="Hello, what is shown in the photo?")

    # define the conversation messages
    messages = [
        {"role": "user", "content": "Hello!"},
        {"role": "user", "content": img_content},
    ]

    # call an agent
    new_messages = ai_agent.run_messages(messages)
    answer = new_messages[-1].content


if __name__ == "__main__":
    main()
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://pypi.org/project/dm-aioaiagent",
    "name": "dm-aioaiagent",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "dm aioaiagent",
    "author": "dimka4621",
    "author_email": "mismartconfig@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/a9/2e/b557adce2caf7bc3f874e0b1fc7b3acdf4e755debcbef4ed283afd0543eb/dm_aioaiagent-0.5.6.tar.gz",
    "platform": null,
    "description": "# DM-aioaiagent\n\n## Urls\n\n* [PyPI](https://pypi.org/project/dm-aioaiagent)\n* [GitHub](https://github.com/MykhLibs/dm-aioaiagent)\n\n### * Package contains both `asynchronous` and `synchronous` clients\n\n## Usage\n\nAnalogue to `DMAioAIAgent` is the synchronous client `DMAIAgent`.\n\n### Windows Setup\n\n```python\nimport asyncio\nimport sys\n\nif sys.platform == \"win32\":\n    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())\n```\n\n### Api Key Setup\n\nYou can set your OpenAI API key in the environment variable `OPENAI_API_KEY` or pass it as an argument to the agent.\n\n**Use load_dotenv to load the `.env` file.**\n\n```python\nfrom dotenv import load_dotenv\nload_dotenv()\n```\n\n### Use agent *with* inner memory and run *single* message\n\nBy default, agent use inner memory to store the conversation history.\n\n(You can set *max count messages in memory* by `max_memory_messages` init argument)\n\n```python\nimport asyncio\nfrom dm_aioaiagent import DMAioAIAgent\n\n\nasync def main():\n    # define a system message\n    system_message = \"Your custom system message with role, backstory and goal\"\n\n    # (optional) define a list of tools, if you want to use them\n    tools = [...]\n\n    # define a openai model, default is \"gpt-4o-mini\"\n    model_name = \"gpt-4o\"\n\n    # create an agent\n    ai_agent = DMAioAIAgent(system_message, tools, model=model_name)\n    # if you don't want to see the input and output messages from agent\n    # you can set `input_output_logging=False` init argument\n\n    # call an agent\n    answer = await ai_agent.run(\"Hello!\")\n\n    # call an agent\n    answer = await ai_agent.run(\"I want to know the weather in Kyiv\")\n\n    # get full conversation history\n    conversation_history = ai_agent.memory_messages\n\n    # clear conversation history\n    ai_agent.clear_memory_messages()\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n### Use agent *without* inner memory and run *multiple* messages\n\nIf you want to control the memory of the agent, you can disable it by setting `is_memory_enabled=False`\n\n```python\nimport asyncio\nfrom dm_aioaiagent import DMAioAIAgent\n\n\nasync def main():\n    # define a system message\n    system_message = \"Your custom system message with role, backstory and goal\"\n\n    # (optional) define a list of tools, if you want to use them\n    tools = [...]\n\n    # define a openai model, default is \"gpt-4o-mini\"\n    model_name = \"gpt-4o\"\n\n    # create an agent\n    ai_agent = DMAioAIAgent(system_message, tools, model=model_name,\n                            is_memory_enabled=False)\n    # if you don't want to see the input and output messages from agent\n    # you can set input_output_logging=False\n\n    # define the conversation message(s)\n    messages = [\n        {\"role\": \"user\", \"content\": \"Hello!\"}\n    ]\n\n    # call an agent\n    new_messages = await ai_agent.run_messages(messages)\n\n    # add new_messages to messages\n    messages.extend(new_messages)\n\n    # define the next conversation message\n    messages.append(\n        {\"role\": \"user\", \"content\": \"I want to know the weather in Kyiv\"}\n    )\n\n    # call an agent\n    new_messages = await ai_agent.run_messages(messages)\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n### Image vision\n\n```python\nfrom dm_aioaiagent import DMAIAgent, OpenAIImageMessageContent\n\n\ndef main():\n    # create an agent\n    ai_agent = DMAIAgent(agent_name=\"image_vision\", model=\"gpt-4o\")\n\n    # create an image message content\n    # NOTE: text argument is optional\n    img_content = OpenAIImageMessageContent(image_url=\"https://your.domain/image\",\n                                            text=\"Hello, what is shown in the photo?\")\n\n    # define the conversation messages\n    messages = [\n        {\"role\": \"user\", \"content\": \"Hello!\"},\n        {\"role\": \"user\", \"content\": img_content},\n    ]\n\n    # call an agent\n    new_messages = ai_agent.run_messages(messages)\n    answer = new_messages[-1].content\n\n\nif __name__ == \"__main__\":\n    main()\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "This is my custom aioaiagent client",
    "version": "0.5.6",
    "project_urls": {
        "GitHub": "https://github.com/MykhLibs/dm-aioaiagent",
        "Homepage": "https://pypi.org/project/dm-aioaiagent"
    },
    "split_keywords": [
        "dm",
        "aioaiagent"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "c129be6a59afe2c0df35965b88162f3a71faee2b2f01c5c4cd461664a72ed0d3",
                "md5": "0b984021c254c868a56900f168a389dc",
                "sha256": "2cc475f8b4ed079386bc868dd3d4fcf49148abea971ecc81ea8c6f81f6b75e3a"
            },
            "downloads": -1,
            "filename": "dm_aioaiagent-0.5.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0b984021c254c868a56900f168a389dc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 8801,
            "upload_time": "2025-10-21T10:29:40",
            "upload_time_iso_8601": "2025-10-21T10:29:40.284301Z",
            "url": "https://files.pythonhosted.org/packages/c1/29/be6a59afe2c0df35965b88162f3a71faee2b2f01c5c4cd461664a72ed0d3/dm_aioaiagent-0.5.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a92eb557adce2caf7bc3f874e0b1fc7b3acdf4e755debcbef4ed283afd0543eb",
                "md5": "3508301dd4793bf09575072fb0b6bd26",
                "sha256": "8964e5d0ddc6c1d74011adba2f9c4051c16aaca5ca7bf22fc1d83bbe26a8948f"
            },
            "downloads": -1,
            "filename": "dm_aioaiagent-0.5.6.tar.gz",
            "has_sig": false,
            "md5_digest": "3508301dd4793bf09575072fb0b6bd26",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 8423,
            "upload_time": "2025-10-21T10:29:41",
            "upload_time_iso_8601": "2025-10-21T10:29:41.132843Z",
            "url": "https://files.pythonhosted.org/packages/a9/2e/b557adce2caf7bc3f874e0b1fc7b3acdf4e755debcbef4ed283afd0543eb/dm_aioaiagent-0.5.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-21 10:29:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "MykhLibs",
    "github_project": "dm-aioaiagent",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "dm-logger",
            "specs": [
                [
                    ">=",
                    "0.6.6"
                ],
                [
                    "<",
                    "0.7.0"
                ]
            ]
        },
        {
            "name": "python-dotenv",
            "specs": [
                [
                    "<",
                    "1.1.0"
                ],
                [
                    ">=",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "pydantic",
            "specs": [
                [
                    ">=",
                    "2.9.2"
                ],
                [
                    "<",
                    "3.0.0"
                ]
            ]
        },
        {
            "name": "langchain",
            "specs": [
                [
                    ">=",
                    "0.3.0"
                ],
                [
                    "<",
                    "0.4.0"
                ]
            ]
        },
        {
            "name": "langchain-core",
            "specs": [
                [
                    "<",
                    "0.4.0"
                ],
                [
                    ">=",
                    "0.3.5"
                ]
            ]
        },
        {
            "name": "langchain-community",
            "specs": [
                [
                    ">=",
                    "0.3.0"
                ],
                [
                    "<",
                    "0.4.0"
                ]
            ]
        },
        {
            "name": "langchain-openai",
            "specs": [
                [
                    ">=",
                    "0.3.0"
                ],
                [
                    "<",
                    "0.4.0"
                ]
            ]
        },
        {
            "name": "langchain-anthropic",
            "specs": [
                [
                    ">=",
                    "0.3.0"
                ],
                [
                    "<",
                    "0.4.0"
                ]
            ]
        },
        {
            "name": "langgraph",
            "specs": [
                [
                    ">=",
                    "0.3.23"
                ],
                [
                    "<",
                    "0.4.0"
                ]
            ]
        },
        {
            "name": "langsmith",
            "specs": [
                [
                    ">=",
                    "0.3.45"
                ],
                [
                    "<",
                    "0.4.0"
                ]
            ]
        },
        {
            "name": "grandalf",
            "specs": [
                [
                    "<",
                    "0.9.0"
                ],
                [
                    ">=",
                    "0.8.0"
                ]
            ]
        }
    ],
    "lcname": "dm-aioaiagent"
}
        
Elapsed time: 3.09823s