sdk/README.md
mrmamongo 38e074704c docs: fix install command with extra-index-url, bump to 0.1.2
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-20 12:36:38 +03:00

73 lines
1.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ErGPT SDK
Python SDK для работы с API ErGPT.
## Документация
- [KB_API_Guide.md](KB_API_Guide.md) — руководство по Knowledge Base API с curl-примерами
- [examples.py](examples.py) — примеры использования SDK на Python
## Установка
## Установка
```bash
pip install --extra-index-url https://git.infra.er-gpt.ru/api/packages/ergpt/pypi/simple sdk
```
## Быстрый старт
### Синхронный клиент
```python
from ergpt.kb import KnowledgeBaseClient
client = KnowledgeBaseClient(api_token="your_token")
# Создать базу знаний
kb = client.create_knowledge_base(
name="Моя база",
description="Описание",
chunk_size=1000,
chunk_overlap=200,
)
# Загрузить документ
with open("doc.pdf", "rb") as f:
doc = client.upload_document(kb.id, f)
# Поиск
results = client.search(kb.id, "мой запрос", limit=5)
for r in results.chunks:
print(r.filename, r.chunks[0].score)
```
### Асинхронный клиент
```python
import asyncio
from ergpt.kb import AsyncKnowledgeBaseClient
async def main():
async with AsyncKnowledgeBaseClient(api_token="your_token") as client:
kb = await client.create_knowledge_base(...)
results = await client.search(kb.id, "запрос")
asyncio.run(main())
```
## Документация
См. [KB_API_Guide.md](KB_API_Guide.md) — подробное руководство по Knowledge Base API.
## Структура пакета
- `ergpt.kb` — Knowledge Base API (базы знаний, документы, поиск)
В будущем:
- `ergpt.chat` — Chat API
- `ergpt.users` — Users API
## Лицензия
MIT