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 typing import List, Dict, Any, Optional
|
||||
from ..config import Config
|
||||
from typing import Dict, List, Any, Optional
|
||||
|
||||
|
||||
class BaseProvider(ABC):
|
||||
"""Base class for AI providers"""
|
||||
"""Base class for LLM providers"""
|
||||
|
||||
def __init__(self, config: Config):
|
||||
self.config = config
|
||||
def __init__(self, api_key: str, model: str):
|
||||
self.api_key = api_key
|
||||
self.model = model
|
||||
|
||||
@abstractmethod
|
||||
async def chat_completion(
|
||||
async def generate_response(
|
||||
self,
|
||||
messages: List[Dict[str, Any]],
|
||||
system_prompt: str,
|
||||
tools: Optional[List[Dict[str, Any]]] = None,
|
||||
system_prompt: Optional[str] = None
|
||||
max_tokens: int = 8192
|
||||
) -> Dict[str, Any]:
|
||||
"""
|
||||
Get chat completion from the provider
|
||||
Generate a response from the LLM
|
||||
|
||||
Args:
|
||||
messages: List of messages in the conversation
|
||||
tools: Optional list of available tools
|
||||
system_prompt: Optional system prompt
|
||||
messages: List of conversation messages
|
||||
system_prompt: System prompt for the model
|
||||
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:
|
||||
List of tool calls with 'id', 'name', and 'arguments'
|
||||
"""
|
||||
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
|
||||
Dict containing the response with 'content' and optional 'tool_calls'
|
||||
"""
|
||||
pass
|
||||
Loading…
Reference in New Issue
Block a user