https://www.boundaryml.com logo
🟑 Does BAML allow for integrating web search tool...
# questions
p
In BAML, you'd simply define the list of tools you want as an enum (with a fallback tool that prints "unsure", so that you can handle it appropriately). And then call the tool via a routing function whose output signature is the enum. https://docs.boundaryml.com/examples/prompt-engineering/tools-function-calling
v
Yep! It works with native tools as well! You just add them to the client definition
Within options parameter
options { tools [{ type web_search }] }
p
Oooh! Nice!
b
Okay that's actually awesome! Native tool support - so we can mix native JSON mode and SAP But Vabihav what is your take on this? What yields better reliability / performance? Pros/cons of doing the routing ourselves with BAML vs Native tool calling?
j
Thanks @Vaibhav (BAML πŸ‘) As per the feedback above we can able to use the websearch functionality using the below client defintion. client WebSearchClient { provider openai-responses options { model "gpt-4.1" tools [ { type "web_search_preview" } ] } } As the external tool of tavilyextract or other endpoints from their services cannot be able to called as a separate tool Could you please guide me in this https://docs.boundaryml.com/examples/prompt-engineering/tools-function-calling
Is any of other options available to do the website extract similar to tavilyextract that supports within the BAML where we don't want to write a separate service for this. @Vaibhav (BAML πŸ‘)
v
What do you mean? If you can share example python code, we may be able to help and better understand as well!
j
Thansk for replying , Our requirement is to use the tavilyextract within the baml, API details for that service - https://docs.tavily.com/documentation/api-reference/endpoint/extract Currently we can able to extract it via separate service and ingest into the .baml to get the response We are checking the possibility of integrating the API within the .baml via client is it possible @Vaibhav (BAML πŸ‘)
v
Sadly for this you can’t do it within the client directly yet. You would need to define a data model that is the tool shape, and then call it and then pass it back into the function call again
t
How to pass "tools": [{ "type": "web_search_preview" }] using azure-openai provider ?
@Vaibhav (BAML πŸ‘)
v
You just add that to your client definition!
And it will β€œjust work”
t
@Vaibhav (BAML πŸ‘) client AzureOpenAIWithWebTool { provider azure-openai options { resource_name "openai" deployment_id "gpt-4o" api_version "2025-01-01-preview" api_key env.AZURE_OPENAI_API_KEY tools [ { type "web_search" } ] } } Getting error: Unspecified error code: 400 Request failed with status code: 400 Bad Request, { "error": { "message": "Invalid value: 'web_search'. Supported values are: 'function' and 'custom'.", "type": "invalid_request_error", "param": "tools[0].type", "code": "invalid_value" } } Request options: {"tools":[{"type":"web_search"}],"max_tokens":4096}
v
Does azure models support web search? Can you share the docs?
v
Huh. This looks like it doesn’t mimic the chat completion or responses api. curl --request POST \ --url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/assistants?api-version=$API_VERSION \ -H "Authorization: Bearer $AGENT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "instructions": "You are a helpful agent.", "name": "my-agent", "model": "gpt-4o", "tools": [ { "type": "bing_grounding", "bing_grounding": { "search_configurations": [ { "connection_id": "", "count": 7, "market": "en-US", "set_lang": "en", "freshness": "7d", } ] } } ] }'
It looks more like the assistant api which I think openai has deprecated
t
Ahh i had azure credits, might have to switch to some other provider which can help with web search
v
Sadly yes. I think Google has something!
t
This seems to be working, but i am not sure if google search tool is actually getting used. client GoogleGeminiWithWebSearch { provider google-ai options { api_key env.GEMINI_API_KEY model "gemini-2.5-flash" allowed_roles ["system", "user"] tools [ { google_search {} } ] } }
also is there a way to extract out these searches. https://ai.google.dev/gemini-api/docs/google-search: When a response is successfully grounded, the response includes a groundingMetadata field. This structured data is essential for verifying claims and building a rich citation experience in your application.
v
yep! for accessing the raw http response you can do it either via: https://docs.boundaryml.com/guide/baml-advanced/modular-api or via collector: https://docs.boundaryml.com/guide/baml-advanced/collector-track-tokens which gives you access via:
collector.last.calls[-1].http_response
t
@Vaibhav (BAML πŸ‘) Thanks, but seems like HTTP does not have this support yet ?
v
oh you mean the rest api?
yes sadly that isn't available via the rest api πŸ™
what language do you use btw?
t
Ahh, Java
v
got it. yes sadly the trade off of type-safety over REST api makes certain thinks tricky to expose. we hopefully we be able to do most languages natively soon-ish. We are about to land rust, and i think java/ruby/next should be good.
t
Do we have any raw api exposed ? like just json string in the response ? so that we can parse if the data is avaialble
v
not yet. i can see if we can jsut expose an api for the modular api via rest, then it should work similarly
will need to discuss with the team!
t
Thanks, any work around should be fine.
Hey @Vaibhav (BAML πŸ‘), Any update for me 🀞
@Vaibhav (BAML πŸ‘) 🫣
v
hey @thegamedefault we haven't been able to prioritize getting the modular api exposed on the REST client yet πŸ™
i'll flag it again and see if we can design something here. sadly it a bit more design work to do this (hence why it was deprioritized). Generally we try and do things that don't require any design work ASAP, with designed stuff we end up needing to think about long term extensibility since we try our best with BAML to never do breaking changes.
t
Any experimental api will also work
5 Views