I am doing some experiments with LLM on Dagger (local Docker model).
I want to export the result into a Directory type, using export in terminal.
I struggled a lot and I found out the issue was quite funny, let's say.
Here is the code
func (m *BaseAiAgent) GoAdvancedProgram(
assignment string,
) *dagger.Directory {
environment := dag.Env().
WithStringInput("assignment", assignment, "the assignment to complete").
WithContainerInput(
"builder",
dag.Container().From("golang").WithWorkdir("/app"),
"a container to use for building Go code").
WithDirectoryOutput("completed", "the completed assignment in the Golang container")
prompt := dag.CurrentModule().
Source().
File("prompts/create_go_app.md")
work := dag.LLM().
WithEnv(environment).
WithPromptFile(prompt)
return work.
Env().
Output("completed").
AsDirectory()
This code does not work, it fails in the export step
However fix was quite simple, basically exporting the directory from the container output.
Is there something I did not fully get from the doc?
func (m *BaseAiAgent) GoAdvancedProgram(
assignment string,
) *dagger.Directory {
environment := dag.Env().
WithStringInput("assignment", assignment, "the assignment to complete").
WithContainerInput(
"builder",
dag.Container().From("golang").WithWorkdir("/app"),
"a container to use for building Go code").
WithContainerOutput("completed", "the completed assignment in the Golang container")
prompt := dag.CurrentModule().
Source().
File("prompts/create_go_app.md")
work := dag.LLM().
WithEnv(environment).
WithPromptFile(prompt)
return work.
Env().
Output("completed").
AsContainer().Directory("/app")