refactor: reorganize Taskiq broker and update imports for clarity

This commit is contained in:
2026-06-15 15:36:22 +08:00
parent 7b061660c0
commit 2d98628681
5 changed files with 36 additions and 17 deletions
+14
View File
@@ -0,0 +1,14 @@
"""Taskiq broker — shared across all task modules."""
from taskiq_redis import ListQueueBroker, RedisAsyncResultBackend
from app.core.config import settings
# Create Taskiq broker with Redis
broker = ListQueueBroker(
url=settings.TASKIQ_BROKER_URL,
).with_result_backend(
RedisAsyncResultBackend(
redis_url=settings.TASKIQ_RESULT_BACKEND,
)
)
+6 -12
View File
@@ -1,23 +1,17 @@
"""Taskiq application configuration."""
from taskiq import TaskiqScheduler
from taskiq_redis import ListQueueBroker, RedisAsyncResultBackend
from taskiq.schedule_sources import LabelScheduleSource
from app.core.config import settings
# Create Taskiq broker with Redis
broker = ListQueueBroker(
url=settings.TASKIQ_BROKER_URL,
).with_result_backend(
RedisAsyncResultBackend(
redis_url=settings.TASKIQ_RESULT_BACKEND,
)
)
from app.worker.broker import broker
import app.worker.tasks # noqa: F401 — register @broker.task decorated functions
import app.worker.tasks.schedules # noqa: F401 — register scheduled tasks
# Create scheduler for periodic tasks
# LabelScheduleSource auto-discovers @broker.task(schedule=[...]) decorated functions
scheduler = TaskiqScheduler(
broker=broker,
sources=["app.worker.tasks.schedules"],
sources=[LabelScheduleSource(broker)],
)
+1 -1
View File
@@ -6,7 +6,7 @@ import tempfile
from pathlib import Path
from typing import Any
from app.worker.taskiq_app import broker
from app.worker.broker import broker
logger = logging.getLogger(__name__)
+1 -1
View File
@@ -1,6 +1,6 @@
"""Taskiq scheduled tasks (cron-like)."""
from app.worker.taskiq_app import broker
from app.worker.broker import broker
from app.worker.tasks.rag_tasks import check_scheduled_syncs
+14 -3
View File
@@ -31,7 +31,7 @@ dependencies = [
"jinja2>=3.1.0",
"slowapi>=0.1.9",
"fastapi-pagination>=0.12.31",
"taskiq>=0.11.0",
"taskiq[reload]>=0.11.0",
"taskiq-redis>=1.0.0",
"taskiq-dependencies>=0.1.0",
# pydantic-deep: deep agentic coding assistant built on pydantic-ai
@@ -39,7 +39,7 @@ dependencies = [
# pydantic-ai backend with console toolset (StateBackend, LocalBackend)
"pydantic-ai-backend[console]>=0.2.4",
# pydantic-ai with web search and fetch support (WebSearch, WebFetch capabilities)
"pydantic-ai-slim[duckduckgo,web-fetch]>=1.80.0",
"pydantic-ai-slim[duckduckgo,web-fetch,openai]>=1.80.0",
# Vector store
"qdrant-client>=1.14.0",
# Text splitting
@@ -47,7 +47,6 @@ dependencies = [
# BM25 for hybrid search
"rank-bm25>=0.2.2",
# Uses existing openai dependency
"sentence-transformers>=3.0.0",
"pymupdf>=1.25.0",
"pillow>=10.0.0",
"python-docx>=1.1.0",
@@ -58,6 +57,9 @@ dependencies = [
# AntV chart MCP server client (advanced diagrams via mcp-server-chart sidecar).
# Each framework attaches MCP differently, so the client dep is gated per framework.
"pydantic-ai-slim[mcp]>=1.80.0",
# Cross-encoder reranking for RAG
"sentence-transformers>=3.0.0",
"torch>=2.0.0",
]
[project.optional-dependencies]
@@ -77,6 +79,15 @@ agent_delta = "cli.commands:main"
requires = ["hatchling"]
build-backend = "hatchling.build"
[[tool.uv.index]]
url = "https://download.pytorch.org/whl/cpu"
[[tool.uv.index]]
url = "https://pypi.org/simple"
[tool.uv]
index-strategy = "unsafe-best-match"
[tool.hatch.build.targets.wheel]
packages = ["app", "cli"]