Metadata-Version: 2.1
Name: srai-chat
Version: 0.1.3
Summary: A chat library frontend for srai services.
Home-page: https://github.com/southriverai/srai-chat
Author: Jaap Oosterbroek
Author-email: jaap.oosterbroek@southriverai.com
License: MIT
Download-URL: https://github.com/southriverai/srai-chat/archive/v_01.tar.gz
Keywords: SRAI,TOOLS
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.5
Description-Content-Type: text/markdown
License-File: LICENSE

# 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()
```

