mirror of
https://github.com/imartinez/privateGPT.git
synced 2026-07-18 14:04:29 +00:00
fix: mypy
This commit is contained in:
@@ -387,9 +387,9 @@ class StatefulBackgroundTask(_BackgroundTask):
|
||||
|
||||
if not loop.is_closed():
|
||||
with contextlib.suppress(Exception):
|
||||
asyncio.run_coroutine_threadsafe(
|
||||
cls._shutdown_async(), loop
|
||||
).result(timeout=10)
|
||||
asyncio.run_coroutine_threadsafe(cls._shutdown_async(), loop).result(
|
||||
timeout=10
|
||||
)
|
||||
with contextlib.suppress(RuntimeError):
|
||||
loop.call_soon_threadsafe(loop.stop)
|
||||
|
||||
@@ -408,4 +408,3 @@ class StatefulBackgroundTask(_BackgroundTask):
|
||||
if self.rollback_fn:
|
||||
self.rollback_fn(*args, **kwargs)
|
||||
raise e
|
||||
|
||||
|
||||
@@ -3,13 +3,18 @@
|
||||
When ``tool_scheduler.mode`` is ``"celery"``, the chat worker dispatches tool
|
||||
calls to this task on the ``tools`` queue instead of running them in-process.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from private_gpt.celery.base import StatefulBackgroundTask
|
||||
from private_gpt.celery.celery import celery_app
|
||||
from private_gpt.di import get_global_injector
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from private_gpt.server.tools.tool_service import ToolService
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -61,7 +66,7 @@ async def tool_run_task(
|
||||
|
||||
|
||||
async def _execute_by_name(
|
||||
tool_service: "ToolService",
|
||||
tool_service: ToolService,
|
||||
tool_name: str,
|
||||
kwargs: dict[str, Any],
|
||||
) -> Any:
|
||||
|
||||
@@ -6,11 +6,13 @@ import logging
|
||||
import time
|
||||
import uuid
|
||||
from abc import ABC, abstractmethod
|
||||
from collections.abc import Awaitable, Callable
|
||||
from typing import Any
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from injector import inject, singleton
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Awaitable, Callable
|
||||
|
||||
from private_gpt.components.tools.tool_names import (
|
||||
BASH_TOOL_NAME,
|
||||
DATABASE_QUERY_TOOL_NAME,
|
||||
|
||||
@@ -35,7 +35,9 @@ def _chat_body() -> ChatBody:
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_worker_handoff_sends_json_safe_body(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
async def test_worker_handoff_sends_json_safe_body(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
stream_service = InMemoryStreamService()
|
||||
sent: dict[str, Any] = {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user