# Agentic Chunking

Agentic chunking is an intelligent method of splitting documents into smaller chunks by using an LLM to determine natural breakpoints in the text. Rather than splitting text at fixed character counts, it analyzes the content to find semantically meaningful boundaries like paragraph breaks and topic transitions.

### [​](https://docs.phidata.com/chunking/agentic-chunking#usage)Usage <a href="#usage" id="usage"></a>

```python
from bitca.agent import Agent
from bitca.document.chunking.agentic import AgenticChunking
from bitca.knowledge.pdf import PDFUrlKnowledgeBase
from bitca.vectordb.pgvector import PgVector

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

knowledge_base = PDFUrlKnowledgeBase(
    urls=["https://bitca-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"],
    vector_db=PgVector(table_name="recipes_agentic_chunking", db_url=db_url),
    chunking_strategy=AgenticChunking(),
)
knowledge_base.load(recreate=False)  # Comment out after first run

agent = Agent(
    knowledge_base=knowledge_base,
    search_knowledge=True,
)

agent.print_response("How to make Thai curry?", markdown=True)
```

### [​](https://docs.phidata.com/chunking/agentic-chunking#params)Params <a href="#params" id="params"></a>

| Parameter        | Type    | Default      | Description                     |
| ---------------- | ------- | ------------ | ------------------------------- |
| `model`          | `Model` | `OpenAIChat` | The model to use for chunking.  |
| `max_chunk_size` | `int`   | `5000`       | The maximum size of each chunk. |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.projectbit.ca/documentation/chunking/agentic-chunking.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
