# `vllm_mlx.gradio_text_app`

Gradio Text-Only Chatbot Interface for vllm-mlx.

[View the complete module source at #L1-L205](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/gradio_text_app.py#L1-L205).

## API details

Each callable below includes its exact signature, type annotations, inputs, defaults, return contract, documented exceptions, implementation source, and parsed docstring sections when the source provides them.

::: vllm_mlx.gradio_text_app
    options:
      members:
        - create_chat_function
        - main
      filters: []
      show_if_no_docstring: true

## Complete contract reference

Expand any definition for its exact inputs, annotations, defaults, return contract, directly raised exceptions, source-grounded behavior, and immutable line link. This section includes private and nested definitions that ordinary API generators omit.

<details class="api-contract" id="contract-vllm_mlx.gradio_text_app.create_chat_function" markdown="1">
<summary><code>vllm_mlx.gradio_text_app.create_chat_function</code> · function</summary>

```python
vllm_mlx.gradio_text_app.create_chat_function(server_url: str, max_tokens: int, temperature: float, served_model_name: str = 'default') -> not annotated
```

Create the chat function for Gradio ChatInterface.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `server_url` | `str` | `yes` | `none` | URL of the vllm-mlx server |
| `max_tokens` | `int` | `yes` | `none` | Maximum tokens to generate |
| `temperature` | `float` | `yes` | `none` | Sampling temperature |
| `served_model_name` | `str` | `no` | `'default'` | Model name to send in OpenAI-compatible requests |

**Returns**

- Type: `not annotated`
- Direct return expressions: `chat`

**Exceptions and behavior**

Function `create_chat_function` returns `chat`.
No direct `raise` statement appears in this definition.

[View source #L34-L108](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/gradio_text_app.py#L34-L108).

</details>

<details class="api-contract" id="contract-vllm_mlx.gradio_text_app.create_chat_function.chat" markdown="1">
<summary><code>vllm_mlx.gradio_text_app.create_chat_function.chat</code> · nested function</summary>

```python
vllm_mlx.gradio_text_app.create_chat_function.chat(message: str, history: list) -> str
```

Process a text message and return response.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `message` | `str` | `yes` | `none` | User's text message |
| `history` | `list` | `yes` | `none` | List of previous messages |

**Returns**

- Type: `str`
- Direct return expressions: `result['choices'][0]['message']['content']`; `'Error: Cannot connect to server. Make sure vllm-mlx is running.'`; `'Error: Timeout - server took too long to respond.'`; `f'Error: {str(e)}'`

**Exceptions and behavior**

Nested Function `create_chat_function.chat` calls `isinstance`, `msg.get`, `p.get`, `' '.join`; has 4 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L53-L106](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/gradio_text_app.py#L53-L106).

</details>

<details class="api-contract" id="contract-vllm_mlx.gradio_text_app.main" markdown="1">
<summary><code>vllm_mlx.gradio_text_app.main</code> · function</summary>

```python
vllm_mlx.gradio_text_app.main() -> not annotated
```

Run the Gradio app.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `not annotated`

**Exceptions and behavior**

Function `main` calls `argparse.ArgumentParser`, `parser.add_argument`, `parser.parse_args`, `print`.
No direct `raise` statement appears in this definition.

[View source #L111-L201](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/gradio_text_app.py#L111-L201).

</details>

## Complete symbol map

This map also includes private definitions and nested helpers. The signature column exposes every explicit input even when an internal helper has no dedicated parameter prose.

| Symbol | Kind | Signature and inputs | What it does | Source |
| --- | --- | --- | --- | --- |
| [`create_chat_function`](#contract-vllm_mlx.gradio_text_app.create_chat_function) | function | `create_chat_function(server_url: str, max_tokens: int, temperature: float, served_model_name: str = 'default') -> not annotated` | Create the chat function for Gradio ChatInterface. | [#L34-L108](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/gradio_text_app.py#L34-L108) |
| [`create_chat_function.chat`](#contract-vllm_mlx.gradio_text_app.create_chat_function.chat) | nested function | `create_chat_function.chat(message: str, history: list) -> str` | Process a text message and return response. | [#L53-L106](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/gradio_text_app.py#L53-L106) |
| [`main`](#contract-vllm_mlx.gradio_text_app.main) | function | `main() -> not annotated` | Run the Gradio app. | [#L111-L201](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/gradio_text_app.py#L111-L201) |
