Skip to main content

A chat library frontend for srai services.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

srai-chat-0.1.5.tar.gz (12.5 kB view details)

Uploaded Source

File details

Details for the file srai-chat-0.1.5.tar.gz.

File metadata

  • Download URL: srai-chat-0.1.5.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.0

File hashes

Hashes for srai-chat-0.1.5.tar.gz
Algorithm Hash digest
SHA256 7e838b2ea7f6ce3aead983c59de99c088cb47898e95747faee6a6265e6bbb347
MD5 805fab66352ea70ef2b801095a190005
BLAKE2b-256 8a798eaab85c1db5dce6b994ea57a166cec220f4c411e3808320f2383f0775fc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page