vllm_mlx.gradio_text_app¶
Gradio Text-Only Chatbot Interface for vllm-mlx.
View the complete module source at #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
¶
Gradio Text-Only Chatbot Interface for vllm-mlx.
A fast, text-only chat interface for LLM models. Use this for text conversations without image/video overhead.
Usage
First start the server with a model:¶
Without a custom API model name (model path is the name used in the OpenAI API):¶
vllm-mlx serve mlx-community/Llama-3.2-3B-Instruct-4bit --port 8000
With a custom API model name ("default" is the name used in the OpenAI API):¶
vllm-mlx serve --served-model-name default mlx-community/Llama-3.2-3B-Instruct-4bit --port 8000
Then run this app:¶
vllm-mlx-text-chat --served-model-name mlx-community/Llama-3.2-3B-Instruct-4bit
Or with vllm-mlx started with served model name is 'default', there is no need to use --served-model-name:¶
vllm-mlx-text-chat --server-url http://localhost:8000 --port 7861
Note
Query the /v1/models endpoint with curl and jq to see available models and their names:
vllm_mlx.gradio_text_app.create_chat_function
¶
create_chat_function(server_url: str, max_tokens: int, temperature: float, served_model_name: str = 'default')
Create the chat function for Gradio ChatInterface.
Parameters:
-
server_url(str) –URL of the vllm-mlx server
-
max_tokens(int) –Maximum tokens to generate
-
temperature(float) –Sampling temperature
-
served_model_name(str, default:'default') –Model name to send in OpenAI-compatible requests
Returns:
-
–
Chat function compatible with gr.ChatInterface
Source code in vllm_mlx/gradio_text_app.py
vllm_mlx.gradio_text_app.main
¶
Run the Gradio app.
Source code in vllm_mlx/gradio_text_app.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
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.
vllm_mlx.gradio_text_app.create_chat_function · function
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.
vllm_mlx.gradio_text_app.create_chat_function.chat · nested function
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.
vllm_mlx.gradio_text_app.main · function
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.
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 |
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 |
create_chat_function.chat |
nested function | create_chat_function.chat(message: str, history: list) -> str |
Process a text message and return response. | #L53-L106 |
main |
function | main() -> not annotated |
Run the Gradio app. | #L111-L201 |