mirror of
https://github.com/RichieCahill/dotfiles.git
synced 2026-04-17 13:08:19 -04:00
fixed tree fmt and removed chat with images
This commit is contained in:
@@ -95,9 +95,9 @@ def handle_inventory_update(
|
||||
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(
|
||||
raw_response = llm.chat(
|
||||
IMAGE_PROMPT,
|
||||
image_data,
|
||||
image_data=image_data,
|
||||
system=SYSTEM_PROMPT,
|
||||
)
|
||||
source_type = "receipt_photo"
|
||||
|
||||
@@ -48,8 +48,8 @@ class DeviceRegistry:
|
||||
|
||||
def is_verified(self, phone_number: str) -> bool:
|
||||
"""Check if a phone number is verified."""
|
||||
# if entry := self._cached(phone_number):
|
||||
# return entry.trust_level == TrustLevel.VERIFIED
|
||||
if entry := self._cached(phone_number):
|
||||
return entry.trust_level == TrustLevel.VERIFIED
|
||||
device = self.get_device(phone_number)
|
||||
return device is not None and device.trust_level == TrustLevel.VERIFIED
|
||||
|
||||
@@ -57,9 +57,9 @@ class DeviceRegistry:
|
||||
"""Record seeing a device. Creates entry if new, updates last_seen."""
|
||||
now = utcnow()
|
||||
|
||||
# entry = self._cached(phone_number)
|
||||
# if entry and entry.safety_number == safety_number:
|
||||
# return
|
||||
entry = self._cached(phone_number)
|
||||
if entry and entry.safety_number == safety_number:
|
||||
return
|
||||
|
||||
with Session(self.engine) as session:
|
||||
device = session.execute(
|
||||
@@ -94,8 +94,8 @@ class DeviceRegistry:
|
||||
|
||||
def has_safety_number(self, phone_number: str) -> bool:
|
||||
"""Check if a device has a safety number on file."""
|
||||
# if entry := self._cached(phone_number):
|
||||
# return entry.has_safety_number
|
||||
if entry := self._cached(phone_number):
|
||||
return entry.has_safety_number
|
||||
device = self.get_device(phone_number)
|
||||
return device is not None and device.safety_number is not None
|
||||
|
||||
|
||||
@@ -26,24 +26,17 @@ class LLMClient:
|
||||
self.temperature = temperature
|
||||
self._client = httpx.Client(base_url=f"http://{host}:{port}", timeout=120)
|
||||
|
||||
def chat(self, prompt: str, *, system: str = "") -> str:
|
||||
def chat(self, prompt: str, image_data: bytes | None = None, system: str | None = None) -> str:
|
||||
"""Send a text prompt and return the response."""
|
||||
messages: list[dict[str, Any]] = []
|
||||
if system:
|
||||
messages.append({"role": "system", "content": system})
|
||||
messages.append({"role": "user", "content": prompt})
|
||||
return self._generate(messages)
|
||||
|
||||
def chat_with_image(self, prompt: str, image_data: bytes, *, system: str = "") -> str:
|
||||
"""Send a prompt with an image and return the response.
|
||||
user_msg = {"role": "user", "content": prompt}
|
||||
if image_data:
|
||||
user_msg["images"] = [base64.b64encode(image_data).decode()]
|
||||
|
||||
Requires a vision-capable model (e.g. qwen3-vl).
|
||||
"""
|
||||
encoded = base64.b64encode(image_data).decode()
|
||||
messages: list[dict[str, Any]] = []
|
||||
if system:
|
||||
messages.append({"role": "system", "content": system})
|
||||
messages.append({"role": "user", "content": prompt, "images": [encoded]})
|
||||
messages.append(user_msg)
|
||||
return self._generate(messages)
|
||||
|
||||
def _generate(self, messages: list[dict[str, Any]]) -> str:
|
||||
|
||||
Reference in New Issue
Block a user