#LLM authentication issues on custom function invocation

1 messages · Page 1 of 1 (latest)

elder jackal
#

Disclaimer: I'm very new to Dagger, therefore I cannot tell if I'm hitting a bug or doing it wrong.

I'm developing a Dagger module in Go which interacts with LLMs from different models and providers, and I'm hitting authentication issues. I simplified my module to a single function and still hit the issue:

func (m *Example) Test(ctx context.Context, model string) (string, error) {
    return dag.LLM().WithModel(model).WithPrompt("testing").LastReply(ctx)
}

Launching dagger and calling test "gpt-4o-mini" fails with a 401. However if I interact with the LLM from dagger shell first, and call my custom function second, then authentication works as expected:

> dagger
Dagger interactive shell. Type ".help" for more information. Press Ctrl+D to exit.

✔ llm | with-model "gpt-4o-mini" | with-prompt "test" | last-reply 0.8s
It looks like you're testing the system! How can I assist you today?

✔ test "gpt-4o-mini" 1.3s
It looks like you’re testing the chat! How can I assist you today?

My API keys are in a .env file at the root of my Dagger module. The version is the following:

> dagger version
dagger v0.18.2 (docker-image://registry.dagger.io/engine:v0.18.2) darwin/arm64
#

LLM authentication issues on custom function invocation

compact linden
#

👋 Hi Arnaud 🙂

There's a limitation in the .env implementation that makes it work only if it's in the working directory of the client. So you could be hitting that.

Technically .env support is "hidden" until it works properly. One way to isolate is to try setting LLM auth in regular env variables, and see if the problem goes away

elder jackal
#

hey @compact linden 🙂 It unfortunately doesn't seem to make a difference (i.e., calling the llm from the dagger shell works, which indicates that the key is correctly taken from the env, but my custom function fails when called first)

compact linden
#

@elder jackal could you try with dag.LLM(dagger.LLMOpts{Model: model}) instead of WithModel, just in case there's a bug in the latter?

elder jackal
#

I'm triple checking but it seems to fix it indeed

#

thanks!

compact linden
harsh mortar