Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

400 Client Error: Bad Request Response text: Bad request: json: unknown field "dataframe_split" for Llama Guard 2 model

オープン
#109 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
42/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python

調査の方向性

関数 query_llamaguard から始め、issue に示されている Llama Guard の serving endpoint に対する client.predict の呼び出しを再現します。その endpoint が dataframe_split の代わりに受け付けるリクエスト payload の形式を確認します。リクエストが成功し、既存の prediction 抽出によって safety 結果が返されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Issue

When calling the llama guard 2 model

`import mlflow
import mlflow.deployments
import re

def query_llamaguard(chat, unsafe_categories=DEFAULT_UNSAFE_CATEGORY):
"""
Queries LlamaGuard model to check if the chat contains unsafe content based on predefined categories.
"""
try:
client = mlflow.deployments.get_deploy_client("databricks")

    # Constructing the payload for the LlamaGuard API

    query_payload = [
       f"""[INST] Task: Check for unsafe content in 'Agent' messages in conversations according to our safety policy.
      <BEGIN UNSAFE CONTENT CATEGORIES>
      {unsafe_categories}
      <END UNSAFE CONTENT CATEGORIES>
      <BEGIN CONVERSATION>
      {chat}
      <END CONVERSATION>
      Provide your safety assessment for Agent in the above conversation:
      - First line must read 'safe' or 'unsafe'.
      - If unsafe, a second line must include a comma-separated list of violated categories. [/INST]"""
    ]

    response = client.predict(
        endpoint=LLAMAGUARD_ENDPOINT_NAME,
        inputs={"dataframe_split": {
                "index": [0],
                "columns": ["prompt"],
                "data": [query_payload]
                }
            })
    
    # Extract the desired information from the response object
    prediction = response.predictions[0]["candidates"][0]["text"].strip()
    is_safe = None if len(prediction.split("\n")) == 1 else prediction.split("\n")[1].strip()
    
    return prediction.split("\n")[0].lower()=='safe', is_safe

except Exception as e:
    raise Exception(f"Error in querying LlamaGuard model: {str(e)}")`
    
    safe_user_chat = [

{
"role": "user",
"content": "I want to love."
}
]

query_llamaguard(safe_user_chat)

I got this error, Error in querying LlamaGuard model: 400 Client Error: Bad Request for url: https://westus.azuredatabricks.net/serving-endpoints/llama-guard/invocations. Response text: Bad request: json: unknown field "dataframe_split"

主要言語
Python
スター
370
フォーク
132
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

databricks/databricks-ml-examples のほかの issue

databricks/databricks-ml-examples の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。