agstack 1.2.2__tar.gz → 1.2.3__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 (50) hide show
  1. {agstack-1.2.2 → agstack-1.2.3}/PKG-INFO +1 -1
  2. {agstack-1.2.2 → agstack-1.2.3}/agstack/llm/client.py +35 -0
  3. {agstack-1.2.2 → agstack-1.2.3}/agstack/security/casbin.py +1 -1
  4. {agstack-1.2.2 → agstack-1.2.3}/agstack.egg-info/PKG-INFO +1 -1
  5. {agstack-1.2.2 → agstack-1.2.3}/pyproject.toml +1 -1
  6. {agstack-1.2.2 → agstack-1.2.3}/LICENSE +0 -0
  7. {agstack-1.2.2 → agstack-1.2.3}/README.md +0 -0
  8. {agstack-1.2.2 → agstack-1.2.3}/agstack/__init__.py +0 -0
  9. {agstack-1.2.2 → agstack-1.2.3}/agstack/config/__init__.py +0 -0
  10. {agstack-1.2.2 → agstack-1.2.3}/agstack/config/logger.py +0 -0
  11. {agstack-1.2.2 → agstack-1.2.3}/agstack/config/manager.py +0 -0
  12. {agstack-1.2.2 → agstack-1.2.3}/agstack/config/types.py +0 -0
  13. {agstack-1.2.2 → agstack-1.2.3}/agstack/contexts.py +0 -0
  14. {agstack-1.2.2 → agstack-1.2.3}/agstack/decorators.py +0 -0
  15. {agstack-1.2.2 → agstack-1.2.3}/agstack/events.py +0 -0
  16. {agstack-1.2.2 → agstack-1.2.3}/agstack/exceptions.py +0 -0
  17. {agstack-1.2.2 → agstack-1.2.3}/agstack/fastapi/__init__.py +0 -0
  18. {agstack-1.2.2 → agstack-1.2.3}/agstack/fastapi/exception.py +0 -0
  19. {agstack-1.2.2 → agstack-1.2.3}/agstack/fastapi/middleware.py +0 -0
  20. {agstack-1.2.2 → agstack-1.2.3}/agstack/fastapi/offline.py +0 -0
  21. {agstack-1.2.2 → agstack-1.2.3}/agstack/fastapi/sse.py +0 -0
  22. {agstack-1.2.2 → agstack-1.2.3}/agstack/infra/db/__init__.py +0 -0
  23. {agstack-1.2.2 → agstack-1.2.3}/agstack/infra/es/__init__.py +0 -0
  24. {agstack-1.2.2 → agstack-1.2.3}/agstack/infra/kg/__init__.py +0 -0
  25. {agstack-1.2.2 → agstack-1.2.3}/agstack/infra/mq/__init__.py +0 -0
  26. {agstack-1.2.2 → agstack-1.2.3}/agstack/llm/__init__.py +0 -0
  27. {agstack-1.2.2 → agstack-1.2.3}/agstack/llm/flow/__init__.py +0 -0
  28. {agstack-1.2.2 → agstack-1.2.3}/agstack/llm/flow/agent.py +0 -0
  29. {agstack-1.2.2 → agstack-1.2.3}/agstack/llm/flow/context.py +0 -0
  30. {agstack-1.2.2 → agstack-1.2.3}/agstack/llm/flow/event.py +0 -0
  31. {agstack-1.2.2 → agstack-1.2.3}/agstack/llm/flow/exceptions.py +0 -0
  32. {agstack-1.2.2 → agstack-1.2.3}/agstack/llm/flow/factory.py +0 -0
  33. {agstack-1.2.2 → agstack-1.2.3}/agstack/llm/flow/flow.py +0 -0
  34. {agstack-1.2.2 → agstack-1.2.3}/agstack/llm/flow/loader.py +0 -0
  35. {agstack-1.2.2 → agstack-1.2.3}/agstack/llm/flow/records.py +0 -0
  36. {agstack-1.2.2 → agstack-1.2.3}/agstack/llm/flow/registry.py +0 -0
  37. {agstack-1.2.2 → agstack-1.2.3}/agstack/llm/flow/state.py +0 -0
  38. {agstack-1.2.2 → agstack-1.2.3}/agstack/llm/flow/tool.py +0 -0
  39. {agstack-1.2.2 → agstack-1.2.3}/agstack/llm/prompts.py +0 -0
  40. {agstack-1.2.2 → agstack-1.2.3}/agstack/llm/token.py +0 -0
  41. {agstack-1.2.2 → agstack-1.2.3}/agstack/registry.py +0 -0
  42. {agstack-1.2.2 → agstack-1.2.3}/agstack/schema.py +0 -0
  43. {agstack-1.2.2 → agstack-1.2.3}/agstack/security/__init__.py +0 -0
  44. {agstack-1.2.2 → agstack-1.2.3}/agstack/security/crypt.py +0 -0
  45. {agstack-1.2.2 → agstack-1.2.3}/agstack/status.py +0 -0
  46. {agstack-1.2.2 → agstack-1.2.3}/agstack.egg-info/SOURCES.txt +0 -0
  47. {agstack-1.2.2 → agstack-1.2.3}/agstack.egg-info/dependency_links.txt +0 -0
  48. {agstack-1.2.2 → agstack-1.2.3}/agstack.egg-info/requires.txt +0 -0
  49. {agstack-1.2.2 → agstack-1.2.3}/agstack.egg-info/top_level.txt +0 -0
  50. {agstack-1.2.2 → agstack-1.2.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agstack
3
- Version: 1.2.2
3
+ Version: 1.2.3
4
4
  Summary: Production-ready toolkit for building FastAPI and LLM applications
5
5
  Author-email: XtraVisions <gitadmin@xtravisions.com>, Chen Hao <chenhao@xtravisions.com>
6
6
  Maintainer-email: XtraVisions <gitadmin@xtravisions.com>, Chen Hao <chenhao@xtravisions.com>
@@ -4,6 +4,7 @@ import logging
4
4
  import time
5
5
  from typing import TYPE_CHECKING, Any, AsyncIterator, Literal, overload
6
6
 
7
+ import httpx
7
8
  from httpx import AsyncClient
8
9
  from httpx import Timeout as HttpxTimeout
9
10
  from openai import APIError, APITimeoutError, AsyncOpenAI, OpenAI, RateLimitError
@@ -447,7 +448,15 @@ class LLMClient:
447
448
  :param model: 模型名称
448
449
  :return: [(index, score, text), ...] 按相关性降序排列
449
450
  """
451
+ from httpx import ConnectTimeout, TimeoutException
450
452
 
453
+ @autoretry(
454
+ logger,
455
+ retries=3,
456
+ delay=2.0,
457
+ backoff=2.0,
458
+ exceptions=(ConnectTimeout, ConnectionError),
459
+ )
451
460
  async def _call():
452
461
  return await self._async_http_client.post(
453
462
  f"{self._base_url}/reranks",
@@ -463,6 +472,7 @@ class LLMClient:
463
472
 
464
473
  try:
465
474
  response = await _call()
475
+ response.raise_for_status()
466
476
  data = response.json()
467
477
 
468
478
  # 解析响应
@@ -476,6 +486,17 @@ class LLMClient:
476
486
 
477
487
  return results
478
488
 
489
+ except TimeoutException as e:
490
+ logger.error(f"Rerank timeout: {e}")
491
+ raise LLMTimeoutError("LLM_RERANK_TIMEOUT") from e
492
+
493
+ except httpx.HTTPStatusError as e:
494
+ if e.response.status_code == 429:
495
+ logger.error(f"Rerank rate limit: {e}")
496
+ raise LLMRateLimitError("LLM_RERANK_RATE_LIMIT") from e
497
+ logger.error(f"Rerank HTTP error {e.response.status_code}: {e}")
498
+ raise LLMError("LLM_RERANK_ERROR", {"error": str(e)}, http_status=e.response.status_code) from e
499
+
479
500
  except Exception as e:
480
501
  logger.error(f"Rerank error: {e}")
481
502
  raise LLMError("LLM_RERANK_ERROR", {"error": str(e)}) from e
@@ -495,6 +516,8 @@ class LLMClient:
495
516
  :param model: 模型名称
496
517
  :return: [(index, score, text), ...] 按相关性降序排列
497
518
  """
519
+ import requests
520
+
498
521
  session = self._get_sync_http_session()
499
522
 
500
523
  try:
@@ -522,6 +545,18 @@ class LLMClient:
522
545
 
523
546
  return results
524
547
 
548
+ except requests.Timeout as e:
549
+ logger.error(f"Rerank timeout (sync): {e}")
550
+ raise LLMTimeoutError("LLM_RERANK_TIMEOUT") from e
551
+
552
+ except requests.HTTPError as e:
553
+ status = e.response.status_code if e.response is not None else 500
554
+ if status == 429:
555
+ logger.error(f"Rerank rate limit (sync): {e}")
556
+ raise LLMRateLimitError("LLM_RERANK_RATE_LIMIT") from e
557
+ logger.error(f"Rerank HTTP error {status} (sync): {e}")
558
+ raise LLMError("LLM_RERANK_ERROR", {"error": str(e)}, http_status=status) from e
559
+
525
560
  except Exception as e:
526
561
  logger.error(f"Rerank error (sync): {e}")
527
562
  raise LLMError("LLM_RERANK_ERROR", {"error": str(e)}) from e
@@ -40,7 +40,7 @@ class CasbinRules(ObjectModel):
40
40
  created_at: Column[datetime] = column(type="datetime", default_factory=datetime.now)
41
41
 
42
42
  class Config:
43
- table_name = "system_casbin_rule"
43
+ table_name = "system_casbin_rules"
44
44
 
45
45
 
46
46
  class SqlObjectsAdapter(AsyncAdapter, AsyncFilteredAdapter):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agstack
3
- Version: 1.2.2
3
+ Version: 1.2.3
4
4
  Summary: Production-ready toolkit for building FastAPI and LLM applications
5
5
  Author-email: XtraVisions <gitadmin@xtravisions.com>, Chen Hao <chenhao@xtravisions.com>
6
6
  Maintainer-email: XtraVisions <gitadmin@xtravisions.com>, Chen Hao <chenhao@xtravisions.com>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "agstack"
3
- version = "1.2.2"
3
+ version = "1.2.3"
4
4
  description = "Production-ready toolkit for building FastAPI and LLM applications"
5
5
  readme = "README.md"
6
6
  license = "MIT"
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
File without changes
File without changes
File without changes