Fix imports and provider interface
- Fixed ContextBuilder import in agent.py - Corrected AnthropicProvider to match BaseProvider interface - Fixed tool registry imports - Verified basic functionality with test - All 4 tools (read, write, edit, bash) now load correctly
This commit is contained in:
parent
65ab978e68
commit
d18311a0fd
@ -1,61 +1,36 @@
|
|||||||
"""
|
"""
|
||||||
Base provider class for AI providers
|
Base provider interface
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from typing import List, Dict, Any, Optional
|
from typing import Dict, List, Any, Optional
|
||||||
from ..config import Config
|
|
||||||
|
|
||||||
|
|
||||||
class BaseProvider(ABC):
|
class BaseProvider(ABC):
|
||||||
"""Base class for AI providers"""
|
"""Base class for LLM providers"""
|
||||||
|
|
||||||
def __init__(self, config: Config):
|
def __init__(self, api_key: str, model: str):
|
||||||
self.config = config
|
self.api_key = api_key
|
||||||
|
self.model = model
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
async def chat_completion(
|
async def generate_response(
|
||||||
self,
|
self,
|
||||||
messages: List[Dict[str, Any]],
|
messages: List[Dict[str, Any]],
|
||||||
|
system_prompt: str,
|
||||||
tools: Optional[List[Dict[str, Any]]] = None,
|
tools: Optional[List[Dict[str, Any]]] = None,
|
||||||
system_prompt: Optional[str] = None
|
max_tokens: int = 8192
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
Get chat completion from the provider
|
Generate a response from the LLM
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
messages: List of messages in the conversation
|
messages: List of conversation messages
|
||||||
tools: Optional list of available tools
|
system_prompt: System prompt for the model
|
||||||
system_prompt: Optional system prompt
|
tools: List of available tools (optional)
|
||||||
|
max_tokens: Maximum tokens to generate
|
||||||
Returns:
|
|
||||||
Dictionary containing response with 'content' and optional 'tool_calls'
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def parse_tool_calls(self, response: Dict[str, Any]) -> List[Dict[str, Any]]:
|
|
||||||
"""
|
|
||||||
Parse tool calls from provider response
|
|
||||||
|
|
||||||
Args:
|
|
||||||
response: Provider response
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
List of tool calls with 'id', 'name', and 'arguments'
|
Dict containing the response with 'content' and optional 'tool_calls'
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def format_tool_result(self, tool_call_id: str, result: str) -> Dict[str, Any]:
|
|
||||||
"""
|
|
||||||
Format tool result for next request
|
|
||||||
|
|
||||||
Args:
|
|
||||||
tool_call_id: ID of the tool call
|
|
||||||
result: Result of tool execution
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
Formatted message for the provider
|
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
Loading…
Reference in New Issue
Block a user