Skip to content

Commit

Permalink
Introduce configuration file support (#858)
Browse files Browse the repository at this point in the history
* introducing configuration file

* support for config file and custom .env location

* added docs

* simpler

* updated docs

* cleanup setting?

* fix build

* refactor: ♻️ update import for HostConfiguration module

* feat: 🎉 add check for specific env file in syncDotEnv

* removefd project file

* typo
  • Loading branch information
pelikhan authored Nov 13, 2024
1 parent 4266643 commit ec73edc
Show file tree
Hide file tree
Showing 25 changed files with 411 additions and 458 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ dev/
foobar*.genai.mjs
azure-sdk-for-js/
trapi.md
.env.local
genaiscript.config.yaml
19 changes: 0 additions & 19 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,6 @@
},
"files.eol": "\n",
"terminal.integrated.defaultProfile.windows": "Git Bash",
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#443c00",
"activityBar.background": "#443c00",
"activityBar.foreground": "#e7e7e7",
"activityBar.inactiveForeground": "#e7e7e799",
"activityBarBadge.background": "#008071",
"activityBarBadge.foreground": "#e7e7e7",
"commandCenter.border": "#e7e7e799",
"sash.hoverBorder": "#443c00",
"statusBar.background": "#110f00",
"statusBar.foreground": "#e7e7e7",
"statusBarItem.hoverBackground": "#443c00",
"statusBarItem.remoteBackground": "#110f00",
"statusBarItem.remoteForeground": "#e7e7e7",
"titleBar.activeBackground": "#110f00",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveBackground": "#110f0099",
"titleBar.inactiveForeground": "#e7e7e799"
},
"peacock.remoteColor": "#110f00",
"mdmath.delimiters": "brackets",
"spellright.language": [
Expand Down
36 changes: 8 additions & 28 deletions THIRD_PARTY_LICENSES.md
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,7 @@ available under the Apache 2.0 license (https://github.com/puppeteer/puppeteer/b

The following npm package may be included in this product:

- [email protected].1
- [email protected].2

This package contains the following license:

Expand Down Expand Up @@ -1702,7 +1702,7 @@ MIT License

The following npm package may be included in this product:

- [email protected].0
- [email protected].1

This package contains the following license:

Expand Down Expand Up @@ -3820,16 +3820,6 @@ IN THE SOFTWARE.

-----------

The following npm package may be included in this product:

- [email protected]

This package contains the following license:

http://github.com/mscdex/buildcheck/raw/master/LICENSE

-----------

The following npm package may be included in this product:

- [email protected]
Expand All @@ -3840,16 +3830,6 @@ http://github.com/mscdex/ssh2/raw/master/LICENSE

-----------

The following npm package may be included in this product:

- [email protected]

This package contains the following license:

https://github.com/mscdex/cpu-features/raw/master/LICENSE

-----------

The following npm packages may be included in this product:

- [email protected]
Expand Down Expand Up @@ -4582,12 +4562,12 @@ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

The following npm packages may be included in this product:

- @esbuild/linux-x64@0.23.1
- @esbuild/win32-x64@0.23.1
- @tokenizer/token@0.3.0
- [email protected]
- [email protected].0
- [email protected].0
- [email protected].0
- [email protected].1
- [email protected].1
- [email protected].1
- [email protected]
- [email protected]
- [email protected]
Expand Down Expand Up @@ -5356,7 +5336,7 @@ SOFTWARE.

The following npm package may be included in this product:

- [email protected].1
- [email protected].2

This package contains the following license:

Expand Down Expand Up @@ -5514,7 +5494,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
The following npm packages may be included in this product:

- [email protected]
- undici@6.20.1
- undici@6.21.0

These packages each contain the following license:

Expand Down
7 changes: 7 additions & 0 deletions docs/src/content/docs/getting-started/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import lmSelectAlt from "../../../assets/vscode-language-models-select.png.txt?r
import oaiModelsSrc from "../../../assets/openai-model-names.png"
import oaiModelsAlt from "../../../assets/openai-model-names.png.txt?raw"


You will need to configure the LLM connection and authorization secrets.

:::tip
Expand Down Expand Up @@ -134,6 +135,12 @@ npx genaiscript ... --env .env.local
GENAISCRIPT_ENV_FILE=.env.local npx genaiscript ...
```

- by specifying the `.env` file location in a [configuration file](/genaiscript/reference/configuration-files).

```yaml file="~/genaiscript.config.yaml"
envFile: ~/.env.genaiscript
```
## OpenAI
This provider, `openai`, is the OpenAI chat model provider.
Expand Down
29 changes: 29 additions & 0 deletions docs/src/content/docs/reference/configuration-files.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: Configuration Files
description: Learn how to configure common configuration settings using configuration files
sidebar:
order: 90
---

import { Code } from "@astrojs/starlight/components"
import hostConfigurationSource from "../../../../../packages/core/src/hostconfiguration.ts?raw"

GenAIScript supports local and global configuration files to allow reusing common configuration settings and secrets across multiple scripts.

## File resolution

GenAIScript will scan for the following configuration files
and merge their content into the final configuration.

- `~/genaiscript.config.yaml`
- `~/genaiscript.config.json`
- `./genaiscript.config.yaml`
- `./genaiscript.config.json`

## File format

The configuration file format is the following:

<Code code={hostConfigurationSource} wrap={true} lang="ts" />

The final location of `envFile` will be used to load the secret in the environment variables.
55 changes: 0 additions & 55 deletions docs/src/content/docs/reference/token.md

This file was deleted.

Loading

0 comments on commit ec73edc

Please sign in to comment.