#model returning file output
1 messages ยท Page 1 of 1 (latest)
From the model POV it only has the string you gave it, and no other tools. What I'd do in this case is give it an empty directory to write the file into, like with-directory-input dest $(directory)
also, lol @ it trying File#42
with-directory-input or output ?
gotcha
then the model should call something like dest.withNewFile("foo", "Guillaume").file("foo") and return it
outputs are only exposed through the return tool - it still needs a pathway to getting that File ID that it can pass in
alternatively you could expose all of Query to it, and it'd probably figure it out, just at a higher time/token cost
yeah no i'll do dir input
do i still have to specify with-file-output in addition to dir input ?
yeah. well, depends on what you're trying to do, but it's orthogonal. there's another way to get the last value out ($llm | bind-result doesnt-matter | as-file), but if you're trying to ensure it's calling the return tool, you'll still need to declare the desired output, and if you don't have the output, it won't know that you want it as a file. outputs effectively become part of your entire prompt
In the version where i didnt specify an output, only two input variables (name and dir):
โ e=$(env | with-string-input name Guillaume "The name of the person to greet" | with-directory-input dir $d "the directory to put a greeting.txt file into") 0.0s
โ r=$(llm | with-env $e | with-prompt "You have access to a name input variable and a dir directory variable. I want you to greet the person with the given name, in a language other than English.") 12.8s
โ๐ง You have access to a name input variable and a dir directory variable. I want you to greet the person with the given name, in a language other than English.
โ โ 0.0s
โ
โ๐ค 7.3s โ Input Tokens: 267 โ Output Tokens: 10
โ โ name: String! 0.0s
โ๐ค 0.6s โ Input Tokens: 287 โ Output Tokens: 10
โ โ dir: String! 0.0s
โ๐ค 2.4s โ Input Tokens: 1,949 โ Output Tokens: 31
โ โ .withNewFile(contents: "Bonjour, Guillaume!", path: "/greeting.txt", permissions: 420): Directory! 0.0s
โ๐ค I've created a greeting for Guillaume in French: "Bonjour, Guillaume!" and saved it in a file named greeting.txt .
โ โ 2.5s
LLM@xxh3:6ec50292fb4cf582
โ $r | env | input dir | as-directory | file /greeting.txt 0.0s
! input: directory.file /greeting.txt: no such file or directory
โ โ Directory.file(path: "/greeting.txt"): File! 0.0s
โ ! /greeting.txt: no such file or directory
! input: directory.file /greeting.txt: no such file or directory
i'll try bind-result
that bind-result API is mostly an implementation detail of how $_ works in the shell, fwiw - wouldn't rely on it in production code. just pointing it out for illustrative purposes
โ $r | bind-result foo | as-directory | file /greeting.txt | contents 0.0s
Bonjour, Guillaume!
this worked
sweet
is there a way i can make it work with "input"/"output" env api ?
$r | env | output result | as-file | contents
so assuming with-env contained name, dir as input vars and result as output file ?
yep