From cecbfe35e21f770166d660f2bb85a12def0a492e Mon Sep 17 00:00:00 2001 From: Debanjum Date: Fri, 30 May 2025 20:31:43 -0700 Subject: [PATCH] Rename compile response into a private operator agents function --- src/khoj/processor/operator/operator_agent_anthropic.py | 2 +- src/khoj/processor/operator/operator_agent_base.py | 6 +++--- src/khoj/processor/operator/operator_agent_binary.py | 2 +- src/khoj/processor/operator/operator_agent_openai.py | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/khoj/processor/operator/operator_agent_anthropic.py b/src/khoj/processor/operator/operator_agent_anthropic.py index 7af74c29..81332bf0 100644 --- a/src/khoj/processor/operator/operator_agent_anthropic.py +++ b/src/khoj/processor/operator/operator_agent_anthropic.py @@ -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 diff --git a/src/khoj/processor/operator/operator_agent_base.py b/src/khoj/processor/operator/operator_agent_base.py index 3528348a..38e7744e 100644 --- a/src/khoj/processor/operator/operator_agent_base.py +++ b/src/khoj/processor/operator/operator_agent_base.py @@ -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) diff --git a/src/khoj/processor/operator/operator_agent_binary.py b/src/khoj/processor/operator/operator_agent_binary.py index 7b1ec086..f4df22fe 100644 --- a/src/khoj/processor/operator/operator_agent_binary.py +++ b/src/khoj/processor/operator/operator_agent_binary.py @@ -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 diff --git a/src/khoj/processor/operator/operator_agent_openai.py b/src/khoj/processor/operator/operator_agent_openai.py index 7ae71bff..af115e1c 100644 --- a/src/khoj/processor/operator/operator_agent_openai.py +++ b/src/khoj/processor/operator/operator_agent_openai.py @@ -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):