-
Notifications
You must be signed in to change notification settings - Fork 20
Split by LLM #1319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split by LLM #1319
Conversation
f98b5db
to
a47db84
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1319 +/- ##
==========================================
+ Coverage 69.12% 69.14% +0.02%
==========================================
Files 283 283
Lines 21533 21543 +10
==========================================
+ Hits 14884 14896 +12
+ Misses 6214 6211 -3
- Partials 435 436 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
bf55d83
to
46141ad
Compare
"exit_uuid": "959d6e4c-658a-49fc-a80d-5ed7df5af640" | ||
} | ||
], | ||
"default_category_uuid": "a766ac1a-766f-4ce5-be4c-a24061bfdec0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<CANT>
would also go here into Other
if the LLM can't do what you've asked
flows/actions/call_llm.go
Outdated
} else { | ||
run.Locals().Set("_llm_status", "failure") | ||
run.Locals().Set("_llm_output", "") | ||
run.Locals().Set(LLMOutputLocal, LLMOutputFailed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot that router rules have one operand... so need a single value that describes successful output as well as failure
Damn @rowanseymour this is really great. Nice work. |
Trying to put it all together and document it to help with adding support on the editor side...
@locals
is now a thing in the context. For now the values of locals are limited to text values. The names are limited to snaked names (^[a-z_][a-z0-9_]{0,63}$
).@locals.foo_bar_1
etc.There is an action
set_run_local
which is a lot likeset_run_result
but writes a local variable and has three operations (set
,increment
andclear
).increment
tries to make it easier to build counters because it assumes zero for undefined values.These don't produce any events because there's nothing for the caller to do and we're trying to keep locals more lightweight than results.
There is a new
call_llm
action which is completely generic and just takesinstructions
andinput
. It saves its output to a local variable called@locals._llm_output
. It produces either anllm_called
event or anerror
event. In the latter case it sets@locals._llm_output
to<ERROR>
.Instead of creating HTTP logs like we've always done for classifiers, airtime etc this generates an
llm_called
event like below. If in future we decide we sometimes need HTTP logs for debugging it could be selective (see #1332).To avoid always storing raw LLM prompts in flow definitions, there's a new function called
prompt
to return pre-defined prompts that we can iterate on over time.If that function is used on a split node it can access the node's category names via new context value
@node.categories
. We've also added theslice(array, start [,end])
expression function to allow trimming off theOther
andFailure
categories:These pieces can be combined into an "Split By LLM" node which splits on any value in the context (set as the
input
of thecall_llm
action):call_llm
action could be an addable action in its own right and usable for generating responses if that's your cup of tea.Wait and then Split By LLM
node but that was forgetting that waits always come after actions. Having the wait and the split be two different nodes is how classifiers work and so this should be a drop in replacement for the few users still hanging on to classifiers. It also lends itself to using the first wait to split on non-LLM logic and save LLM calls.prompt
function gets prompt text from the environment which in turn gets it from the engine which exposes it as an option - so we can have a master store of LLM prompts in mailroom.