Simple prompt in custom action or iex shell

I can't seem to figure out how to do a simple prompt i.e. one prompt - one response. What would be the simplest way using AshAi? How could I do it directly in shell? I was playing around AshAi.Actions.Prompt.run/3 but couldn't grok it.
action :my_action do
run fn input, context ->
...
action :my_action do
run fn input, context ->
...
this is how my action starts. not sure if I can put somewhere the builtin prompt call :thinkies:
3 Replies
ZachDaniel
ZachDaniel4mo ago
Running the action does the prompt Did you try running it?
ken-kost
ken-kostOP4mo ago
I did try but since its oban triggered I don't see what breaks, so I tried in shell using the run. I see what breaks but still can't figure out how to fill the call. how could I do a custom prompt and process the response after it, also custom, in my custom action
ZachDaniel
ZachDaniel4mo ago
Ah, so if thats what you want to do I think you want to write your own calls to LangChain The way that AshAi works with the prompt action, is tha tyou provide a return type to the action
action :my_action, :atom do
constraints [one_of: [:positive, :negative]]

run prompt(....)
end
action :my_action, :atom do
constraints [one_of: [:positive, :negative]]

run prompt(....)
end
You don't post-process the output, you get that type of data back so it works like a black-box Ash action You can customize the prompt though
action :my_action, :atom do
constraints [one_of: [:positive, :negative]]

run prompt(...., prompt: {"system_prompt", "user_message"})
end
action :my_action, :atom do
constraints [one_of: [:positive, :negative]]

run prompt(...., prompt: {"system_prompt", "user_message"})
end
those are eex templates run prompt(...., prompt: {"<%= @input.arguments.... %>", "user_message"})

Did you find this page helpful?