#model returning file output

1 messages ยท Page 1 of 1 (latest)

normal anchor
#

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

viral cliff
#

with-directory-input or output ?

normal anchor
#

model returning file output

#

input - so it gets exposed to it

viral cliff
#

gotcha

normal anchor
#

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

viral cliff
#

yeah no i'll do dir input

#

do i still have to specify with-file-output in addition to dir input ?

normal anchor
#

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

viral cliff
#

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

normal anchor
#

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

viral cliff
#
โœ” $r | bind-result foo | as-directory | file /greeting.txt | contents 0.0s
Bonjour, Guillaume!

this worked

normal anchor
#

sweet

viral cliff
#

is there a way i can make it work with "input"/"output" env api ?

normal anchor
#

$r | env | output result | as-file | contents

viral cliff
#

so assuming with-env contained name, dir as input vars and result as output file ?

normal anchor
#

yep

viral cliff
#

worked, thanks!

#

weird that i have to specify a directory for it to write the file, but i guess i understand now how it works underneath

#

we should improve this by autoproviding it an empty dir somehow, do you agree?