diff --git a/trustgraph-base/trustgraph/api/api.py b/trustgraph-base/trustgraph/api/api.py index 73adc7a3..b65f62ac 100644 --- a/trustgraph-base/trustgraph/api/api.py +++ b/trustgraph-base/trustgraph/api/api.py @@ -49,9 +49,6 @@ class Api: url = f"{self.url}{path}" -# print("uri:", url) -# print(json.dumps(request, indent=4)) - # Invoke the API, input is passed as JSON resp = requests.post(url, json=request, timeout=self.timeout) @@ -59,8 +56,6 @@ class Api: if resp.status_code != 200: raise ProtocolException(f"Status code {resp.status_code}") -# print(resp.text) - try: # Parse the response as JSON object = resp.json() diff --git a/trustgraph-flow/trustgraph/agent/react/service.py b/trustgraph-flow/trustgraph/agent/react/service.py index c962bd0b..1ed255af 100755 --- a/trustgraph-flow/trustgraph/agent/react/service.py +++ b/trustgraph-flow/trustgraph/agent/react/service.py @@ -263,7 +263,7 @@ class Processor(AgentService): await next(r) - print("Done.", flush=True) + logger.debug("React agent processing complete") return diff --git a/trustgraph-flow/trustgraph/rev_gateway/service.py b/trustgraph-flow/trustgraph/rev_gateway/service.py index 8d82f407..c8e78af2 100644 --- a/trustgraph-flow/trustgraph/rev_gateway/service.py +++ b/trustgraph-flow/trustgraph/rev_gateway/service.py @@ -107,7 +107,7 @@ class ReverseGateway: async def handle_message(self, message: str): try: - print(f"Received: {message}", flush=True) + logger.debug(f"Received message: {message}") msg_data = json.loads(message) response = await self.dispatcher.handle_message(msg_data) @@ -228,15 +228,15 @@ def run(): pulsar_listener=args.pulsar_listener ) - print(f"Starting reverse gateway:") - print(f" WebSocket URI: {gateway.url}") - print(f" Max workers: {args.max_workers}") - print(f" Pulsar host: {gateway.pulsar_host}") + logger.info(f"Starting reverse gateway:") + logger.info(f" WebSocket URI: {gateway.url}") + logger.info(f" Max workers: {args.max_workers}") + logger.info(f" Pulsar host: {gateway.pulsar_host}") try: asyncio.run(gateway.run()) except KeyboardInterrupt: - print("\nShutdown requested by user") + logger.info("Shutdown requested by user") except Exception as e: - print(f"Fatal error: {e}") + logger.error(f"Fatal error: {e}", exc_info=True) sys.exit(1) diff --git a/trustgraph-flow/trustgraph/template/prompt_manager.py b/trustgraph-flow/trustgraph/template/prompt_manager.py index 49a21c73..9364cf21 100644 --- a/trustgraph-flow/trustgraph/template/prompt_manager.py +++ b/trustgraph-flow/trustgraph/template/prompt_manager.py @@ -3,6 +3,10 @@ import ibis import json from jsonschema import validate import re +import logging + +# Module logger +logger = logging.getLogger(__name__) class PromptConfiguration: def __init__(self, system_template, global_terms={}, prompts={}): @@ -101,7 +105,7 @@ class PromptManager: async def invoke(self, id, input, llm): - print("Invoke...", flush=True) + logger.debug("Invoking prompt template...") terms = self.terms | self.prompts[id].terms | input @@ -123,13 +127,13 @@ class PromptManager: try: obj = self.parse_json(resp) except: - print("Parse fail:", resp, flush=True) + logger.error(f"JSON parse failed: {resp}") raise RuntimeError("JSON parse fail") if self.prompts[id].schema: try: validate(instance=obj, schema=self.prompts[id].schema) - print("Validated", flush=True) + logger.debug("Schema validation successful") except Exception as e: raise RuntimeError(f"Schema validation fail: {e}")