Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions preprocessors/object-detection-llm/object-detection-llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,14 @@ def detect_objects():
if error:
return jsonify(error), error["code"]

# leaving list here since not sure which one(s) might be useful for
# preventing endless responses, but when enabled, these definitely
# prevented Qwen from generating valid return messages.
stop_tokens = [
"<|im_end|>", # Qwen's end token
"<|endoftext|>", # Alternative end token
"\n\n\n", # Triple newline
"```", # Code block end
# "<|im_end|>", # Qwen's end token
# "<|endoftext|>", # Alternative end token
# "\n\n\n", # Triple newline
# "```", # Code block end
]

try:
Expand Down
3 changes: 3 additions & 0 deletions utils/llm/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
import os
import json
import logging
from config.logging_utils import configure_logging
from openai import OpenAI
from typing import Optional, Dict, Any, Union

configure_logging()

class LLMClient:
"""Generic wrapper for OpenAI-compatible API clients."""
Expand Down Expand Up @@ -160,6 +162,7 @@ def chat_completion(

logging.debug(f"Making LLM request to model: {self.model}")
response = self.client.chat.completions.create(**params)
logging.pii(response)

# Validate and extract response
response_text = self._validate_response(response)
Expand Down