nya-proxy 0.3.2__tar.gz → 0.3.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. {nya_proxy-0.3.2/nya_proxy.egg-info → nya_proxy-0.3.4}/PKG-INFO +5 -2
  2. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/README.md +3 -0
  3. nya_proxy-0.3.4/nya/_version.py +1 -0
  4. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/config/manager.py +3 -1
  5. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/core/proxy.py +1 -3
  6. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/core/streaming.py +4 -0
  7. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/server/app.py +22 -7
  8. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/utils/header.py +1 -2
  9. {nya_proxy-0.3.2 → nya_proxy-0.3.4/nya_proxy.egg-info}/PKG-INFO +5 -2
  10. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya_proxy.egg-info/requires.txt +1 -1
  11. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/pyproject.toml +2 -2
  12. nya_proxy-0.3.2/nya/_version.py +0 -1
  13. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/LICENSE +0 -0
  14. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/__init__.py +0 -0
  15. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/common/__init__.py +0 -0
  16. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/common/constants.py +0 -0
  17. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/common/exceptions.py +0 -0
  18. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/common/models.py +0 -0
  19. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/config/__init__.py +0 -0
  20. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/config.yaml +0 -0
  21. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/core/__init__.py +0 -0
  22. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/core/handler.py +0 -0
  23. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/core/queue.py +0 -0
  24. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/core/request.py +0 -0
  25. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/dashboard/__init__.py +0 -0
  26. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/dashboard/api.py +0 -0
  27. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/html/favicon.ico +0 -0
  28. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/html/index.html +0 -0
  29. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/html/login.html +0 -0
  30. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/html/static/css/styles.css +0 -0
  31. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/html/static/js/dashboard.js +0 -0
  32. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/html/static/logo.svg +0 -0
  33. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/schema.json +0 -0
  34. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/server/__init__.py +0 -0
  35. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/server/auth.py +0 -0
  36. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/services/__init__.py +0 -0
  37. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/services/control.py +0 -0
  38. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/services/lb.py +0 -0
  39. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/services/limit.py +0 -0
  40. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/services/metrics.py +0 -0
  41. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/utils/__init__.py +0 -0
  42. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya/utils/helper.py +0 -0
  43. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya_proxy.egg-info/SOURCES.txt +0 -0
  44. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya_proxy.egg-info/dependency_links.txt +0 -0
  45. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya_proxy.egg-info/entry_points.txt +0 -0
  46. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/nya_proxy.egg-info/top_level.txt +0 -0
  47. {nya_proxy-0.3.2 → nya_proxy-0.3.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nya-proxy
3
- Version: 0.3.2
3
+ Version: 0.3.4
4
4
  Summary: A lightweight, flexible API proxy with dynamic token rotation, load balancing, and rate limiting capabilities.
5
5
  Author-email: "Nya Foundation Team (k3scat)" <k3scat@gmail.com>
6
6
  License-Expression: MIT
@@ -27,7 +27,7 @@ Requires-Dist: brotli>=1.0.9
27
27
  Requires-Dist: jmespath>=1.0.1
28
28
  Requires-Dist: orjson<4,>=3.10
29
29
  Requires-Dist: loguru>=0.7.0
30
- Requires-Dist: nekoconf[remote,schema,server]==1.1.1
30
+ Requires-Dist: nekoconf[remote,schema,server]==1.1.2
31
31
  Provides-Extra: dev
32
32
  Requires-Dist: pytest>=7.0.0; extra == "dev"
33
33
  Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
@@ -65,6 +65,9 @@ Dynamic: license-file
65
65
 
66
66
  ## 🌈 Introduction
67
67
 
68
+ > [!WARNING]
69
+ > This project is currently under active development. Documentation may not reflect the latest changes. If you encounter unexpected behavior, please consider using a previous stable version or report issues on our GitHub repository.
70
+
68
71
  NyaProxy acts like a smart, central manager for accessing various online services (APIs) – think AI tools (like OpenAI, Gemini, Anthropic), image generators, or almost any web service that uses access keys. It helps you use these services more reliably, efficiently, and securely.
69
72
 
70
73
  Here's how NyaProxy can help:
@@ -23,6 +23,9 @@
23
23
 
24
24
  ## 🌈 Introduction
25
25
 
26
+ > [!WARNING]
27
+ > This project is currently under active development. Documentation may not reflect the latest changes. If you encounter unexpected behavior, please consider using a previous stable version or report issues on our GitHub repository.
28
+
26
29
  NyaProxy acts like a smart, central manager for accessing various online services (APIs) – think AI tools (like OpenAI, Gemini, Anthropic), image generators, or almost any web service that uses access keys. It helps you use these services more reliably, efficiently, and securely.
27
30
 
28
31
  Here's how NyaProxy can help:
@@ -0,0 +1 @@
1
+ __version__ = "0.3.4"
@@ -100,14 +100,15 @@ class ConfigManager:
100
100
  storage: Union[FileStorageBackend, RemoteStorageBackend, None] = None
101
101
 
102
102
  if self.remote_url:
103
+ logger.info(f"Using remote configuration server: {self.remote_url}")
103
104
  storage = RemoteStorageBackend(
104
105
  remote_url=self.remote_url,
105
106
  api_key=self.remote_api_key,
106
107
  app_name=self.remote_app_name or "default",
107
108
  logger=logger,
108
109
  )
109
-
110
110
  else:
111
+ logger.info(f"Using local configuration file: {self.config_path}")
111
112
  storage = FileStorageBackend(config_path=self.config_path, logger=logger)
112
113
 
113
114
  storage.set_change_callback(self.callback)
@@ -122,6 +123,7 @@ class ConfigManager:
122
123
  schema_path=self.schema_path,
123
124
  logger=logger,
124
125
  env_override_enabled=True,
126
+ event_emission_enabled=True,
125
127
  env_prefix="NYA",
126
128
  )
