https://www.boundaryml.com logo
🟢 Role Type Handling in Jinja for Gemini
# questions
a
is it possible to avoid doing this for gemini (using model role instead of assistant) - or to be able to check the provider within jinja template to know what type to use?
Copy code
{{ _.role("model" if message.role == "assistant" else message.role) }}
v
i think so! Let me give you the hidden option!
g
@anerli Do you want something like this?
Copy code
{{ ctx.client.provider }}
{% if (ctx.client.privoder == "openai") %}
  {{ _.role("user") }}
  It is openai
{% else %}
  {{ _.role("assistant")}}
  It is not openai
{% endif %}
Unfortunately this doesn't work for me -
ctx.client.provider == "openai"
returns false in the
if
block even though
{{ ctx.client.provider }}
returns
"openai"
.
a
yes something like that would work, or alternatively if BAML translated assistant to provider-equivalents (like gemini with "model') automatically, that might be a better experience. being able to check provider and have this be explicit might be clearer though
v
a
ohh nice, cool vid lol
this patch gonna be out soon?