Is it possible to use LangChain.NativeTools?
I tried creating the following resource to build a simple lookup prompt action. The idea is that someone can put some search term into it and have the LLM look up the NPI registry information using a Google search. The LangChain docs show a usage example here and I tried recreating it with an Ash resource here:
This seems to fail the Spark validation here. Is there a way we can support something like this or am I just missing how to do it? I'd be happy to work on adding it but I'm not sure if this is something you'd want to support and I'm not super familiar with defining Spark schemas (though I'd be happy to try!).
Thanks!
GitHub
ash_ai/lib/ash_ai.ex at main · ash-project/ash_ai
Structured outputs, vectorization and tool calling for your Ash application - ash-project/ash_ai
Solution:Jump to solution
It's slightly more verbose but converting it to a generic action wasn't so bad:
```elixir
defmodule Prism.NPI.Lookup do
use Ash.Resource, extensions: [AshAi], domain: Prism.NPI...
4 Replies
Looking at the code, tools only takes a list of
atoms
atm. Could you open an issue on gh with a feature request please.
In the meantime, you can just call Langchain yourself in a generic action instead of going through prompt
Thanks, I'll open a feature request and refactor to a generic action for now
Solution
It's slightly more verbose but converting it to a generic action wasn't so bad:
I had to replace the markdown code fences with double backticks from triple backticks so that the Markdown rendering isn't confused (you'd replace them with triple backticks in the actual code), but otherwise this example should work with Gemini models, at least. I'll mark this as the solution for now since it works. Thanks for the help Barnabas!