127
129
 
@@ -78,9 +78,7 @@ class NyaProxyCore:
78
78
  # Validate and prepare request
79
79
  self.handler.prepare_request(request)
80
80
  if not request.api_name:
81
- return self._error_response(
82
- request, "NyaProxy: Unknown API endpoint", 404
83
- )
81
+ return self._error_response("NyaProxy: Unknown API endpoint", 404)
84
82
 
85
83
  # If rate limit does not apply, get a random key and process immediately
86
84
  if not request._rate_limited:
@@ -74,6 +74,10 @@ class StreamingHandler:
74
74
  Processed headers for streaming
75
75
  """
76
76
 
77
+ for header in ["content-encoding", "content-length", "accept-encoding"]:
78
+ if header in headers:
79
+ del headers[header]
80
+
77
81
  # Set SSE-specific headers according to standards
78
82
  headers["cache-control"] = "no-cache, no-transform"
79
83
  headers["connection"] = "keep-alive"
@@ -2,18 +2,22 @@
2
2
  """
3
3
  NyaProxy - A simple low-level API proxy with dynamic token rotation.
4
4
  """
5
- import argparse
6
- import contextlib
7
- import logging
5
+
6
+
8
7
  import os
9
8
  import sys
10
9
 
10
+ import logging
11
11
  import uvicorn
12
- from fastapi import FastAPI, Request, Response
12
+ import argparse
13
+ import traceback
14
+ import contextlib
15
+
13
16
  from loguru import logger
17
+ from fastapi import FastAPI, Request, Response
18
+ from starlette.responses import JSONResponse
14
19
  from starlette.middleware.base import BaseHTTPMiddleware
15
20
  from starlette.middleware.cors import CORSMiddleware
16
- from starlette.responses import JSONResponse
17
21
 
18
22
  from .. import __version__
19
23
  from ..common.constants import (
@@ -146,7 +150,12 @@ class NyaProxyApp:
146
150
  logger.info("Starting NyaProxy...")
147
151
  await self.init_nya_services()
148
152
  yield
149
- await self.shutdown()
153
+ try:
154
+ await self.shutdown()
155
+ except Exception as e:
156
+ logger.error(
157
+ f"Error during shutdown: {e} traceback: {traceback.format_exc()}"
158
+ )
150
159
 
151
160
  def setup_routes(self, app):
152
161
  """
