Skip to content

Commit

Permalink
chore: bit provider work
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Jan 30, 2025
1 parent 079c2e9 commit 04e0dd5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/llmling_agent_providers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class AgentProvider[TDeps]:
tool_used = Signal(ToolCallInfo)
chunk_streamed = Signal(str, str)
model_changed = Signal(object) # Model | None
NAME: str

def __init__(
self,
Expand Down Expand Up @@ -198,3 +199,7 @@ async def get_token_limits(self) -> tokonomics.TokenLimits | None:
except ValueError:
logger.debug("Could not get token limits for model: %s", self.model_name)
return None


class AgentLLMProvider[TDeps](AgentProvider[TDeps]):
"""Provider using LLM backend."""
2 changes: 2 additions & 0 deletions src/llmling_agent_providers/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class CallbackProvider[TDeps](AgentProvider[TDeps]):
- String or ChatMessage returns
"""

NAME = "callback"

def __init__(
self,
callback: ProcessorCallback[Any],
Expand Down
1 change: 1 addition & 0 deletions src/llmling_agent_providers/human/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class HumanProvider(AgentProvider):

model = None
_conversation: ConversationManager
NAME = "human"

def __init__(
self,
Expand Down
8 changes: 5 additions & 3 deletions src/llmling_agent_providers/litellm_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from llmling_agent.models.content import BaseContent, Content
from llmling_agent.models.messages import ChatMessage, TokenCost
from llmling_agent_providers.base import (
AgentProvider,
AgentLLMProvider,
ProviderResponse,
StreamingResponseProtocol,
)
Expand Down Expand Up @@ -108,9 +108,11 @@ def usage(self) -> Usage:
return self._final_usage


class LiteLLMProvider(AgentProvider[Any]):
class LiteLLMProvider(AgentLLMProvider[Any]):
"""Provider using LiteLLM for model-agnostic completions."""

NAME = "litellm"

def __init__(
self,
name: str,
Expand Down Expand Up @@ -260,7 +262,7 @@ async def generate_response(
tool_calls=calls,
model_name=model_name,
cost_and_usage=cost_and_usage,
provider_extra=response.choices[0].message.provider_specific_fields,
provider_extra=response.choices[0].message.provider_specific_fields, # pyright: ignore
)

except Exception as e:
Expand Down
5 changes: 3 additions & 2 deletions src/llmling_agent_providers/pydanticai/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
ToolSkippedError,
)
from llmling_agent.utils.inspection import has_argument_type
from llmling_agent_providers.base import AgentProvider, ProviderResponse
from llmling_agent_providers.base import AgentLLMProvider, ProviderResponse
from llmling_agent_providers.pydanticai.utils import (
convert_model_message,
format_part,
Expand All @@ -49,10 +49,11 @@
logger = get_logger(__name__)


class PydanticAIProvider(AgentProvider):
class PydanticAIProvider(AgentLLMProvider):
"""Provider using pydantic-ai as backend."""

_conversation: ConversationManager
NAME = "pydantic_ai"

def __init__(
self,
Expand Down
2 changes: 2 additions & 0 deletions src/llmling_agent_providers/remote_websocket/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class ToolContext(BaseModel):
class WebSocketProvider(AgentProvider, TaskManagerMixin):
"""Provider that connects to remote agent via WebSocket."""

NAME = "websocket"

def __init__(
self,
url: str,
Expand Down

0 comments on commit 04e0dd5

Please sign in to comment.