mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-24 20:51:02 +02:00
Logging strategy updates
This commit is contained in:
parent
d91a82d8d5
commit
1d9aa652e0
4 changed files with 15 additions and 16 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ class Processor(AgentService):
|
|||
|
||||
await next(r)
|
||||
|
||||
print("Done.", flush=True)
|
||||
logger.debug("React agent processing complete")
|
||||
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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}")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue