> ## 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/cerebras/basic_knowledge.py theme={null}
from agno.agent import Agent
from agno.knowledge.pdf_url import PDFUrlKnowledgeBase
from agno.models.cerebras import Cerebras
from agno.vectordb.pgvector import PgVector

db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"

knowledge_base = PDFUrlKnowledgeBase(
    urls=["https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"],
    vector_db=PgVector(table_name="recipes", db_url=db_url),
)
knowledge_base.load(recreate=True)  # 首次运行时注释掉此行

agent = Agent(
    model=Cerebras(id="llama-4-scout-17b-16e-instruct"),
    knowledge=knowledge_base,
)
agent.print_response("How to make Thai curry?", markdown=True)
```

## 用法

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

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

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

  <Step title="启动您的 Postgres 服务器">
    确保您的 Postgres 服务器正在运行，并且可以从 `db_url` 中使用的连接字符串访问。
  </Step>

  <Step title="运行智能体（首次）">
    首次运行将加载并索引 PDF。这可能需要一些时间。

    <CodeGroup>
      ```bash Mac theme={null}
      python cookbook/models/cerebras/basic_knowledge.py
      ```

      ```bash Windows theme={null}
      python cookbook/models/cerebras/basic_knowledge.py
      ```
    </CodeGroup>
  </Step>

  <Step title="后续运行">
    首次运行后，注释掉或删除 `knowledge_base.load(recreate=True)` 以避免每次都重新加载 PDF。
  </Step>
</Steps>
