mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-03 17:29:01 +00:00
tested with v0.2.1
This commit is contained in:
parent
41dbb91371
commit
edf8610448
1 changed files with 17 additions and 4 deletions
|
@ -208,18 +208,24 @@ response = agent.create_turn(
|
||||||
```
|
```
|
||||||
## Simple Example 2: Using an Agent with the Web Search Tool
|
## Simple Example 2: Using an Agent with the Web Search Tool
|
||||||
1. Start by registering a Tavily API key at [Tavily](https://tavily.com/).
|
1. Start by registering a Tavily API key at [Tavily](https://tavily.com/).
|
||||||
2. When starting the Llama Stack server, ensure the API key is provided as an environment variable:
|
2. [Optional] Provide the API key directly to the Llama Stack server
|
||||||
|
```bash
|
||||||
|
export TAVILY_SEARCH_API_KEY="your key"
|
||||||
```
|
```
|
||||||
|
```bash
|
||||||
--env TAVILY_SEARCH_API_KEY=${TAVILY_SEARCH_API_KEY}
|
--env TAVILY_SEARCH_API_KEY=${TAVILY_SEARCH_API_KEY}
|
||||||
```
|
```
|
||||||
3. run the following script.
|
3. Run the following script.
|
||||||
```python
|
```python
|
||||||
from llama_stack_client.lib.agents.agent import Agent
|
from llama_stack_client.lib.agents.agent import Agent
|
||||||
from llama_stack_client.types.agent_create_params import AgentConfig
|
from llama_stack_client.types.agent_create_params import AgentConfig
|
||||||
from llama_stack_client.lib.agents.event_logger import EventLogger
|
from llama_stack_client.lib.agents.event_logger import EventLogger
|
||||||
from llama_stack_client import LlamaStackClient
|
from llama_stack_client import LlamaStackClient
|
||||||
|
|
||||||
client = LlamaStackClient(base_url=f"http://localhost:8321")
|
client = LlamaStackClient(
|
||||||
|
base_url=f"http://localhost:8321",
|
||||||
|
provider_data = {"tavily_search_api_key": "your_TAVILY_SEARCH_API_KEY"} # Set this from the client side. No need to provide it if it has already been configured on the Llama Stack server.
|
||||||
|
)
|
||||||
|
|
||||||
agent = Agent(
|
agent = Agent(
|
||||||
client,
|
client,
|
||||||
|
@ -242,10 +248,17 @@ for log in EventLogger().log(response):
|
||||||
|
|
||||||
## Simple Example3: Using an Agent with the WolframAlpha Tool
|
## Simple Example3: Using an Agent with the WolframAlpha Tool
|
||||||
1. Start by registering for a WolframAlpha API key at [WolframAlpha Developer Portal](https://developer.wolframalpha.com/access).
|
1. Start by registering for a WolframAlpha API key at [WolframAlpha Developer Portal](https://developer.wolframalpha.com/access).
|
||||||
2. When starting the Llama Stack server, ensure the API key is provided as an environment variable:
|
2. Provide the API key either when starting the Llama Stack server:
|
||||||
```bash
|
```bash
|
||||||
--env WOLFRAM_ALPHA_API_KEY=${WOLFRAM_ALPHA_API_KEY}
|
--env WOLFRAM_ALPHA_API_KEY=${WOLFRAM_ALPHA_API_KEY}
|
||||||
```
|
```
|
||||||
|
or from the client side:
|
||||||
|
```python
|
||||||
|
client = LlamaStackClient(
|
||||||
|
base_url="http://localhost:8321",
|
||||||
|
provider_data={"wolfram_alpha_api_key": wolfram_api_key}
|
||||||
|
)
|
||||||
|
```
|
||||||
3. Configure the tools in the Agent by setting `tools=["builtin::wolfram_alpha"]`.
|
3. Configure the tools in the Agent by setting `tools=["builtin::wolfram_alpha"]`.
|
||||||
4. Example user query:
|
4. Example user query:
|
||||||
```python
|
```python
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue