microsoft / TaskWeaver

A code-first agent framework for seamlessly planning and executing data analytics tasks.
https://microsoft.github.io/TaskWeaver/
MIT License
5.38k stars 689 forks source link

Hosting taskweaver online — using environment variables rather than config.json #209

Closed KawniX closed 8 months ago

KawniX commented 9 months ago

Is it possible to set the API Key through .env file instead rather than through the /Project config.json?

Would like to know how I can do this even if I have to edit the src code itself. Thank you!

liqul commented 9 months ago

@KawniX This is supported. You just need to translate the configuration key to upper case and "." to "_". For example, llm.api_base is translated to LLM_API_BASE.

KawniX commented 9 months ago

Is this documented? Can you be more specific with the example? Is it like this?:

{ "llm.api_key": LLM_API_BASE, "llm.model": "gpt-3.5-turbo-0125", "session.max_internal_chat_round_num": "20", "code_generator.enable_auto_plugin_selection": "true" }

What about when we want to use the UI? How do we set the env variable there? Or just having a secret env variable enough for it to work?

liqul commented 9 months ago

Not documented yet. But this is supported. I mean if you want to configure an environment variable, you should have the key as LLM_API_BASE for llm.api_key. The environment variables will then overwrite any corresponding keys in the config file.

For your example case, you just configure 4 env variables:

LLM_API_KEY=xxx LLM_MODEL=xxx ...

That's it.