diff options
| author | sigoden <sigoden@gmail.com> | 2024-06-06 08:52:40 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-06 08:52:40 +0800 |
| commit | 7d5b14bca135ce521a48c00e54e2e34c7bb76773 (patch) | |
| tree | 5e55922192bb8f774d603e7cac6e453f2ee32fa6 /run/tool.rb | |
| parent | bfb7d75fe47ea588495c5be8157a67b1fec67a13 (diff) | |
| download | llm-functions-docker-7d5b14bca135ce521a48c00e54e2e34c7bb76773.tar.gz | |
feat: support dotenv (#18)
Diffstat (limited to 'run/tool.rb')
| -rwxr-xr-x | run/tool.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/run/tool.rb b/run/tool.rb index cf51f3f..2b47788 100755 --- a/run/tool.rb +++ b/run/tool.rb @@ -31,6 +31,23 @@ def load_func(func_file) end end +def load_env(file_path) + return unless File.exist?(file_path) + + File.readlines(file_path).each do |line| + line = line.strip + next if line.empty? || line.start_with?('#') + + key, *value = line.split('=', 2) + ENV[key.strip] = value.join('=').strip + end +rescue StandardError +end + +ENV['LLM_FUNCTIONS_DIR'] = Pathname.new(__dir__).join('..').expand_path.to_s + +load_env(Pathname.new(ENV['LLM_FUNCTIONS_DIR']).join('.env').to_s) + func_file, func_data = parse_argv if ENV["LLM_FUNCTION_ACTION"] == "declarate" |
