Skip to content

Commit b86d1da

Browse files
authored
feat: include tavily secret if available in requests (#18)
* feat: include tavily secret if available in requests - without this change the secret must also be provided in the llama-stack environment which too me a little while to figure out - makes it a bit more consistent with the python example in https://github.com/meta-llama/llama-stack-apps/blob/592a101c155082125d8f1170cf4824860a0fd921/examples/agents/hello.py#L24 Signed-off-by: Michael Dawson <[email protected]> * squash: cleanup --------- Signed-off-by: Michael Dawson <[email protected]>
1 parent 7da9564 commit b86d1da

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

examples/agents.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22

33
import { AgentConfig } from "llama-stack-client/resources/shared";
44

5-
import LlamaStackClient from 'llama-stack-client';
6-
const client = new LlamaStackClient({ baseURL: 'http://localhost:8321' });
5+
import { LlamaStackClient, ClientOptions } from 'llama-stack-client';
6+
7+
const options: ClientOptions = { baseURL: 'http://localhost:8321' };
8+
if (process.env["TAVILY_SEARCH_API_KEY"]) {
9+
const tavilyHeader = JSON.stringify({tavily_search_api_key: process.env["TAVILY_SEARCH_API_KEY"]});
10+
options.defaultHeaders = { 'X-LlamaStack-Provider-Data': tavilyHeader }
11+
}
12+
const client = new LlamaStackClient(options);
713

814
async function main() {
915
const availableModels = (await client.models.list())
@@ -80,4 +86,4 @@ async function main() {
8086

8187
}
8288

83-
main();
89+
main();

0 commit comments

Comments
 (0)