Almost working?
This commit is contained in:
parent
90a83a7313
commit
c3cf9a9c76
@ -648,7 +648,6 @@ class WebServer:
|
||||
return JSONResponse({"error": "Invalid context_id"}, status_code=400)
|
||||
context = self.upsert_context(context_id)
|
||||
|
||||
|
||||
try:
|
||||
data = await request.json()
|
||||
agent = context.get_agent(agent_type)
|
||||
@ -978,6 +977,9 @@ class WebServer:
|
||||
async def generate_response(self, context : Context, agent : Agent, content : str):
|
||||
if not self.file_watcher:
|
||||
return
|
||||
|
||||
if agent.agent_type == "Chat":
|
||||
agent.proces
|
||||
|
||||
if self.processing:
|
||||
logging.info("TODO: Implement delay queing; busy for same agent, otherwise return queue size and estimated wait time")
|
||||
|
@ -4,7 +4,7 @@ from typing_extensions import Annotated
|
||||
from abc import ABC, abstractmethod
|
||||
from typing_extensions import Annotated
|
||||
import logging
|
||||
from .base import Agent, registry
|
||||
from .base import Agent, ContextBase, registry
|
||||
from .. conversation import Conversation
|
||||
from .. message import Message
|
||||
|
||||
@ -16,32 +16,10 @@ class Chat(Agent, ABC):
|
||||
agent_type: Literal["chat"] = "chat"
|
||||
_agent_type: ClassVar[str] = agent_type # Add this for registration
|
||||
|
||||
def __init_subclass__(cls, **kwargs):
|
||||
"""Auto-register subclasses"""
|
||||
super().__init_subclass__(**kwargs)
|
||||
# Register this class if it has an agent_type
|
||||
if hasattr(cls, 'agent_type') and cls.agent_type != Agent.agent_type:
|
||||
registry.register(cls.agent_type, cls)
|
||||
|
||||
def __init__(self, **data):
|
||||
# Set agent_type from class if not provided
|
||||
if 'agent_type' not in data:
|
||||
data['agent_type'] = self.__class__.agent_type
|
||||
super().__init__(**data)
|
||||
|
||||
system_prompt: str # Mandatory
|
||||
conversation: Conversation = Conversation()
|
||||
context_tokens: int = 0
|
||||
|
||||
# Add a property for context if needed without creating a circular reference
|
||||
@property
|
||||
def context(self) -> Optional['Context']:
|
||||
if TYPE_CHECKING:
|
||||
from .context import Context
|
||||
# Implement logic to fetch context by ID if needed
|
||||
return None
|
||||
|
||||
#context: Context
|
||||
context: ContextBase
|
||||
|
||||
_content_seed: str = PrivateAttr(default="")
|
||||
|
||||
|
@ -135,10 +135,9 @@ class Context(ContextBase):
|
||||
|
||||
# Find the matching subclass
|
||||
for agent_cls in Agent.__subclasses__():
|
||||
logging.info(f"Found class: {agent_cls.model_fields['agent_type'].default}")
|
||||
if agent_cls.model_fields["agent_type"].default == agent_type:
|
||||
# Create the agent instance with provided kwargs
|
||||
agent = agent_cls(agent_type=agent_type, **kwargs)
|
||||
agent = agent_cls(agent_type=agent_type, context=self, **kwargs)
|
||||
self.agents.append(agent)
|
||||
return agent
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user