ruff
This commit is contained in:
@@ -8,7 +8,7 @@ from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from collections.abc import AsyncIterator, Sequence
|
||||
from typing import TYPE_CHECKING, Any, Optional
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from agentlite.message import (
|
||||
ContentPart,
|
||||
@@ -17,8 +17,8 @@ from agentlite.message import (
|
||||
ToolCall,
|
||||
ToolCallPart,
|
||||
)
|
||||
from agentlite.provider import ChatProvider, StreamedMessage, TokenUsage
|
||||
from agentlite.tool import SimpleToolset, Tool, ToolResult, ToolType
|
||||
from agentlite.provider import ChatProvider
|
||||
from agentlite.tool import SimpleToolset, ToolResult, ToolType
|
||||
from agentlite.labor_market import LaborMarket
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -311,7 +311,7 @@ class Agent:
|
||||
# Execute all tool calls concurrently
|
||||
futures = [self.tools.handle(tc) for tc in tool_calls]
|
||||
|
||||
for tc, future in zip(tool_calls, futures):
|
||||
for tc, future in zip(tool_calls, futures, strict=False):
|
||||
try:
|
||||
if asyncio.isfuture(future):
|
||||
result = await future
|
||||
|
||||
@@ -6,7 +6,7 @@ models, and agent settings.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Literal, Optional, Union
|
||||
from typing import Literal, Optional
|
||||
|
||||
from pydantic import BaseModel, Field, SecretStr, model_validator
|
||||
|
||||
|
||||
@@ -32,11 +32,10 @@ from __future__ import annotations
|
||||
from collections.abc import AsyncIterator
|
||||
from typing import Optional
|
||||
|
||||
from agentlite.config import AgentConfig, ModelConfig, ProviderConfig
|
||||
from agentlite.config import AgentConfig
|
||||
from agentlite.message import Message, TextPart
|
||||
from agentlite.provider import ChatProvider, TokenUsage
|
||||
from agentlite.providers.openai import OpenAIProvider
|
||||
from agentlite.tool import Tool
|
||||
|
||||
|
||||
class LLMResponse:
|
||||
@@ -174,7 +173,7 @@ class LLMClient:
|
||||
try:
|
||||
if usage is None and hasattr(stream, "usage") and stream.usage:
|
||||
usage = stream.usage
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
content = "".join(content_parts)
|
||||
|
||||
@@ -6,10 +6,8 @@ tools from external MCP-compatible servers.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from agentlite.message import TextPart
|
||||
from agentlite.tool import CallableTool, ToolOk, ToolResult, ToolError
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
@@ -7,7 +7,7 @@ and provides the base types for streaming responses.
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import AsyncIterator, Sequence
|
||||
from typing import Protocol, runtime_checkable
|
||||
from typing import Protocol, Union, runtime_checkable
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
@@ -44,8 +44,6 @@ class TokenUsage(BaseModel):
|
||||
return self.input_tokens + self.output_tokens
|
||||
|
||||
|
||||
from typing import Union
|
||||
|
||||
StreamedPart = Union[ContentPart, ToolCall, ToolCallPart]
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ from typing import TYPE_CHECKING, Any
|
||||
import httpx
|
||||
from openai import AsyncOpenAI, OpenAIError
|
||||
from openai.types.chat import (
|
||||
ChatCompletion,
|
||||
ChatCompletionChunk,
|
||||
ChatCompletionMessageParam,
|
||||
ChatCompletionToolParam,
|
||||
@@ -27,7 +26,6 @@ from agentlite.message import (
|
||||
)
|
||||
from agentlite.provider import (
|
||||
APIConnectionError,
|
||||
APIEmptyResponseError,
|
||||
APIStatusError,
|
||||
APITimeoutError,
|
||||
ChatProviderError,
|
||||
|
||||
@@ -195,7 +195,6 @@ def discover_skills(skills_dir: Path) -> list["Skill"]:
|
||||
>>> for skill in skills:
|
||||
... print(f"{skill.name}: {skill.description}")
|
||||
"""
|
||||
from agentlite.skills.models import Skill
|
||||
|
||||
if not skills_dir.is_dir():
|
||||
return []
|
||||
|
||||
@@ -16,7 +16,7 @@ Example:
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Iterable, Iterator
|
||||
from collections.abc import Iterable
|
||||
from pathlib import Path
|
||||
from typing import Literal, Optional
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ in a hierarchical agent architecture.
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any, Optional
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, Field, model_validator
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ from typing import (
|
||||
Protocol,
|
||||
TypeVar,
|
||||
Union,
|
||||
cast,
|
||||
Generic,
|
||||
get_type_hints,
|
||||
)
|
||||
@@ -298,10 +297,6 @@ class CallableTool2(ABC, Generic[Params]):
|
||||
return ToolError(message=f"Tool execution failed: {e}")
|
||||
|
||||
|
||||
# Import Generic here to avoid issues with type checking
|
||||
from typing import Generic
|
||||
|
||||
|
||||
class Toolset(Protocol):
|
||||
"""Protocol for tool collections.
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ for enabling/disabling individual tools.
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any, Optional
|
||||
from typing import Optional
|
||||
|
||||
from agentlite.tool import CallableTool2, ToolOk, ToolError, ToolResult, SimpleToolset
|
||||
from agentlite.tool import SimpleToolset
|
||||
from agentlite.tools.config import (
|
||||
ToolSuiteConfig,
|
||||
FileToolsConfig,
|
||||
|
||||
@@ -6,7 +6,6 @@ allowing users to enable/disable specific tools.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
@@ -165,7 +165,6 @@ class ReadFile(CallableTool2[Params]):
|
||||
|
||||
for i, line in enumerate(selected_lines):
|
||||
line_num = start_idx + i + 1
|
||||
original_line = line
|
||||
|
||||
# Truncate if needed
|
||||
if len(line) > self._max_line_length:
|
||||
|
||||
@@ -3,7 +3,4 @@
|
||||
This module provides tools for creating and managing subagents.
|
||||
"""
|
||||
|
||||
from agentlite.tools.multiagent.task import Task
|
||||
from agentlite.tools.multiagent.create import CreateSubagent
|
||||
|
||||
__all__ = []
|
||||
|
||||
@@ -8,8 +8,6 @@ from typing import Optional
|
||||
|
||||
import asyncio
|
||||
import platform
|
||||
import shlex
|
||||
from pathlib import Path
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
@@ -152,7 +150,7 @@ class Shell(CallableTool2[Params]):
|
||||
if process.returncode == 0:
|
||||
return ToolOk(
|
||||
output=output,
|
||||
message=f"Command executed successfully (exit code 0).",
|
||||
message="Command executed successfully (exit code 0).",
|
||||
)
|
||||
else:
|
||||
return ToolError(
|
||||
|
||||
@@ -7,7 +7,6 @@ from __future__ import annotations
|
||||
|
||||
import urllib.request
|
||||
import urllib.error
|
||||
from pathlib import Path
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
Reference in New Issue
Block a user