> ## Documentation Index
> Fetch the complete documentation index at: https://ikun.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 拥有工具的代理

## 代码

```python cookbook/models/groq/tool_use.py theme={null}
from agno.agent import Agent
from agno.models.groq import Groq
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.newspaper4k import Newspaper4kTools

agent = Agent(
    model=Groq(id="llama-3.1-8b-instant"),
    tools=[DuckDuckGoTools(), Newspaper4kTools()],
    description="你是《纽约时报》的一名资深研究员，正在撰写一篇关于某个主题的文章。",
    instructions=[
        "对于给定的主题，搜索排名前 5 的链接。",
        "然后阅读每个 URL 并提取文章文本，如果 URL 不可用，则忽略。",
        "根据信息分析和撰写一篇符合《纽约时报》风格的文章。",
    ],
    markdown=True,
    show_tool_calls=True,
    add_datetime_to_instructions=True,
)
agent.print_response("模拟理论", stream=True)
```

## 用法

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="设置你的 API 密钥">
    ```bash theme={null}
    export GROQ_API_KEY=xxx
    ```
  </Step>

  <Step title="安装库">
    ```bash theme={null}
    pip install -U groq duckduckgo-search newspaper4k lxml_html_clean agno
    ```
  </Step>

  <Step title="运行代理">
    <CodeGroup>
      ```bash Mac theme={null}
      python cookbook/models/groq/tool_use.py
      ```

      ```bash Windows theme={null}
      python cookbook/models/groq/tool_use.py
      ```
    </CodeGroup>
  </Step>
</Steps>
