https://www.boundaryml.com logo
Hey guys i had a question about the
# questions
o
Hey guys i had a question about the Client Registry when trying to specify primary and fallback models at runtime. This is the code @Vaibhav (BAML 🐑) pointed us towards to achieve this.
Copy code
from baml_py import Collector, ClientRegistry

prim_model = "NOCDGPT41Nano"
fallback_models = ["NOCDGPT4o","NOCDGPT41Mini"]
cr = ClientRegistry()
collector = Collector(name="fallback-collector-test")
cr.add_llm_client(name=prim_model,provider='fallback',options={
    "strategy": list(fallback_models)
})
cr.set_primary(prim_model)

res = b.PingModelGPT41(" ",baml_options={"client_registry":cr})
The issue that I am having with this code is that every time I specify a primary model, BAML will always use the first fallback. Even when switching the given fallback with the primary model, it will still go use the first fallback meaning that BAML is just skipping using the primary model. Has anyone else experienced this? Please let me know. Thank you!
a
can you try grabbing the 'curl' request from the playground for your primary client, and calling the llm from your terminal?
does it work?
o
calling the function from the playground and via curl request in the terminal works if thats what you are referring to. i am not sure of how to look at a client itself in the playground as i thought the playground was only for functions and tests
a
ok this may be a bug with fallbacks in ClientRegistry, we'll see if we can repro
o
sounds good, thank you!
Hey just wanted to follow up and ask if this was taken a look at. The client registry is pretty critical to our LLM projects. Another issue with the ClientRegistry we find pretty import was this Github issue i sent last month. If you could take a look at this as well and try to confirm the bug. Thank you! Link: https://github.com/BoundaryML/baml/issues/2105?utm_source=chatgpt.com
a
we will be taking a look this friday
fyi @ba11b0y is taking a look now!
b
@omar NOCD I think there's a semantic misunderstanding here. I think you might want to declare a fallback client with
NOCDGPT41Nano
as the first client which gets called
Copy code
# Fallback client with multiple fallback models
cr.add_llm_client(name='FallbackClient', provider='fallback', options={
    "strategy": ["NOCDGPT41Nano", "NOCDGPT4o", "NOCDGPT41Mini"],
})

# Set the primary client
cr.set_primary('FallbackClient')
res = b.PingModelGPT41(" ",baml_options={"client_registry":cr})
Does that make sense? I think that also solves the above GitHub issue
You can also refer to this example in the docs here https://docs.boundaryml.com/ref/baml_client/client-registry