@@ -396,11 +405,17 @@ class NyaProxyApp:
396
405
  """
397
406
  Clean up resources on shutdown.
398
407
  """
408
+
399
409
  logger.info("Shutting down NyaProxy")
410
+ logger.info(f"Shutdown stack trace: {''.join(traceback.format_stack())}")
400
411
 
401
412
  # Close proxy handler client
402
413
  if self.core and hasattr(self.core, "request_executor"):
403
- await self.core.request_executor.close()
414
+ try:
415
+ await self.core.request_executor.close()
416
+ logger.info("Request executor closed successfully")
417
+ except Exception as e:
418
+ logger.error(f"Error closing request executor: {e}")
404
419
 
405
420
 
406
421
  def parse_args():
@@ -128,8 +128,7 @@ class HeaderUtils:
128
128
  final_headers[header_name] = header_value
129
129
 
130
130
  # patch accept-encoding header to avoid issues with httpx
131
- if header_name.lower() == "accept-encoding":
132
- final_headers[header_name] = "identity"
131
+ final_headers["accept-encoding"] = "identity"
133
132
 
134
133
  return final_headers
135
134
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nya-proxy
3
- Version: 0.3.2
3
+ Version: 0.3.4
4
4
  Summary: A lightweight, flexible API proxy with dynamic token rotation, load balancing, and rate limiting capabilities.
5
5
  Author-email: "Nya Foundation Team (k3scat)" <k3scat@gmail.com>
6
6
  License-Expression: MIT
@@ -27,7 +27,7 @@ Requires-Dist: brotli>=1.0.9
27
27
  Requires-Dist: jmespath>=1.0.1
28
28
  Requires-Dist: orjson<4,>=3.10
29
29
  Requires-Dist: loguru>=0.7.0
30
- Requires-Dist: nekoconf[remote,schema,server]==1.1.1
30
+ Requires-Dist: nekoconf[remote,schema,server]==1.1.2
31
31
  Provides-Extra: dev
32
32
  Requires-Dist: pytest>=7.0.0; extra == "dev"
33
33
  Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
@@ -65,6 +65,9 @@ Dynamic: license-file
65
65
 
66
66
  ## 🌈 Introduction
67
67
 
68
+ > [!WARNING]
69
+ > This project is currently under active development. Documentation may not reflect the latest changes. If you encounter unexpected behavior, please consider using a previous stable version or report issues on our GitHub repository.
70
+
68
71
  NyaProxy acts like a smart, central manager for accessing various online services (APIs) – think AI tools (like OpenAI, Gemini, Anthropic), image generators, or almost any web service that uses access keys. It helps you use these services more reliably, efficiently, and securely.
69
72
 
70
73
  Here's how NyaProxy can help:
@@ -9,7 +9,7 @@ brotli>=1.0.9
9
9
  jmespath>=1.0.1
10
10
  orjson<4,>=3.10
11
11
  loguru>=0.7.0
12
- nekoconf[remote,schema,server]==1.1.1
12
+ nekoconf[remote,schema,server]==1.1.2
13
13
 
14
14
  [dev]
15
15
  pytest>=7.0.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "nya-proxy"
7
- version = "0.3.2"
7
+ version = "0.3.4"
8
8
  description = "A lightweight, flexible API proxy with dynamic token rotation, load balancing, and rate limiting capabilities."
9
9
  readme = "README.md"
10
10
  authors = [
@@ -35,7 +35,7 @@ dependencies = [
35
35
  "jmespath>=1.0.1",
36
36
  "orjson>=3.10,<4",
37
37
  "loguru>=0.7.0",
38
- "nekoconf[remote,schema,server]==1.1.1",
38
+ "nekoconf[remote,schema,server]==1.1.2",
39
39
  ]
40
40
 
41
41
  [project.optional-dependencies]
@@ -1 +0,0 @@
1
- __version__ = "0.3.2"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes