From 0781d3e6a7cdea204ca62813676bd9ef6d6d0f5a Mon Sep 17 00:00:00 2001 From: cybermaggedon Date: Tue, 31 Mar 2026 09:12:33 +0100 Subject: [PATCH] Remove unnecessary prompt-client logging (#740) --- .../trustgraph/base/prompt_client.py | 23 +++---------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/trustgraph-base/trustgraph/base/prompt_client.py b/trustgraph-base/trustgraph/base/prompt_client.py index 74b25132..6859a9f0 100644 --- a/trustgraph-base/trustgraph/base/prompt_client.py +++ b/trustgraph-base/trustgraph/base/prompt_client.py @@ -1,21 +1,16 @@ import json import asyncio -import logging from . request_response_spec import RequestResponse, RequestResponseSpec from .. schema import PromptRequest, PromptResponse -logger = logging.getLogger(__name__) - class PromptClient(RequestResponse): async def prompt(self, id, variables, timeout=600, streaming=False, chunk_callback=None): - logger.info(f"DEBUG prompt_client: prompt called, id={id}, streaming={streaming}, chunk_callback={chunk_callback is not None}") if not streaming: - logger.info("DEBUG prompt_client: Non-streaming path") - # Non-streaming path + resp = await self.request( PromptRequest( id = id, @@ -36,39 +31,30 @@ class PromptClient(RequestResponse): return json.loads(resp.object) else: - logger.info("DEBUG prompt_client: Streaming path") - # Streaming path - just forward chunks, don't accumulate + last_text = "" last_object = None async def forward_chunks(resp): nonlocal last_text, last_object - logger.info(f"DEBUG prompt_client: forward_chunks called, resp.text={resp.text[:50] if resp.text else None}, end_of_stream={getattr(resp, 'end_of_stream', False)}") if resp.error: - logger.error(f"DEBUG prompt_client: Error in response: {resp.error.message}") raise RuntimeError(resp.error.message) end_stream = getattr(resp, 'end_of_stream', False) - # Always call callback if there's text OR if it's the final message if resp.text is not None: last_text = resp.text - # Call chunk callback if provided with both chunk and end_of_stream flag if chunk_callback: - logger.info(f"DEBUG prompt_client: Calling chunk_callback with end_of_stream={end_stream}") if asyncio.iscoroutinefunction(chunk_callback): await chunk_callback(resp.text, end_stream) else: chunk_callback(resp.text, end_stream) elif resp.object: - logger.info(f"DEBUG prompt_client: Got object response") last_object = resp.object - logger.info(f"DEBUG prompt_client: Returning end_of_stream={end_stream}") return end_stream - logger.info("DEBUG prompt_client: Creating PromptRequest") req = PromptRequest( id = id, terms = { @@ -77,19 +63,16 @@ class PromptClient(RequestResponse): }, streaming = True ) - logger.info(f"DEBUG prompt_client: About to call self.request with recipient, timeout={timeout}") + await self.request( req, recipient=forward_chunks, timeout=timeout ) - logger.info(f"DEBUG prompt_client: self.request returned, last_text={last_text[:50] if last_text else None}") if last_text: - logger.info("DEBUG prompt_client: Returning last_text") return last_text - logger.info("DEBUG prompt_client: Returning parsed last_object") return json.loads(last_object) if last_object else None async def extract_definitions(self, text, timeout=600):