Skip to content
Open
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@
.DS_Store
Thumbs.db

# Python cache
__pycache__/
*.pyc
*.pyo

# Debug logs
debug_logs/

# Env
.env
.env.local
kiro_creds.json

# Notes
kirogate-progress.md
13 changes: 9 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ services:
container_name: kirogate
restart: unless-stopped
ports:
- "8833:8000"
- "8000:8000"
environment:
# 必填: 代理服务器密码
Expand All @@ -22,7 +23,7 @@ services:
- REFRESH_TOKEN=${REFRESH_TOKEN:-}

# 方式二: 挂载凭证文件 (见下方 volumes)
- KIRO_CREDS_FILE=${KIRO_CREDS_FILE:-}
- KIRO_CREDS_FILE=/app/credentials.json

# 可选配置
- PROFILE_ARN=${PROFILE_ARN:-}
Expand Down Expand Up @@ -56,12 +57,16 @@ services:
- STATIC_ASSETS_PROXY_ENABLED=${STATIC_ASSETS_PROXY_ENABLED:-true}
- STATIC_ASSETS_PROXY_BASE=${STATIC_ASSETS_PROXY_BASE:-https://proxy.jhun.edu.kg}

# 自动分片配置(长文档处理)
- AUTO_CHUNKING_ENABLED=${AUTO_CHUNKING_ENABLED:-true}
- AUTO_CHUNK_THRESHOLD=${AUTO_CHUNK_THRESHOLD:-150000}
- CHUNK_MAX_CHARS=${CHUNK_MAX_CHARS:-100000}

volumes:
# 持久化统计数据(使用命名卷,自动处理权限)
- kirogate_data:/app/data
# 如果使用凭证文件,取消下面的注释
# - ~/.aws/sso/cache/kiro-auth-token.json:/app/credentials.json:ro
# 然后设置 KIRO_CREDS_FILE=/app/credentials.json
# IDC 凭证文件
- ./kiro_creds.json:/app/credentials.json:ro

healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"]
Expand Down
2 changes: 2 additions & 0 deletions kiro_gateway/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
# Exceptions
from kiro_gateway.exceptions import (
validation_exception_handler,
http_exception_handler,
sanitize_validation_errors,
)

Expand Down Expand Up @@ -162,5 +163,6 @@

# Exceptions
"validation_exception_handler",
"http_exception_handler",
"sanitize_validation_errors",
]
39 changes: 36 additions & 3 deletions kiro_gateway/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ class Settings(BaseSettings):
# 超过此限制的描述将被移至 system prompt
tool_description_max_length: int = Field(default=10000, alias="TOOL_DESCRIPTION_MAX_LENGTH")

# 输出限制警告设置
inject_output_limit_warning: bool = Field(default=False, alias="INJECT_OUTPUT_LIMIT_WARNING")
output_token_limit: int = Field(default=6000, alias="OUTPUT_TOKEN_LIMIT")

# ==================================================================================================
# 日志设置
# ==================================================================================================
Expand Down Expand Up @@ -475,14 +479,14 @@ def validate_security_defaults(self) -> "Settings":
# ==================================================================================================

# 慢模型列表 - 这些模型需要更长的超时时间
SLOW_MODELS: frozenset = frozenset({
SLOW_MODELS: frozenset[str] = frozenset({
"claude-opus-4-6",
"claude-opus-4-6-thinking",
"claude-opus-4-5",
"claude-opus-4-5-20251101",
"claude-3-opus",
"claude-3-opus-20240229",
})


# ==================================================================================================
# Kiro API URL Templates
# ==================================================================================================
Expand All @@ -498,6 +502,11 @@ def validate_security_defaults(self) -> "Settings":

# External model names (OpenAI compatible) -> Kiro internal ID
MODEL_MAPPING: Dict[str, str] = {
# Claude Opus 4.6 - Top tier model
"claude-opus-4-6": "claude-opus-4.6",
"claude-opus-4-6-20250601": "claude-opus-4.6",
"claude-opus-4-6-thinking": "claude-opus-4.6",

# Claude Opus 4.5 - Top tier model
"claude-opus-4-5": "claude-opus-4.5",
"claude-opus-4-5-20251101": "claude-opus-4.5",
Expand All @@ -507,6 +516,11 @@ def validate_security_defaults(self) -> "Settings":
"claude-haiku-4-5-20251001": "claude-haiku-4.5",
"claude-haiku-4.5": "claude-haiku-4.5",

# Claude Sonnet 4.6 - Enhanced model
"claude-sonnet-4-6": "claude-sonnet-4.6",
"claude-sonnet-4-6-20250601": "claude-sonnet-4.6",
"claude-sonnet-4-6-thinking": "claude-sonnet-4.6",

# Claude Sonnet 4.5 - Enhanced model
"claude-sonnet-4-5": "CLAUDE_SONNET_4_5_20250929_V1_0",
"claude-sonnet-4-5-20250929": "CLAUDE_SONNET_4_5_20250929_V1_0",
Expand All @@ -524,14 +538,33 @@ def validate_security_defaults(self) -> "Settings":

# Available models list for /v1/models endpoint
AVAILABLE_MODELS: List[str] = [
# Claude Opus 4.6
"claude-opus-4-6",
"claude-opus-4-6-20250601",
"claude-opus-4-6-thinking",

# Claude Opus 4.5
"claude-opus-4-5",
"claude-opus-4-5-20251101",

# Claude Haiku 4.5
"claude-haiku-4-5",
"claude-haiku-4-5-20251001",

# Claude Sonnet 4.6
"claude-sonnet-4-6",
"claude-sonnet-4-6-20250601",
"claude-sonnet-4-6-thinking",

# Claude Sonnet 4.5
"claude-sonnet-4-5",
"claude-sonnet-4-5-20250929",

# Claude Sonnet 4
"claude-sonnet-4",
"claude-sonnet-4-20250514",

# Claude 3.7
"claude-3-7-sonnet-20250219",
]

Expand Down
Loading