mirror of
https://github.com/RichieCahill/dotfiles.git
synced 2026-04-17 04:58:19 -04:00
added logging
This commit is contained in:
@@ -92,6 +92,7 @@ def handle_inventory_update(
|
||||
Uses the LLM to extract structured items, then pushes to the van_inventory API.
|
||||
"""
|
||||
try:
|
||||
logger.info(f"Processing inventory update from {message.source}")
|
||||
if message.attachments:
|
||||
image_data = signal.get_attachment(message.attachments[0])
|
||||
raw_response = llm.chat_with_image(
|
||||
@@ -110,8 +111,12 @@ def handle_inventory_update(
|
||||
signal.reply(message, "Send a photo of a receipt or a text list of items to update inventory.")
|
||||
return InventoryUpdate()
|
||||
|
||||
logger.info(f"{raw_response=}")
|
||||
|
||||
new_items = parse_llm_response(raw_response)
|
||||
|
||||
logger.info(f"{new_items=}")
|
||||
|
||||
for item in new_items:
|
||||
_upsert_item(api_url, item)
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ def dispatch(
|
||||
"status": status_action,
|
||||
"inventory": inventory_action,
|
||||
}
|
||||
|
||||
logger.info(f"f{source=} running {cmd=} with {message=}")
|
||||
action = commands.get(cmd)
|
||||
if action is None:
|
||||
if message.attachments:
|
||||
@@ -184,7 +184,10 @@ def run_loop(
|
||||
raise
|
||||
|
||||
|
||||
def main(log_level: Annotated[str, typer.Option()] = "INFO") -> None:
|
||||
def main(
|
||||
log_level: Annotated[str, typer.Option()] = "INFO",
|
||||
llm_timeout: Annotated[int, typer.Option()] = 600,
|
||||
) -> None:
|
||||
"""Run the Signal command and control bot."""
|
||||
configure_logger(log_level)
|
||||
signal_api_url = getenv("SIGNAL_API_URL")
|
||||
@@ -218,7 +221,7 @@ def main(log_level: Annotated[str, typer.Option()] = "INFO") -> None:
|
||||
|
||||
with (
|
||||
SignalClient(config.signal_api_url, config.phone_number) as signal,
|
||||
LLMClient(model=llm_model, host=llm_host, port=llm_port) as llm,
|
||||
LLMClient(model=llm_model, host=llm_host, port=llm_port, timeout=llm_timeout) as llm,
|
||||
):
|
||||
registry = DeviceRegistry(signal, engine)
|
||||
run_loop(config, signal, llm, registry)
|
||||
|
||||
Reference in New Issue
Block a user