-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpyproject.toml
More file actions
453 lines (416 loc) · 14.4 KB
/
pyproject.toml
File metadata and controls
453 lines (416 loc) · 14.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
[project]
name = "llm-interactive-proxy"
version = "0.1.0"
description = "The swiss-army knife for LLM-powered applications. A universal proxy that seamlessly translates between OpenAI, Anthropic, and Gemini APIs while routing to any provider you choose. Override hardcoded models, prevent infinite loops, rotate API keys, capture and debug traffic, and automatically steer conversations away from trouble. Perfect for making any AI client work with any model, anywhere."
authors = [
{ name = "Mateusz B.", email = "llm.interactive.proxy@matdev83.anonaddy.com" },
]
dependencies = [
"fastapi",
"uvicorn[standard]",
"httpx[http2]",
"python-dotenv",
"pydantic>=2",
"openai==1.84.0",
"tomli",
"typer",
"rich",
"llm-accounting",
"tiktoken",
"google-genai",
"anthropic",
"structlog",
"pyyaml",
"jsonschema>=4.19.0",
"google-auth>=2.27.0",
"json-repair",
"ijson",
"watchdog",
"pytz",
"pytest-asyncio==0.23.7",
"pytest-xdist==3.6.1",
"cbor2>=5.6.0",
"authlib>=1.3.0",
"argon2-cffi>=23.1.0",
"aiosqlite>=0.19.0",
"python-multipart>=0.0.6",
"ping3>=4.0.0",
"sqlmodel>=0.0.22",
"alembic>=1.13.0",
"greenlet>=3.0.0",
"cachetools>=5.3.0",
"desktop-notifier",
"websockets>=12.0",
]
requires-python = ">=3.10"
readme = "README.md"
# License per PEP 621: string SPDX identifier
license = "AGPL-3.0-or-later"
keywords = ["llm", "proxy", "interactive", "api", "ai", "chatgpt", "openai", "gemini", "openrouter"]
urls = { Home = "https://github.com/matdev83/llm-interactive-proxy" }
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Internet :: Proxy Servers",
"Operating System :: OS Independent", # Common classifier
]
[project.optional-dependencies]
oauth = [
"llm-proxy-oauth-connectors",
]
dev = [
# Test stack (pin to match local green runs)
"pytest==8.3.2",
"pytest-asyncio==0.23.7",
"pytest-cov==5.0.0",
"pytest-xdist==3.6.1",
"pytest-httpx==0.30.0",
"pytest-mock==3.14.0",
"freezegun==1.5.1",
# Linters/formatters
"ruff==0.5.6",
"black==24.8.0",
"requests",
"bandit",
"mdformat",
"pymarkdownlnt",
"types-PyYAML==6.0.12.20240808",
"types-jsonschema==4.23.0.20240813",
"types-colorama==0.4.15.20240311",
"types-cachetools>=5.3.0",
"respx",
"dependency-injector",
"vulture",
"pytest-snapshot==0.9.0",
"mypy==1.10.0",
"hypothesis==6.112.1",
"xenon",
"radon",
"types-pytz",
"pytest-testmon",
"pytest-timeout",
]
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
[tool.setuptools]
package-dir = {"" = "src"}
[tool.pytest.ini_options]
testpaths = ["tests"]
norecursedirs = ["tmp.*", "build", "benchmark", "_site", "OLD", "dev/thrdparty"]
# JUnit XML generation is conditional - only when CI env var is set or explicitly requested
# This reduces I/O overhead during local development
# Use --junit-xml=test-results.xml to enable explicitly
# Using loadfile distribution - more efficient for test suites with file-level fixtures
addopts = "--asyncio-mode=auto -W ignore --max-worker-restart=50 -n 4 --dist=loadfile --timeout=400 --timeout-method=thread -r fE"
asyncio_mode = "auto"
junit_duration_report = "call"
log_cli_level = "WARNING"
# Logging configuration
# Reduced from DEBUG to WARNING to minimize disk I/O overhead during test execution
# Use --log-cli-level=DEBUG or --log-file-level=DEBUG when debugging is needed
log_file = "./var/logs/pytest.log"
log_file_level = "WARNING"
log_file_format = "%(asctime)s [%(levelname)8s] %(name)s:%(lineno)s %(message)s"
log_file_date_format = "%Y-%m-%d %H:%M:%S"
# Filter warnings
filterwarnings = [
"ignore::UserWarning:pydantic._internal._fields",
"ignore::DeprecationWarning",
"ignore:coroutine 'AsyncMockMixin\\._execute_mock_call' was never awaited:RuntimeWarning",
"ignore:DI CONTAINER VIOLATIONS DETECTED:UserWarning",
"ignore::ResourceWarning",
"ignore::Warning",
# Targeted upstream/runtime warnings (Windows + websockets)
"ignore:unclosed event loop <ProactorEventLoop.*:ResourceWarning",
"ignore:.*websockets\\.legacy is deprecated.*:DeprecationWarning",
"ignore:.*websockets\\.server\\.WebSocketServerProtocol is deprecated.*:DeprecationWarning",
"ignore:.*Construction of dict of EntryPoints is deprecated.*:DeprecationWarning",
"ignore:unclosed file <_io\\..*:ResourceWarning",
# Pydantic V2 deprecation warnings from external library
"ignore:Support for class-based.*:pydantic.warnings.PydanticDeprecatedSince20",
]
# To run integration tests, use: pytest -m integration
# To run command tests, use: pytest -m command
# To run session tests, use: pytest -m session
# To run backend tests, use: pytest -m backend
# To run DI tests, use: pytest -m di
# To run tests without global mock, use: pytest -m no_global_mock
# To run slow tests, use: pytest -m slow
# To run codex tests (development only): pytest -m codex
markers = [
"integration: marks tests as integration tests (deselect with '-m \"not integration\"')",
"unit: marks tests as unit tests",
"network: marks tests that require network access (deselect with '-m \"not network\"')",
"regression: marks tests as regression tests",
"backends: marks tests that need specific backends to be initialized",
"backend: marks tests that need a specific backend to be initialized",
"custom_backend_mock: marks tests that use custom backend mocking strategies",
"httpx_mock: marks tests that use httpx mocking (provided by pytest-httpx plugin)",
"no_global_mock: marks tests that should not use global mocking",
"command: marks tests related to command handling",
"session: marks tests related to session state management",
"di: marks tests that use the dependency injection architecture",
"loop_detection: marks tests related to loop detection",
"multimodal: marks tests related to multimodal content",
"quality: Tests that check code quality (linting, formatting)",
"slow: marks tests that are slow to run and should be excluded by default",
"codex: marks tests for Codex backend (included by default)",
"testmon_cache: marks tests that should disable testmon cache",
"real_time: marks tests that legitimately require real system wall-clock time (requires reason parameter)",
"performance: marks tests as performance benchmarks (excluded by default, use with -m performance)",
]
[tool.mdformat]
# Disable automatic line wrapping for Markdown files to match CI expectations
wrap = 0
[tool.pylint.messages_control]
disable = ["C0301", "C0303", "C0114", "C0116"]
[tool.ruff]
# Target src and tests directories with Python files
src = ["src", "tests"]
# Exclude common directories
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
".pytest_cache",
"__pycache__",
"dev/thrdparty",
]
# Same as Black.
line-length = 88
indent-width = 4
# Assume Python 3.10+
target-version = "py310"
[tool.ruff.lint]
# Enable only rules that catch real issues, not formatting
select = [
# Pyflakes - catches unused imports, undefined names, etc.
"F",
# pycodestyle errors - only serious runtime/syntax errors
"E9", # Runtime errors
# isort - import sorting issues
"I",
# pep8-naming - naming convention violations
"N",
# pyupgrade - outdated syntax
"UP",
# flake8-bugbear - likely bugs
"B",
# flake8-simplify - code simplification
"SIM",
# flake8-comprehensions - list/dict/set comprehension issues
"C4",
# flake8-pie - unnecessary code
"PIE",
# mccabe - cyclomatic complexity checking
"C90",
# Ruff-specific rules
"RUF",
]
# Ignore formatting and whitespace-related rules
ignore = [
# Pycodestyle whitespace and newline rules
"E1", "E2", "E3",
"W1", "W2", "W3",
# Pydocstyle
"D",
# Specific formatting rules to ignore
"E501", # Line too long
"E701", # Multiple statements on one line
"E702", # Multiple statements on one line (semicolon)
"E711", # Comparison to None should be 'is' or 'is not'
"E712", # Comparison to True should be 'is' or 'is not'
"E713", # Test for membership should be 'not in'
"E714", # Test for object identity should be 'is not'
"COM812", # Missing trailing comma
"COM819", # Trailing comma prohibited
"Q000", # Double quotes found but single quotes preferred
# Ignore some overly strict rules
"B008", # Do not perform function calls in argument defaults
"B904", # Within an except clause, raise exceptions with raise ... from err
"SIM108", # Use ternary operator instead of if-else-block
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"N806", # Variable in function should be lowercase (for test constants)
]
# Allow fix for all enabled rules (except those in unfixable)
fixable = ["ALL"]
unfixable = []
# Allow unused variables when underscore-prefixed
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
[tool.ruff.lint.mccabe]
# Maximum cyclomatic complexity threshold (Requirement 4.2)
max-complexity = 50
[tool.ruff.lint.per-file-ignores]
# Pre-existing complexity violations outside DI refactoring scope.
# These files exceed the C901 complexity threshold and are documented as technical debt.
# Per tasks.md requirement 4.2, complexity gates only apply to DI-scope files.
# Tracking issue: Consider refactoring these files in dedicated efforts.
"src/anthropic_converters.py" = ["C901"] # openai_stream_to_anthropic_stream (58)
"src/connectors/gemini_base/streaming_executor.py" = ["C901"] # _stream_generator (65)
"src/connectors/openai_codex.py" = ["C901"] # _call_codex_responses_api (72)
"src/connectors/openai.py" = ["C901"] # _handle_streaming_response (51)
"src/core/app/controllers/chat_controller.py" = ["C901"] # handle_chat_completion (72)
"src/core/auth/sso/web_interface.py" = ["C901"] # create_sso_router (66)
"src/core/domain/translators/gemini/request.py" = ["C901"] # from_domain_to_gemini_request (79)
"src/core/domain/translators/responses/streaming.py" = ["C901"] # responses_to_domain_stream_chunk (71)
"src/core/services/backend_request_manager_service.py" = ["C901"] # _process_streaming_response (101)
"src/core/transport/fastapi/response_adapters.py" = ["C901"] # to_fastapi_streaming_response (164), _streaming_adapter (160)
"src/core/app/controllers/responses_controller.py" = ["C901"] # handle_responses_request (54)
"src/core/app/stages/test_stages.py" = ["C901"] # _register_mock_backend_service (52)
"src/core/services/reasoning_config_applicator.py" = ["C901"] # apply (52)
"src/core/app/controllers/models_controller.py" = ["C901"] # _list_models_impl (52)
[tool.ruff.format]
# Disable formatting entirely - we only want linting
skip-magic-trailing-comma = true
[tool.mypy]
mypy_path = "src"
python_version = "3.10"
warn_return_any = true
warn_unused_configs = true
exclude = ["dev/"]
check_untyped_defs = false
[[tool.mypy.overrides]]
module = ["google.genai"]
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = ["setuptools"]
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = ["ping3"]
ignore_missing_imports = true
ignore_errors = true
[[tool.mypy.overrides]]
module = ["cachetools"]
ignore_missing_imports = true
# Performance optimizations
# Enable incremental mode with cache
# Reduce strictness for performance in tests
strict = false
[tool.coverage.run]
source = ["src"]
omit = [
"*/tests/*",
"*/test_*",
"*/conftest.py",
"*/__pycache__/*",
"*/venv/*",
"*/.venv/*",
]
[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"def __repr__",
"raise AssertionError",
"raise NotImplementedError",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"@abstractmethod",
]
precision = 2
show_missing = true
[tool.coverage.xml]
output = "coverage.xml"
[tool.vulture]
# Vulture configuration for dead code detection suppressions
min_confidence = 80
verbose = false
sort_by_size = true
ignore_names = [
# Names intentionally present but may appear unused in static scans
"HEALTH_CHECK_SUPPORTED",
"enable_health_check",
"disable_health_check",
"internal_health",
"chat_completions_v1",
"chat_completions_v2",
"gemini_generate_content",
"gemini_stream_generate_content",
"anthropic_health",
"OBJECT_TYPE_LIST",
"OBJECT_TYPE_MODEL",
"OBJECT_TYPE_CHAT_COMPLETION",
"OBJECT_TYPE_CHAT_COMPLETION_CHUNK",
"OBJECT_TYPE_MESSAGE",
"FIELD_OBJECT",
"FIELD_ID",
"FIELD_MODEL",
"FIELD_CONTENT",
"FIELD_ROLE",
"FIELD_CHOICES",
"FIELD_MESSAGE",
"FIELD_DELTA",
"FIELD_FINISH_REASON",
"FIELD_STOP_REASON",
"FIELD_TYPE",
"FIELD_NAME",
"FIELD_TEXT",
"FIELD_PARTS",
"FIELD_INLINE_DATA",
"FIELD_MIME_TYPE",
"FIELD_DATA",
"FIELD_SOURCE",
"FIELD_USAGE",
"FIELD_ERROR",
"ROLE_USER",
"ROLE_ASSISTANT",
"ROLE_SYSTEM",
"ROLE_MODEL",
"FINISH_REASON_STOP",
"FINISH_REASON_LENGTH",
"FINISH_REASON_TOOL_CALLS",
"FINISH_REASON_END_TURN",
"FINISH_REASON_MAX_TOKENS",
"FINISH_REASON_STOP_SEQUENCE",
"FINISH_REASON_ERROR",
"TOOL_CALL_TYPE_FUNCTION",
"MODEL_PREFIX_OPENAI",
"MODEL_PREFIX_ANTHROPIC",
"MODEL_PREFIX_GEMINI",
"MODEL_PREFIX_OPENROUTER",
"BACKEND_OPENAI",
"BACKEND_ANTHROPIC",
"BACKEND_GEMINI",
"BACKEND_OPENROUTER",
"BACKEND_QWEN_OAUTH",
"BACKEND_ZAI",
"BACKEND_DISPLAY_OPENAI",
"BACKEND_DISPLAY_ANTHROPIC",
"BACKEND_DISPLAY_GEMINI",
"BACKEND_DISPLAY_OPENROUTER",
"build_development_app",
"build_test_app",
"validate_yaml_against_schema",
"validate_static_yaml_configs",
"_load_yaml_file",
"_load_yaml_schema",
# Kept for API compatibility in _normalize_tool_arguments
"context_element",
"tool_name"
]
[tool.testmon]
run_variant_expression = "','.join(sorted(str(v) for v in [sys.version_info[:2], sys.platform]))"
historian = "git"