mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
Rename compile response into a private operator agents function
This commit is contained in:
@@ -253,7 +253,7 @@ class AnthropicOperatorAgent(OperatorAgent):
|
||||
)
|
||||
return formatted_messages
|
||||
|
||||
def compile_response(self, response_content: list[BetaContentBlock | dict] | str) -> str:
|
||||
def _compile_response(self, response_content: list[BetaContentBlock | dict] | str) -> str:
|
||||
"""Compile Anthropic response into a single string."""
|
||||
if isinstance(response_content, str):
|
||||
return response_content
|
||||
|
||||
@@ -79,10 +79,10 @@ class OperatorAgent(ABC):
|
||||
await self.act(current_state)
|
||||
if not self.messages:
|
||||
return "No actions to summarize."
|
||||
return self.compile_response(self.messages[-1].content)
|
||||
return self._compile_response(self.messages[-1].content)
|
||||
|
||||
@abstractmethod
|
||||
def compile_response(self, response: List | str) -> str:
|
||||
def _compile_response(self, response: List | str) -> str:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
@@ -102,7 +102,7 @@ class OperatorAgent(ABC):
|
||||
self.tracer["chat_model"] = self.vision_model.name
|
||||
if is_promptrace_enabled() and len(self.messages) > 1:
|
||||
compiled_messages = [
|
||||
AgentMessage(role=msg.role, content=self.compile_response(msg.content)) for msg in self.messages
|
||||
AgentMessage(role=msg.role, content=self._compile_response(msg.content)) for msg in self.messages
|
||||
]
|
||||
commit_conversation_trace(compiled_messages[:-1], compiled_messages[-1].content, self.tracer)
|
||||
|
||||
|
||||
@@ -260,7 +260,7 @@ class BinaryOperatorAgent(OperatorAgent):
|
||||
|
||||
return summary
|
||||
|
||||
def compile_response(self, response_content: str | List) -> str:
|
||||
def _compile_response(self, response_content: str | List) -> str:
|
||||
"""Compile response content into a string, handling OpenAI message structures."""
|
||||
if isinstance(response_content, str):
|
||||
return response_content
|
||||
|
||||
@@ -218,8 +218,8 @@ class OpenAIOperatorAgent(OperatorAgent):
|
||||
)
|
||||
return formatted_messages
|
||||
|
||||
def compile_response(self, response_content: str | list[dict | ResponseOutputItem]) -> str:
|
||||
"""Compile the response from model into a single string."""
|
||||
def _compile_response(self, response_content: str | list[dict | ResponseOutputItem]) -> str:
|
||||
"""Compile the response from model into a single string for prompt tracing."""
|
||||
# Handle case where response content is a string.
|
||||
# This is the case when response content is a user query
|
||||
if isinstance(response_content, str):
|
||||
|
||||
Reference in New Issue
Block a user