Skip to content

Commit 92e81dd

Browse files
committed
docs
Signed-off-by: Grant Linville <[email protected]>
1 parent cc244eb commit 92e81dd

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

docs/docs/03-tools/04-credential-tools.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,55 @@ import os
222222
223223
print("myCred expires at " + os.getenv("GPTSCRIPT_CREDENTIAL_EXPIRATION", ""))
224224
```
225+
226+
## Stacked Credential Contexts (Advanced)
227+
228+
When setting the `--credential-context` argument in GPTScript, you can specify multiple contexts separated by commas.
229+
We refer to this as "stacked credential contexts", or just stacked contexts for short. This allows you to specify an order
230+
of priority for credential contexts. This is best explained by example.
231+
232+
### Example: stacked contexts when running a script that uses a credential
233+
234+
Let's say you have two contexts, `one` and `two`, and you specify them like this:
235+
236+
```bash
237+
gptscript --credential-context one,two my-script.gpt
238+
```
239+
240+
```
241+
Credential: my-credential-tool.gpt as myCred
242+
243+
<tool stuff here>
244+
```
245+
246+
When GPTScript runs, it will first look for a credential called `myCred` in the `one` context.
247+
If it doesn't find it there, it will look for it in the `two` context. If it also doesn't find it there,
248+
it will run the `my-credential-tool.gpt` tool to get the credential. It will then store the new credential into the `one`
249+
context, since that has the highest priority.
250+
251+
### Example: stacked contexts when listing credentials
252+
253+
```bash
254+
gptscript --credential-context one,two credentials
255+
```
256+
257+
When you list credentials like this, GPTScript will print out the information for all credentials in contexts one and two,
258+
with one exception. If there is a credential name that exists in both contexts, GPTScript will only print the information
259+
for the credential in the context with the highest priority, which in this case is `one`.
260+
261+
(To see all credentials in all contexts, you can still use the `--all-contexts` flag, and it will show all credentials,
262+
regardless of whether the same name appears in another context.)
263+
264+
### Example: stacked contexts when showing credentials
265+
266+
```bash
267+
gptscript --credential-context one,two credential show myCred
268+
```
269+
270+
When you show a credential like this, GPTScript will first look for `myCred` in the `one` context. If it doesn't find it
271+
there, it will look for it in the `two` context. If it doesn't find it in either context, it will print an error message.
272+
273+
:::note
274+
You cannot specify stacked contexts when doing `gptscript credential delete`. GPTScript will return an error if
275+
more than one context is specified for this command.
276+
:::

0 commit comments

Comments
 (0)