0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

GLM-5.4 のスクショ検証:CSS 修正と画像の読み取り

0
Last updated at Posted at 2026-11-23

この記事は AIHubMix が作成しました。2026年11月23日 10:07 UTC に、GLM-5.4 にコードだけを渡した場合と、同じコードにスクリーンショットを添えた場合を1回ずつ試しました。どちらも HTTP 200 で、リクエストのモデル ID は coding-glm-5.4、応答のモデル ID は glm-5.4 でした。

TL;DR

  • どちらも右端のはみ出しを特定し、box-sizing: border-box を返しました。別々に適用すると、どちらのボタンも幅352pxから320pxに収まりました。
  • コードには含めなかった注文番号を、画像付きの回答は TXA-B4M と正確に読み取りました。コードだけの回答は指示どおり null でした。

注文番号を入れるのはブラウザー用のコピーだけ

検証には架空の注文を使います。以下の HTML と質問文は実測時のものより短く、同じはみ出しを再現できますが、トークン数は一致しません。モデルに渡す checkout.html には {{ORDER_REF}} を残してください。

checkout.html
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Checkout</title>
<style>
  .panel { width: 320px; margin: 32px auto; outline: 2px solid #687f7a; }
  .pay {
    display: block; width: 100%; height: 48px;
    padding: 0 16px; border: 0; box-sizing: content-box;
  }
</style>
<main class="panel">
  <p>Order ref: {{ORDER_REF}}</p>
  <button class="pay">Pay $12.00</button>
</main>
</html>

同じディレクトリに prepare.py を保存し、python3 prepare.py を実行します。テキストのみと画像付きの2件で一組です。新しい組を試すときは番号も作り直します。

prepare.py
from pathlib import Path
from secrets import token_hex

template = Path("checkout.html").read_text(encoding="utf-8")
reference = token_hex(4).upper()
Path("rendered.html").write_text(
    template.replace("{{ORDER_REF}}", reference), encoding="utf-8"
)

Chrome で rendered.html を開き、表示領域の幅を390px、ズームを100%にします。ボタンと番号が両方写るようにスクリーンショットを撮り、同じディレクトリに before.png として保存します。下の画像は実験時のものです。再検証には新しい番号が写った手元の画像を使ってください。

画像付きのリクエストに添えた決済画面。注文番号 TXA-B4M の下でボタンがパネルの右側にはみ出しています。

画像付きのリクエストにだけ before.png を添付する

Python に openai をインストールし(python3 -m pip install openai)、残高のあるテストアカウントのキーを環境変数 AIHUBMIX_API_KEY に設定します。接続先の設定は AIHubMix のクイックスタート にあります。

下のファイルを python3 compare.py で実行します。POST /v1/chat/completions に送るモデル ID は coding-glm-5.4、出力の上限は1,800トークンです。どちらも温度は指定せず、会話履歴を引き継ぎません。

compare.py
import base64
import os
from pathlib import Path
from openai import APIStatusError, OpenAI

template = Path("checkout.html").read_text(encoding="utf-8")
if template.count("{{ORDER_REF}}") != 1:
    raise ValueError("Use the unfilled checkout.html template")
question = (
    "390px viewport. Which edge of .panel does .pay cross? Give one CSS "
    "declaration that keeps the button full width and both 16px paddings. "
    "Read the order reference only if visible in a screenshot, else use null. "
    "Return JSON with keys edge, property, value, order_ref.\n\n"
)
text = {"type": "text", "text": question + template}
png = base64.b64encode(Path("before.png").read_bytes()).decode("ascii")
image = {"type": "image_url", "image_url": {"url": "data:image/png;base64," + png}}
client = OpenAI(
    base_url="https://aihubmix.com/v1",
    api_key=os.environ["AIHUBMIX_API_KEY"],
    max_retries=0,
)
for name, parts in (("text", [text]), ("image", [text, image])):
    try:
        reply = client.chat.completions.create(
            model="coding-glm-5.4",
            messages=[{"role": "user", "content": parts}],
            max_tokens=1800,
        )
        print(name, reply.choices[0].message.content)
    except APIStatusError as error:
        print(f"{name}: HTTP {error.status_code}")

応答とトークン数

GLM Coding Plan の告知 は、プランでの画像対応についてです。AIHubMix のチャネル仕様 にも画像入力の記載はありますが、画像認識が検証済みかを示すフラグは公開されていません。今回の経路でこの PNG が読めたかは、返ってきた注文番号を照合して確かめました。トークン数はゲートウェイが報告した値です。

入力 はみ出した側 注文番号 入力トークン 出力トークン
コードのみ 右 null 573 28
コードと画像 右 TXA-B4M 743 66

同じテキストにこの画像を追加したときの差は、入力の170トークンです。出力の長さの差は含みません。どちらの応答にもキャッシュヒットの報告はありませんでした。

ハマりどころ

画像付きの回答をそのまま JSON として読めない

実測時、コードだけの回答はそのまま読める JSON でした。画像付きの回答では JSON が Markdown のコードブロックに入っていました。プログラムから読む場合は、前後のフェンスを取り除いてから解析してください。

右端を特定しても、画像を読めたかは分からない

width: 100% と content-box の組み合わせでは、中身だけでパネルの幅320pxを使い切ります。ボタンには枠線がなく、左右に16pxずつ余白が付くので、全体の幅は352pxです。ボックスモデルの計算 に画像は要りません。読み取りは order_ref で判定します。

ボタンは収まったのに左右の余白がない

余白をゼロにしても、はみ出しは消えます。回答ごとに未修正の rendered.html をコピーし、提案された宣言を一つだけ適用してください。Chrome の getBoundingClientRect() でパネルとボタンの left 同士、right 同士を比べます。合格条件は、左右とも差が1 CSS ピクセル以内で、余白が各16px、表示が「Pay $12.00」のままであることです。

今回の2件は、左右の差がいずれも0pxで、余白も表示も変わりませんでした。下の画像は、画像付きの回答が返した CSS を適用して Chrome で描画したものです。モデルが PNG を編集したわけではありません。コードだけの回答でも描画結果は同じでした。

画像付きの回答が提案した CSS を適用した後の Chrome の表示。決済ボタンの左右の端がパネルとそろっています。

まとめ

  • この画面では、注文番号を読むには画像が必要でした。ボタンを直すにはコードだけで足りました。この一組から他の画面での精度までは判断できません。
  • 番号が合っていても、CSS の修正が効いたかは別です。それぞれの回答を同じ表示幅で試してください。

手元で比較するなら、番号を差し替えた直後、CSS を直す前に before.png を撮り直してください。両方のリクエストで読むファイルは、未置換の checkout.html です。

参考

  1. モデルに送った元の決済画面・回答の CSS を適用した決済画面(AIHubMix):表示幅と注文番号は同じです。
  2. coding-glm-5.4 のチャネル仕様(AIHubMix)
  3. GLM Coding Plan の画像対応の告知(Zixuan Li)
  4. box-sizing(MDN Web Docs)
  5. getBoundingClientRect()(MDN Web Docs)

あわせて読みたい

GLM-5.4 で CSS を直すときのモデル ID と料金

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?