# client.kb

> The kb methods of the morevoice Python SDK: Knowledge-base documents assistants answer from.

Knowledge-base documents assistants answer from. These methods are on `client.kb`, where `client` is a `MoreVoice` client (see [the Python SDK](https://docs.morevoice.ai/sdk/python/#connect)). On `AsyncMoreVoice` the same methods are awaited. Each one returns the response object and raises an exception when the API answers with an error.

## `documents_search()`

**Search the knowledge base.** The passages that best answer `query`, ranked like assistants and the copilot rank them (hybrid: words and meaning). Test keys search by words only, without an embedding call.

```python
# client.kb
def documents_search(self, body: _m.KbSearchParamsInput | Mapping[str, Any], *, more_voice_version: str | Unset = UNSET, idempotency_key: str | Unset = UNSET) -> _m.KbSearchResult
```

`client.kb.documents_search()` · `await async_client.kb.documents_search()` · `POST /kb/search` · [API reference](https://docs.morevoice.ai/api/operations/kb_documents_search/)

### Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `query` | `string` | yes | What to look for, in any language the documents are in. |
| `copilot_profile_id` | `string` | no | Search as this copilot profile does: its documents only. |
| `document_ids` | `string[]` | no | Search only these documents. |
| `limit` | `integer` | no | Passages to return (1–20, default 5). |

### Returns

`KbSearchResult`:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"kb_search_result"` | Always `kb_search_result`. |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `query` | `string` | — |
| `data` | `object[]` | — |
| `semantic` | `boolean` | Meaning-based retrieval took part. Test keys search by words only (no embedding call). |

### Example

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

kb_search_result = client.kb.documents_search({
    "limit": 3,
    "query": "When are you open on Friday?",
})
print(kb_search_result)
```
