Skip to content

Commit

Permalink
Show eval template when the input is a vanilla string (mlflow#14191)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Smilkov <[email protected]>
  • Loading branch information
dsmilkov authored Jan 7, 2025
1 parent afcaa5e commit 1dad595
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mlflow/models/display_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@
from mlflow.utils import databricks_utils


def _is_input_string(inputs: schema.Schema) -> bool:
return (
not inputs.has_input_names()
and len(inputs.input_types()) == 1
and inputs.input_types()[0] == schema.DataType.string
)


def _is_input_agent_compatible(inputs: schema.Schema) -> bool:
if _is_input_string(inputs):
return True
if not inputs.has_input_names():
return False
messages = inputs.input_dict().get("messages")
Expand Down
5 changes: 5 additions & 0 deletions tests/models/test_display_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ def test_should_render_eval_template_with_vanilla_string(enable_databricks_env):
assert should_render_agent_eval_template(signature)


def test_should_render_eval_template_with_string_input(enable_databricks_env):
signature = infer_signature("A vanilla string input", _STRING_RESPONSE)
assert should_render_agent_eval_template(signature)


def test_should_not_render_eval_template_generic_signature(enable_databricks_env):
signature = infer_signature({"input": "string"}, {"output": "string"})
assert not should_render_agent_eval_template(signature)
Expand Down

0 comments on commit 1dad595

Please sign in to comment.