Skip to main content

RAG client

Project description

rag-plug

Python-клиент для backend RAGPlug API. Поддерживает добавление памяти, семантический поиск и удаление записей по ID (sync/async).

Возможности

  • RagPlug с типизированными моделями ответов.
  • Аутентификация через X-API-Key.
  • Операции в рамках конкретной памяти (memory_name).
  • Готовые CLI-скрипты для быстрого add/search.

Требования

  • Python 3.10+
  • Poetry (рекомендуется)

Установка

poetry install

Или через pip (локальная разработка):

pip install -e .

Конфигурация

Создайте .env в корне проекта:

API_KEY=your_api_key
MEMORY_NAME=your_memory_name

.env добавлен в .gitignore и не должен попадать в репозиторий.

Использование в Python

from ragplug import RagPlug

client = RagPlug(api_key="YOUR_API_KEY", default_memory_name="main")

item = client.add("Paris is the capital of France", metadata={"source": "docs"})
result = client.search("capital of France", top_k=3)
client.delete(item.id)

Async-пример:

import asyncio
from ragplug import RagPlug

async def main():
    client = RagPlug(api_key="YOUR_API_KEY", default_memory_name="main")
    await client.aadd("Async memory text")
    res = await client.asearch("Async memory")
    print(res.results)

asyncio.run(main())

CLI-скрипты

  • scripts/add_memory.py
  • scripts/search.py

Пример запуска:

set -a; source .env; set +a

python scripts/add_memory.py \
  --api-key "$API_KEY" \
  --memory-name "$MEMORY_NAME" \
  --text "Smoke test memory" \
  --metadata '{"source":"scripts"}'

python scripts/search.py \
  --api-key "$API_KEY" \
  --memory-name "$MEMORY_NAME" \
  --query "Smoke test" \
  --top-k 5

Команды разработки

poetry check        # проверка метаданных пакета
poetry build        # сборка sdist + wheel
python -m compileall ragplug scripts

Релиз

CI публикует пакет в PyPI по тегам v*. Тег должен совпадать с версией в pyproject.toml.

Пример:

poetry version patch
git tag v$(poetry version -s)
git push origin --tags

Структура проекта

  • ragplug/client.py: публичный фасад RagPlug.
  • ragplug/types.py: модели ответов и RagPlugError.
  • ragplug/_api.py, _transport.py, _error_handler.py, _validation.py, _response_parser.py: внутренние слои клиента.
  • scripts/: CLI-утилиты.

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

rag_plug-0.1.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rag_plug-0.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file rag_plug-0.1.0.tar.gz.

File metadata

  • Download URL: rag_plug-0.1.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rag_plug-0.1.0.tar.gz
Algorithm Hash digest
SHA256 047586c7c2be1ee09cc7808bb79d17432412d8cb6b0b996fe724a2c937aae212
MD5 3f74d0d3c4606415ed880d45193d6e17
BLAKE2b-256 f6e0735b6e82e4ff8f29b617b8576d1a05a71811f3463850e7b947250e8fe0f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for rag_plug-0.1.0.tar.gz:

Publisher: release.yml on DormintLab/rag-plug

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rag_plug-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rag_plug-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rag_plug-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 51861e5c83feb1334ae1b294cba92b382506f82a829c4da017da73b118f20935
MD5 c717d5f1ee07c0418463b9669fcdb1a5
BLAKE2b-256 d05455e2fcb892cfa9a44063586079c1812f6398e121f66279746abbc1d0aaf7

See more details on using hashes here.

Provenance

The following attestation bundles were made for rag_plug-0.1.0-py3-none-any.whl:

Publisher: release.yml on DormintLab/rag-plug

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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