Skip to content

Commit 36bbdd8

Browse files
fix reply information extract errors when calling gpt-4o
1 parent a337029 commit 36bbdd8

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

scripts/g4f_issue_reply.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,11 @@ def extractconversationid(data: dict[str, Any]) -> str:
324324
'''extractreplytext'''
325325
@staticmethod
326326
def extractreplytext(data: dict[str, Any]) -> str:
327+
if isinstance(messages := data.get("messages"), list):
328+
for message in reversed(messages):
329+
if not isinstance(message, dict): continue
330+
if message.get("role") != "assistant": continue
331+
if isinstance((content := message.get("content")), str) and content.strip(): return content.strip()
327332
candidate_keys = ["reply", "message", "content", "answer", "text", "response", "result", "data"]
328333
for key in candidate_keys:
329334
if isinstance((value := data.get(key)), str) and value.strip(): return value.strip()

0 commit comments

Comments
 (0)