srai-chat


Namesrai-chat JSON
Version 0.1.5 PyPI version JSON
download
home_pagehttps://github.com/southriverai/srai-chat
SummaryA chat library frontend for srai services.
upload_time2024-01-20 14:16:32
maintainer
docs_urlNone
authorJaap Oosterbroek
requires_python>=3.5
licenseMIT
keywords srai tools
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # srai-chat
A chat library frontend for srai services.

## installation
```
pip install srai-chat
```

## environment
requires the following environment variables set \
```
"TELEGRAM_ROOT_ID": ""
"TELEGRAM_TOKEN": ""
"OPENAI_API_KEY": ""
"MONGODB_CONNECTION_STRING": "
"MONGODB_DATABASE_NAME": ""
```

## usage example
```
import os

from srai_chat.skill.mode_chat_gpt import ModeChatGpt
from srai_chat.skill.skill_image_tag import SkillImageTag
from srai_chat.skill.skill_mode_tools import SkillModeTools


def initialize_default() -> "ContextManager":
    context = ContextManager()
    ContextManager._instance = context
    telegram_token = os.environ["TELEGRAM_TOKEN"]
    telegram_root_id = int(os.environ["TELEGRAM_ROOT_ID"])
    openai_api_key = os.environ["OPENAI_API_KEY"]
    connection_string = os.environ["MONGODB_CONNECTION_STRING"]
    database_name = os.environ["MONGODB_DATABASE_NAME"]
    from srai_chat.service.service_chat_telegram import ServiceChatTelegram
    from srai_chat.service.service_openai_chat_gpt import ServiceOpenaiChatGpt
    from srai_chat.service.service_persistency_mongo import ServicePersistencyMongo
    from srai_chat.service.service_sceduling import ServiceSceduling

    context.service_chat = ServiceChatTelegram(context, telegram_token, telegram_root_id)
    context.service_persistency = ServicePersistencyMongo(context, connection_string, database_name)
    context.service_openai_chat_gpt = ServiceOpenaiChatGpt(context, openai_api_key)
    context.service_sceduling = ServiceSceduling(context)
    return context


if __name__ == "__main__":
    from srai_chat.service.context_manager import ContextManager

    context_manager = initialize_default()
    # initialize services
    # ServiceSceduling.initialize(bot)
    context_manager.initialize()
    context_manager.service_chat.register_skill(SkillImageTag())
    context_manager.service_chat.register_skill(SkillModeTools())
    context_manager.service_chat.register_mode(ModeChatGpt())
    context_manager.service_chat.mode_default = context_manager.service_chat.dict_mode["ModeChatGpt"]

    # start services
    context_manager.start()
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/southriverai/srai-chat",
    "name": "srai-chat",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": "",
    "keywords": "SRAI,TOOLS",
    "author": "Jaap Oosterbroek",
    "author_email": "jaap.oosterbroek@southriverai.com",
    "download_url": "https://files.pythonhosted.org/packages/8a/79/8eaab85c1db5dce6b994ea57a166cec220f4c411e3808320f2383f0775fc/srai-chat-0.1.5.tar.gz",
    "platform": null,
    "description": "# srai-chat\r\nA chat library frontend for srai services.\r\n\r\n## installation\r\n```\r\npip install srai-chat\r\n```\r\n\r\n## environment\r\nrequires the following environment variables set \\\r\n```\r\n\"TELEGRAM_ROOT_ID\": \"\"\r\n\"TELEGRAM_TOKEN\": \"\"\r\n\"OPENAI_API_KEY\": \"\"\r\n\"MONGODB_CONNECTION_STRING\": \"\r\n\"MONGODB_DATABASE_NAME\": \"\"\r\n```\r\n\r\n## usage example\r\n```\r\nimport os\r\n\r\nfrom srai_chat.skill.mode_chat_gpt import ModeChatGpt\r\nfrom srai_chat.skill.skill_image_tag import SkillImageTag\r\nfrom srai_chat.skill.skill_mode_tools import SkillModeTools\r\n\r\n\r\ndef initialize_default() -> \"ContextManager\":\r\n    context = ContextManager()\r\n    ContextManager._instance = context\r\n    telegram_token = os.environ[\"TELEGRAM_TOKEN\"]\r\n    telegram_root_id = int(os.environ[\"TELEGRAM_ROOT_ID\"])\r\n    openai_api_key = os.environ[\"OPENAI_API_KEY\"]\r\n    connection_string = os.environ[\"MONGODB_CONNECTION_STRING\"]\r\n    database_name = os.environ[\"MONGODB_DATABASE_NAME\"]\r\n    from srai_chat.service.service_chat_telegram import ServiceChatTelegram\r\n    from srai_chat.service.service_openai_chat_gpt import ServiceOpenaiChatGpt\r\n    from srai_chat.service.service_persistency_mongo import ServicePersistencyMongo\r\n    from srai_chat.service.service_sceduling import ServiceSceduling\r\n\r\n    context.service_chat = ServiceChatTelegram(context, telegram_token, telegram_root_id)\r\n    context.service_persistency = ServicePersistencyMongo(context, connection_string, database_name)\r\n    context.service_openai_chat_gpt = ServiceOpenaiChatGpt(context, openai_api_key)\r\n    context.service_sceduling = ServiceSceduling(context)\r\n    return context\r\n\r\n\r\nif __name__ == \"__main__\":\r\n    from srai_chat.service.context_manager import ContextManager\r\n\r\n    context_manager = initialize_default()\r\n    # initialize services\r\n    # ServiceSceduling.initialize(bot)\r\n    context_manager.initialize()\r\n    context_manager.service_chat.register_skill(SkillImageTag())\r\n    context_manager.service_chat.register_skill(SkillModeTools())\r\n    context_manager.service_chat.register_mode(ModeChatGpt())\r\n    context_manager.service_chat.mode_default = context_manager.service_chat.dict_mode[\"ModeChatGpt\"]\r\n\r\n    # start services\r\n    context_manager.start()\r\n```\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A chat library frontend for srai services.",
    "version": "0.1.5",
    "project_urls": {
        "Download": "https://github.com/southriverai/srai-chat/archive/v_01.tar.gz",
        "Homepage": "https://github.com/southriverai/srai-chat"
    },
    "split_keywords": [
        "srai",
        "tools"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8a798eaab85c1db5dce6b994ea57a166cec220f4c411e3808320f2383f0775fc",
                "md5": "805fab66352ea70ef2b801095a190005",
                "sha256": "7e838b2ea7f6ce3aead983c59de99c088cb47898e95747faee6a6265e6bbb347"
            },
            "downloads": -1,
            "filename": "srai-chat-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "805fab66352ea70ef2b801095a190005",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 12463,
            "upload_time": "2024-01-20T14:16:32",
            "upload_time_iso_8601": "2024-01-20T14:16:32.130976Z",
            "url": "https://files.pythonhosted.org/packages/8a/79/8eaab85c1db5dce6b994ea57a166cec220f4c411e3808320f2383f0775fc/srai-chat-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-20 14:16:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "southriverai",
    "github_project": "srai-chat",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "srai-chat"
}
        
Elapsed time: 0.58830s