gpt-image-2 multi-image + fix: tools need reasoning_effort none on gpt-5.6 (ggg mute bug)

This commit is contained in:
Oleksandr Kozachuk
2026-07-13 16:17:00 +02:00
parent ae870db181
commit 7e6eae10ee
15 changed files with 220 additions and 88 deletions
+10 -9
View File
@@ -123,6 +123,7 @@ class AIResponse(AIMessageBase):
self.channel = channel
self.staff = staff
self.picture = picture
self.picture_count = 1
self.picture_edit = picture_edit
self.hack = hack
self.vars = ["answer", "answer_needed", "channel", "staff", "picture", "hack"]
@@ -188,15 +189,15 @@ class AIResponder(AIResponderBase):
messages.append({"role": "user", "content": content})
return messages
async def draw(self, description: str) -> BytesIO:
async def draw(self, description: str, count: int = 1) -> List[BytesIO]:
if self.config.get("leonardo-token") is not None:
return await self.draw_leonardo(description)
return await self.draw_openai(description)
return [await self.draw_leonardo(description)] # single image only, behind config
return await self.draw_openai(description, count)
async def draw_leonardo(self, description: str) -> BytesIO:
raise NotImplementedError()
async def draw_openai(self, description: str) -> BytesIO:
async def draw_openai(self, description: str, count: int = 1) -> List[BytesIO]:
raise NotImplementedError()
async def post_process(self, message: AIMessage, response: Dict[str, Any]) -> AIResponse:
@@ -221,6 +222,10 @@ class AIResponder(AIResponderBase):
bool(response.get("picture_edit", False)),
bool(response.get("hack", False)),
)
try:
response_message.picture_count = max(1, min(int(response.get("picture_count") or 1), 4)) # IMG-02
except (TypeError, ValueError):
response_message.picture_count = 1
if response_message.staff is not None and response_message.answer is not None:
response_message.answer_needed = True
if response_message.channel is None:
@@ -250,9 +255,6 @@ class AIResponder(AIResponderBase):
"""Cheap reply/factual/emoji pre-pass (BEH-01); None = fail open."""
raise NotImplementedError()
async def translate(self, text: str, language: str = "english") -> str:
raise NotImplementedError()
@staticmethod
def _entry_channel(item: Dict[str, Any]) -> Optional[str]:
try:
@@ -299,11 +301,10 @@ class AIResponder(AIResponderBase):
await asyncio.to_thread(self.store.save_history, self.channel, list(self.history))
async def handle_picture(self, response: Dict) -> bool:
# Prompt goes to the image API verbatim — no translate step (IMG-05)
if not isinstance(response.get("picture"), (type(None), str)):
logging.warning(f"picture key is wrong in response: {pp(response)}")
return False
if response.get("picture") is not None:
response["picture"] = await self.translate(response["picture"])
return True
def _parse_answer(self, answer: Dict[str, Any]) -> Optional[Dict[str, Any]]: