Skip to main content

Быстрый старт DialogMind SDK

Установка

Вариант 1: Из локальной папки (для разработки)

cd dialogmind_sdk
pip install -e .

Вариант 2: Прямое использование (без установки)

import sys
sys.path.insert(0, '/path/to/dialogmind_sdk')

from dialogmind_sdk import DialogMindClient

Минимальный пример

from dialogmind_sdk import DialogMindClient

# Инициализация
client = DialogMindClient(
    api_key="ваш_api_ключ",
    bot_id="ваш_bot_id"
)

# Получить ответ от AI
response = client.get_ai_response(
    chat_id="123456789",
    message="Привет!"
)

print(response)

Интеграция с Telegram ботом

from dialogmind_sdk import DialogMindClient
from telegram import Update
from telegram.ext import Application, MessageHandler, filters

client = DialogMindClient(
    api_key="ваш_api_ключ",
    bot_id="ваш_bot_id"
)

def handle_message(update: Update, context):
    response = client.process_message_with_faq(
        chat_id=str(update.effective_chat.id),
        user_message=update.message.text,
        username=update.effective_user.username
    )
    update.message.reply_text(response)

app = Application.builder().token("YOUR_TOKEN").build()
app.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, handle_message))
app.run_polling()

Где получить API ключ?

  1. Зайдите на https://dialog-mind.ru
  2. Перейдите в "Интеграция"
  3. Выберите бота
  4. Нажмите "Сгенерировать API ключ"
  5. Скопируйте API ключ и Bot ID

Основные методы

  • handle_external_message(chat_id, user_message, llm_callback, ...) — рекомендуется для внешних ботов со своей LLM. SDK сам проверяет FAQ/RAG в DialogMind, и вызывает вашу LLM только если в базе ничего не найдено.
  • process_message_with_faq(chat_id, user_message, ...) — полный цикл, если LLM на стороне DialogMind (внутренний бот).
  • get_ai_response(chat_id, message) — получить ответ от AI на платформе.
  • search_faq(query) / get_faq_answer(query) — низкоуровневый поиск в FAQ.

Внешний бот со своей LLM (рекомендованный сценарий)

Установите SDK и подключите свою LLM функцией llm_callback. SDK сам:

  1. сохранит входящее сообщение в DialogMind для аналитики,
  2. проверит FAQ/RAG в DialogMind,
  3. вернёт готовый ответ из FAQ (вашу LLM не вызовет),
  4. при miss — вызовет вашу llm_callback(user_message, rag_context),
  5. сохранит ответ бота в DialogMind для аналитики.
from dialogmind_sdk import DialogMindClient

client = DialogMindClient(
    api_key="ваш_api_ключ",
    bot_id="UUID бота из карточки бота в DialogMind",
)

def my_llm(user_message, rag_context=None):
    # Здесь вызывайте свою LLM (OpenAI/YandexGPT/локальную).
    # rag_context — None или список чанков из RAG DialogMind.
    return "Ответ от моей LLM на: " + user_message

reply = client.handle_external_message(
    chat_id="123456789",
    user_message="Как оплатить?",
    llm_callback=my_llm,
)
print(reply)

Подробнее в DEVELOPER_GUIDE.md

Metadata

Release files for dialogmind-sdk 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dialogmind-sdk 1.1.0
File Size Uploaded Provenance Actions
dialogmind_sdk-1.1.0.tar.gz 14.6 kB Without provenance Details for dialogmind_sdk-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dialogmind-sdk 1.1.0
File Interpreter ABI Platform Actions
dialogmind_sdk-1.1.0-py3-none-any.whl Python 3 none any Details for dialogmind_sdk-1.1.0-py3-none-any.whl

Total release size: 32.2 kB

Release files / dialogmind_sdk-1.1.0.tar.gz

Download URL dialogmind_sdk-1.1.0.tar.gz
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
612f44126f6c87264f09d8bf12a5d2ef56e468cb8f9110c186923c589faa166d
BLAKE2b-256 checksum
How to use checksums
3487d0e20f1e1bdba5cb6d7b3598f62eb9e3b924f9cc8b3687247288bebeb002
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / dialogmind_sdk-1.1.0-py3-none-any.whl

Download URL dialogmind_sdk-1.1.0-py3-none-any.whl
Size 17.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f6556b38a05c836dc60cb1667f9aff981444295168efe97896bc4d94fdcd1efb
BLAKE2b-256 checksum
How to use checksums
8e8f1975b2c12104e77a82403b9fed393926874915bff602e3dc9e5404c20581
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for dialogmind-sdk 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page