> ## 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.

# 设置 Ollama 客户端

## 代码

```python cookbook/models/ollama/set_client.py theme={null}
from agno.agent import Agent, RunResponse  # noqa
from agno.models.ollama import Ollama
from agno.tools.yfinance import YFinanceTools
from ollama import Client as OllamaClient

agent = Agent(
    model=Ollama(id="llama3.2", client=OllamaClient()),
    tools=[YFinanceTools(stock_price=True)],
    markdown=True,
)

# 在终端打印响应
agent.print_response("写一个两句的恐怖故事")
```

## 用法

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

  <Step title="安装 Ollama">
    遵循[安装指南](https://github.com/ollama/ollama?tab=readme-ov-file#macos)并运行：

    ```bash theme={null}
    ollama pull llama3.2
    ```
  </Step>

  <Step title="安装库">
    ```bash theme={null}
    pip install -U ollama yfinance agno
    ```
  </Step>

  <Step title="运行 Agent">
    <CodeGroup>
      ```bash Mac theme={null}
      python cookbook/models/ollama/set_client.py
      ```

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