Skip to content

Commit 98bb450

Browse files
Release v0.1.3 (#68)
* chore: bump version, up compose * Security/cli args (#67) * security: fix cli_args issue, port bindings and redirects * security: add graceful shutdown * security: add DEV/PROD mode * security: add configurable CORS * chore: up .env.example and README.md * security: add gitleaks to pre-commit * security(attachments): limits for attachments * chore(constants): up constants.py * security(attachments): SSRF hardening for redirects * security(auth): changed to secrets.compare_digest, up README.md * security(auth): logs Redaction policy, disable full payload logging * refactor: split big files into smaller ones * refactor * refactor * refactor tests * Update coverage badge for release/v0.1.3 * add openapi to count_tokens, fix loguru * add openapi to count_tokens, fix loguru (#69) * chore: changelog and README.md * bugfix: create workaround for inner function name web_search * bugfix: add function name mapping to all routes * refactor: exceptions * feature: split profiles in docker (DEV/PROD), up README.md * chore: up CHANGELOG.md --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent db83feb commit 98bb450

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+3497
-894
lines changed

.env.example

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,60 @@
1-
#Proxy settings
1+
# ==============================================================================
2+
# gpt2giga — пример конфигурации
3+
# ==============================================================================
4+
# Скопируйте этот файл в .env и укажите реальные значения.
5+
#
6+
# cp .env.example .env
7+
#
8+
# Docker Compose:
9+
# - сервисы в `docker-compose.yaml` включаются через профили `DEV`/`PROD`
10+
# - запуск: `docker compose --profile PROD up -d` (или `--profile DEV`)
11+
#
12+
# ВАЖНО: Для production-среды обязательно:
13+
# - установите GPT2GIGA_MODE=PROD
14+
# - включите GPT2GIGA_ENABLE_API_KEY_AUTH=True и задайте надёжный API ключ
15+
# - установите GIGACHAT_VERIFY_SSL_CERTS=True
16+
# - ограничьте CORS origins вместо wildcard ["*"]
17+
#
18+
# ==============================================================================
19+
# Чеклист по безопасной эксплуатации (production)
20+
# ==============================================================================
21+
# 1. GPT2GIGA_MODE=PROD — отключает /docs, /logs*, подробный вывод
22+
# 2. GPT2GIGA_ENABLE_API_KEY_AUTH=True — включает API-key на всех эндпоинтах
23+
# 3. GPT2GIGA_API_KEY=<сильный секрет> — минимум 32 случайных символа
24+
# 4. GIGACHAT_VERIFY_SSL_CERTS=True — проверяет TLS сертификаты до API GigaChat
25+
# 5. GPT2GIGA_CORS_ALLOW_ORIGINS=["https://your-app.example.com"]
26+
# 6. GPT2GIGA_LOG_REDACT_SENSITIVE=True (по умолчанию) — маскирует секреты в логах
27+
# 7. GPT2GIGA_LOG_LEVEL=INFO — избегайте DEBUG в production
28+
# 8. GPT2GIGA_MAX_REQUEST_BODY_BYTES=10485760 — ограничение тела запроса (10 МБ)
29+
# 9. Запускайте за reverse proxy (nginx/Caddy) с TLS termination
30+
# ==============================================================================
31+
32+
# --- Настройки прокси ---------------------------------------------------------
33+
GPT2GIGA_MODE=PROD
234
GPT2GIGA_HOST=0.0.0.0
3-
GPT2GIGA_PORT=8000
35+
GPT2GIGA_PORT=8090
436
GPT2GIGA_USE_HTTPS=False
5-
GPT2GIGA_LOG_LEVEL=DEBUG
6-
GPT2GIGA_ENABLE_API_KEY_AUTH=False
7-
GPT2GIGA_API_KEY=123
37+
GPT2GIGA_LOG_LEVEL=INFO
38+
GPT2GIGA_ENABLE_API_KEY_AUTH=True
39+
GPT2GIGA_API_KEY="<REPLACE_WITH_STRONG_SECRET>"
40+
41+
# Глобальный лимит размера HTTP-тела запроса (в байтах, по умолчанию 10 МБ).
42+
# GPT2GIGA_MAX_REQUEST_BODY_BYTES=10485760
43+
44+
# CORS списки в формате JSON-массивов:
45+
# В production ограничьте origins конкретными доменами.
46+
# GPT2GIGA_CORS_ALLOW_ORIGINS=["https://your-app.example.com"]
47+
# GPT2GIGA_CORS_ALLOW_METHODS=["GET","POST","OPTIONS"]
48+
# GPT2GIGA_CORS_ALLOW_HEADERS=["authorization","content-type","x-api-key"]
49+
50+
# IP allowlist для /logs* (пусто = без ограничений, недоступно в PROD)
51+
# GPT2GIGA_LOGS_IP_ALLOWLIST=["10.0.0.1"]
852

9-
#GigaChat Settings
53+
# --- Настройки GigaChat -------------------------------------------------------
1054
GIGACHAT_SCOPE=GIGACHAT_API_PERS
11-
GIGACHAT_CREDENTIALS=""
55+
GIGACHAT_CREDENTIALS="<REPLACE_WITH_YOUR_GIGACHAT_CREDENTIALS>"
1256
GIGACHAT_PROFANITY_CHECK=False
1357
GIGACHAT_MODEL=GigaChat-2-Max
14-
GIGACHAT_VERIFY_SSL_CERTS=False
58+
GIGACHAT_VERIFY_SSL_CERTS=True
1559
GIGACHAT_TIMEOUT=70000
1660

.gitleaks.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
title = "gpt2giga gitleaks config"
2+
3+
[extend]
4+
useDefault = true
5+
6+
[allowlist]
7+
description = "Ignore test fixtures with fake secrets"
8+
paths = [
9+
'''(^|/)tests$''',
10+
'''(^|/)tests/''',
11+
]

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ repos:
1111
args:
1212
- --fix=lf
1313
- id: trailing-whitespace
14+
- repo: https://github.com/gitleaks/gitleaks
15+
rev: v8.30.0
16+
hooks:
17+
- id: gitleaks
18+
args:
19+
- --config=.gitleaks.toml
20+
exclude: ^tests/
1421
- repo: local
1522
hooks:
1623
- id: ruff

CHANGELOG.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,48 @@
55
Формат основан на [Keep a Changelog](https://keepachangelog.com/ru/1.0.0/),
66
и проект придерживается [Семантического версионирования](https://semver.org/lang/ru/).
77

8+
## [0.1.3] - 2026-02-16
9+
10+
### Добавлено
11+
- **Режим DEV/PROD**: Добавлена поддержка режимов разработки и продакшена
12+
- **Настраиваемый CORS**: Добавлена возможность конфигурации CORS через переменные окружения
13+
- **Graceful shutdown**: Добавлено корректное завершение работы сервера
14+
- **Gitleaks**: Добавлен gitleaks в pre-commit для проверки секретов
15+
- **OpenAPI для count_tokens**: Добавлена OpenAPI документация для эндпоинта count_tokens
16+
- **Профили в Docker**: Добавлены профили DEV и PROD в `docker-compose.yaml`
17+
18+
### Изменено
19+
- **Рефакторинг структуры**: Разделение больших файлов на модули:
20+
- `gpt2giga/common/` — общие утилиты (exceptions, json_schema, streaming, tools)
21+
- `gpt2giga/models/` — модели конфигурации и безопасности
22+
- `gpt2giga/protocol/attachment/` — обработка вложений
23+
- `gpt2giga/protocol/request/` — трансформация запросов
24+
- `gpt2giga/protocol/response/` — обработка ответов
25+
- **Улучшено логирование**: Политика редактирования логов, отключено логирование полных payload'ов
26+
27+
### Исправлено
28+
- **Безопасность CLI**: Исправлены проблемы с аргументами командной строки
29+
- **Привязка портов**: Исправлены проблемы с привязкой портов и редиректами
30+
- **SSRF защита**: Усилена защита от SSRF в обработке вложений
31+
- **Аутентификация**: Переход на `secrets.compare_digest` для сравнения ключей
32+
- **Лимиты вложений**: Добавлены лимиты для вложений
33+
- **Название внутренних функций**: Исправлена ошибка с внутренней функцией `web_search`, которая могла ломать function_call
34+
35+
## [0.1.2.post1] - 2026-02-13
36+
37+
### Добавлено
38+
- **OpenAPI документация**: Добавлена полная OpenAPI документация для всех эндпоинтов
39+
- **Count tokens для Anthropic**: Добавлен эндпоинт `/v1/messages/count_tokens` для подсчёта токенов в формате Anthropic
40+
- **Пример count_tokens**: Добавлен пример `examples/anthropic/count_tokens.py`
41+
- **Версия при инициализации**: Отображение версии при запуске сервера
42+
43+
### Изменено
44+
- **Path normalizer**: Улучшен нормализатор путей для responses и messages
45+
46+
### Исправлено
47+
- **Ошибка 405**: Исправлена ошибка 405 при некоторых запросах
48+
- **Безопасное чтение запросов**: Улучшена обработка чтения тела запроса
49+
850
## [0.1.2] - 2026-02-11
951

1052
### Добавлено
@@ -122,7 +164,9 @@
122164

123165
---
124166

125-
[0.1.2b1]: https://github.com/ai-forever/gpt2giga/compare/v0.1.1...v0.1.2b1
167+
[0.1.3]: https://github.com/ai-forever/gpt2giga/compare/v0.1.2.post1...v0.1.3
168+
[0.1.2.post1]: https://github.com/ai-forever/gpt2giga/compare/v0.1.2...v0.1.2.post1
169+
[0.1.2]: https://github.com/ai-forever/gpt2giga/compare/v0.1.1...v0.1.2
126170
[0.1.1]: https://github.com/ai-forever/gpt2giga/compare/v0.1.0...v0.1.1
127171
[0.1.0b2]: https://github.com/ai-forever/gpt2giga/compare/v0.1.0b...v0.1.0b2
128172
[0.1.0b]: https://github.com/ai-forever/gpt2giga/compare/v0.0.15.post1...v0.1.0b

CHANGELOG_en.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,48 @@ All notable changes to the gpt2giga project are documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.1.3] - 2026-02-16
9+
10+
### Added
11+
- **DEV/PROD Mode**: Added support for development and production modes
12+
- **Configurable CORS**: Added CORS configuration via environment variables
13+
- **Graceful shutdown**: Added graceful server shutdown handling
14+
- **Gitleaks**: Added gitleaks to pre-commit for secret detection
15+
- **OpenAPI for count_tokens**: Added OpenAPI documentation for count_tokens endpoint
16+
- - **Profiles in Docker**: Added profiles DEV and PROD in `docker-compose.yaml`
17+
18+
### Changed
19+
- **Structure Refactoring**: Split large files into modules:
20+
- `gpt2giga/common/` — common utilities (exceptions, json_schema, streaming, tools)
21+
- `gpt2giga/models/` — configuration and security models
22+
- `gpt2giga/protocol/attachment/` — attachment processing
23+
- `gpt2giga/protocol/request/` — request transformation
24+
- `gpt2giga/protocol/response/` — response processing
25+
- **Improved Logging**: Log redaction policy, disabled full payload logging
26+
27+
### Fixed
28+
- **CLI Security**: Fixed command-line argument issues
29+
- **Port Bindings**: Fixed port binding and redirect issues
30+
- **SSRF Protection**: Hardened SSRF protection in attachment handling
31+
- **Authentication**: Switched to `secrets.compare_digest` for key comparison
32+
- **Attachment Limits**: Added limits for attachments
33+
- **Mapping for reversed tool name**: Fixed bug with function name `web_search`, which can break function_call
34+
35+
## [0.1.2.post1] - 2026-02-13
36+
37+
### Added
38+
- **OpenAPI Documentation**: Added full OpenAPI documentation for all endpoints
39+
- **Count tokens for Anthropic**: Added `/v1/messages/count_tokens` endpoint for token counting in Anthropic format
40+
- **count_tokens Example**: Added `examples/anthropic/count_tokens.py` example
41+
- **Version on Initialize**: Display version on server startup
42+
43+
### Changed
44+
- **Path Normalizer**: Improved path normalizer for responses and messages
45+
46+
### Fixed
47+
- **405 Error**: Fixed 405 error on certain requests
48+
- **Safe Request Reading**: Improved request body reading handling
49+
850
## [0.1.2] - 2026-02-09
951

1052
### Added
@@ -122,7 +164,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
122164

123165
---
124166

125-
[0.1.2b1]: https://github.com/ai-forever/gpt2giga/compare/v0.1.1...v0.1.2b1
167+
[0.1.3]: https://github.com/ai-forever/gpt2giga/compare/v0.1.2.post1...v0.1.3
168+
[0.1.2.post1]: https://github.com/ai-forever/gpt2giga/compare/v0.1.2...v0.1.2.post1
169+
[0.1.2]: https://github.com/ai-forever/gpt2giga/compare/v0.1.1...v0.1.2
126170
[0.1.1]: https://github.com/ai-forever/gpt2giga/compare/v0.1.0...v0.1.1
127171
[0.1.0b2]: https://github.com/ai-forever/gpt2giga/compare/v0.1.0b...v0.1.0b2
128172
[0.1.0b]: https://github.com/ai-forever/gpt2giga/compare/v0.0.15.post1...v0.1.0b

0 commit comments

Comments
 (0)